aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/RelNotes/2.2.0.txt21
-rw-r--r--Documentation/git-credential-cache--daemon.txt6
-rw-r--r--Documentation/git-rev-parse.txt1
-rw-r--r--Documentation/pretty-formats.txt6
-rw-r--r--Documentation/technical/api-allocation-growing.txt3
-rw-r--r--attr.c3
-rw-r--r--builtin/apply.c2
-rw-r--r--builtin/branch.c33
-rw-r--r--builtin/for-each-ref.c9
-rw-r--r--builtin/fsck.c2
-rw-r--r--builtin/hash-object.c103
-rw-r--r--builtin/index-pack.c7
-rw-r--r--builtin/log.c2
-rw-r--r--builtin/merge.c2
-rw-r--r--builtin/mv.c8
-rw-r--r--builtin/pack-objects.c3
-rw-r--r--builtin/prune-packed.c1
-rw-r--r--builtin/receive-pack.c6
-rw-r--r--builtin/repack.c23
-rw-r--r--builtin/rev-parse.c5
-rw-r--r--builtin/show-branch.c7
-rw-r--r--builtin/unpack-objects.c14
-rw-r--r--cache.h4
-rw-r--r--column.c6
-rw-r--r--commit-slab.h3
-rw-r--r--credential-cache--daemon.c25
-rw-r--r--fast-import.c2
-rw-r--r--fsck.c133
-rw-r--r--fsck.h4
-rw-r--r--git-compat-util.h2
-rwxr-xr-xgit-stash.sh13
-rw-r--r--git.c3
-rw-r--r--graph.c31
-rw-r--r--help.c2
-rw-r--r--khash.h12
-rw-r--r--line-log.c2
-rw-r--r--log-tree.c17
-rw-r--r--log-tree.h8
-rw-r--r--object.c13
-rw-r--r--object.h3
-rw-r--r--pack-bitmap-write.c3
-rw-r--r--pack-bitmap.c6
-rw-r--r--pack-objects.c3
-rw-r--r--po/TEAMS1
-rw-r--r--po/de.po100
-rw-r--r--pretty.c4
-rw-r--r--refs.c171
-rw-r--r--refs.h3
-rw-r--r--revision.c2
-rw-r--r--server-info.c123
-rw-r--r--sh-i18n--envsubst.c5
-rw-r--r--sha1_name.c24
-rw-r--r--shallow.c3
-rw-r--r--string-list.c3
-rwxr-xr-xt/t1450-fsck.sh38
-rwxr-xr-xt/t1503-rev-parse-verify.sh37
-rwxr-xr-xt/t3201-branch-contains.sh29
-rwxr-xr-xt/t3210-pack-refs.sh31
-rwxr-xr-xt/t4205-log-pretty-formats.sh11
-rwxr-xr-xt/t5302-pack-index.sh19
-rwxr-xr-xt/t5401-update-hooks.sh13
-rw-r--r--walker.c4
-rw-r--r--write_or_die.c15
63 files changed, 828 insertions, 370 deletions
diff --git a/Documentation/RelNotes/2.2.0.txt b/Documentation/RelNotes/2.2.0.txt
index a8a27a95b..a5e3ce8f5 100644
--- a/Documentation/RelNotes/2.2.0.txt
+++ b/Documentation/RelNotes/2.2.0.txt
@@ -40,6 +40,10 @@ UI, Workflows & Features
forgot to remove higher stage entries, or if it wanted to unresolve
and forgot to remove the stage#0 entry).
+ * The "pre-receive" and "post-receive" hooks are no longer required
+ to consume their input fully (not following this requirement used
+ to result in intermittent errors in "git push").
+
Performance, Internal Implementation, etc.
@@ -87,6 +91,20 @@ Performance, Internal Implementation, etc.
to two separate options is detected by parse_options() API to help
developers.
+ * The code path to write out the packed-refs file has been optimized,
+ which especially matters in a repository with a large number of
+ refs.
+
+ * The check to see if a ref $F can be created by making sure no
+ existing ref has $F/ as its prefix has been optimized, which
+ especially matters in a repository with a large number of existing
+ refs.
+
+ * "git fsck" was taught to check contents of tag objects a bit more.
+
+ * "git hash-object" was taught a "--literally" option to help
+ debugging.
+
Also contains various documentation updates and code clean-ups.
@@ -169,3 +187,6 @@ notes for details).
* "git fsck" failed to report that it found corrupt objects via its
exit status in some cases.
(merge 30d1038 jk/fsck-exit-code-fix later to maint).
+
+ * Use of "--verbose" option used to break "git branch --merged".
+ (merge 12994dd jk/maint-branch-verbose-merged later to maint).
diff --git a/Documentation/git-credential-cache--daemon.txt b/Documentation/git-credential-cache--daemon.txt
index d15db42d4..7051c6bdf 100644
--- a/Documentation/git-credential-cache--daemon.txt
+++ b/Documentation/git-credential-cache--daemon.txt
@@ -8,7 +8,7 @@ git-credential-cache--daemon - Temporarily store user credentials in memory
SYNOPSIS
--------
[verse]
-git credential-cache--daemon <socket>
+git credential-cache--daemon [--debug] <socket>
DESCRIPTION
-----------
@@ -21,6 +21,10 @@ for `git-credential-cache` clients. Clients may store and retrieve
credentials. Each credential is held for a timeout specified by the
client; once no credentials are held, the daemon exits.
+If the `--debug` option is specified, the daemon does not close its
+stderr stream, and may output extra diagnostics to it even after it has
+begun listening for clients.
+
GIT
---
Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 0b84769bd..fa4a8c3af 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -114,6 +114,7 @@ can be used.
Only meaningful in `--verify` mode. Do not output an error
message if the first argument is not a valid object name;
instead exit with non-zero status silently.
+ SHA-1s for valid object names are printed to stdout on success.
--sq::
Usually the output is made one line per flag and
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 6c3072374..eecc39dec 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -130,6 +130,7 @@ The placeholders are:
- '%ci': committer date, ISO 8601-like format
- '%cI': committer date, strict ISO 8601 format
- '%d': ref names, like the --decorate option of linkgit:git-log[1]
+- '%D': ref names without the " (", ")" wrapping.
- '%e': encoding
- '%s': subject
- '%f': sanitized subject line, suitable for a filename
@@ -184,8 +185,9 @@ The placeholders are:
NOTE: Some placeholders may depend on other options given to the
revision traversal engine. For example, the `%g*` reflog options will
insert an empty string unless we are traversing reflog entries (e.g., by
-`git log -g`). The `%d` placeholder will use the "short" decoration
-format if `--decorate` was not already provided on the command line.
+`git log -g`). The `%d` and `%D` placeholders will use the "short"
+decoration format if `--decorate` was not already provided on the command
+line.
If you add a `+` (plus sign) after '%' of a placeholder, a line-feed
is inserted immediately before the expansion if and only if the
diff --git a/Documentation/technical/api-allocation-growing.txt b/Documentation/technical/api-allocation-growing.txt
index 542946b1b..5a59b5484 100644
--- a/Documentation/technical/api-allocation-growing.txt
+++ b/Documentation/technical/api-allocation-growing.txt
@@ -34,3 +34,6 @@ item[nr++] = value you like;
------------
You are responsible for updating the `nr` variable.
+
+If you need to specify the number of elements to allocate explicitly
+then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
diff --git a/attr.c b/attr.c
index 734222dc4..cd5469770 100644
--- a/attr.c
+++ b/attr.c
@@ -97,8 +97,7 @@ static struct git_attr *git_attr_internal(const char *name, int len)
a->attr_nr = attr_nr++;
git_attr_hash[pos] = a;
- check_all_attr = xrealloc(check_all_attr,
- sizeof(*check_all_attr) * attr_nr);
+ REALLOC_ARRAY(check_all_attr, attr_nr);
check_all_attr[a->attr_nr].attr = a;
check_all_attr[a->attr_nr].value = ATTR__UNKNOWN;
return a;
diff --git a/builtin/apply.c b/builtin/apply.c
index f204cca5d..8714a8872 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2626,7 +2626,7 @@ static void update_image(struct image *img,
* NOTE: this knows that we never call remove_first_line()
* on anything other than pre/post image.
*/
- img->line = xrealloc(img->line, nr * sizeof(*img->line));
+ REALLOC_ARRAY(img->line, nr);
img->line_allocated = img->line;
}
if (preimage_limit != postimage->nr)
diff --git a/builtin/branch.c b/builtin/branch.c
index ced422b62..9e4666f0c 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -280,6 +280,7 @@ struct ref_item {
char *dest;
unsigned int kind, width;
struct commit *commit;
+ int ignore;
};
struct ref_list {
@@ -385,6 +386,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
newitem->commit = commit;
newitem->width = utf8_strwidth(refname);
newitem->dest = resolve_symref(orig_refname, prefix);
+ newitem->ignore = 0;
/* adjust for "remotes/" */
if (newitem->kind == REF_REMOTE_BRANCH &&
ref_list->kinds != REF_REMOTE_BRANCH)
@@ -484,17 +486,6 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
free(ref);
}
-static int matches_merge_filter(struct commit *commit)
-{
- int is_merged;
-
- if (merge_filter == NO_FILTER)
- return 1;
-
- is_merged = !!(commit->object.flags & UNINTERESTING);
- return (is_merged == (merge_filter == SHOW_MERGED));
-}
-
static void add_verbose_info(struct strbuf *out, struct ref_item *item,
int verbose, int abbrev)
{
@@ -522,10 +513,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
{
char c;
int color;
- struct commit *commit = item->commit;
struct strbuf out = STRBUF_INIT, name = STRBUF_INIT;
- if (!matches_merge_filter(commit))
+ if (item->ignore)
return;
switch (item->kind) {
@@ -575,7 +565,7 @@ static int calc_maxwidth(struct ref_list *refs)
{
int i, w = 0;
for (i = 0; i < refs->index; i++) {
- if (!matches_merge_filter(refs->list[i].commit))
+ if (refs->list[i].ignore)
continue;
if (refs->list[i].width > w)
w = refs->list[i].width;
@@ -618,6 +608,7 @@ static void show_detached(struct ref_list *ref_list)
item.kind = REF_LOCAL_BRANCH;
item.dest = NULL;
item.commit = head_commit;
+ item.ignore = 0;
if (item.width > ref_list->maxwidth)
ref_list->maxwidth = item.width;
print_ref_item(&item, ref_list->maxwidth, ref_list->verbose, ref_list->abbrev, 1, "");
@@ -656,6 +647,20 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
if (prepare_revision_walk(&ref_list.revs))
die(_("revision walk setup failed"));
+
+ for (i = 0; i < ref_list.index; i++) {
+ struct ref_item *item = &ref_list.list[i];
+ struct commit *commit = item->commit;
+ int is_merged = !!(commit->object.flags & UNINTERESTING);
+ item->ignore = is_merged != (merge_filter == SHOW_MERGED);
+ }
+
+ for (i = 0; i < ref_list.index; i++) {
+ struct ref_item *item = &ref_list.list[i];
+ clear_commit_marks(item->commit, ALL_REV_FLAGS);
+ }
+ clear_commit_marks(filter, ALL_REV_FLAGS);
+
if (verbose)
ref_list.maxwidth = calc_maxwidth(&ref_list);
}
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 69bba0671..fda0f0471 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -138,10 +138,8 @@ static int parse_atom(const char *atom, const char *ep)
/* Add it in, including the deref prefix */
at = used_atom_cnt;
used_atom_cnt++;
- used_atom = xrealloc(used_atom,
- (sizeof *used_atom) * used_atom_cnt);
- used_atom_type = xrealloc(used_atom_type,
- (sizeof(*used_atom_type) * used_atom_cnt));
+ REALLOC_ARRAY(used_atom, used_atom_cnt);
+ REALLOC_ARRAY(used_atom_type, used_atom_cnt);
used_atom[at] = xmemdupz(atom, ep - atom);
used_atom_type[at] = valid_atom[i].cmp_type;
if (*atom == '*')
@@ -870,8 +868,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
ref->flag = flag;
cnt = cb->grab_cnt;
- cb->grab_array = xrealloc(cb->grab_array,
- sizeof(*cb->grab_array) * (cnt + 1));
+ REALLOC_ARRAY(cb->grab_array, cnt + 1);
cb->grab_array[cnt++] = ref;
cb->grab_cnt = cnt;
return 0;
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 0928a98a7..e9ba576c1 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -298,7 +298,7 @@ static int fsck_obj(struct object *obj)
if (fsck_walk(obj, mark_used, NULL))
objerror(obj, "broken links");
- if (fsck_object(obj, check_strict, fsck_error_func))
+ if (fsck_object(obj, NULL, 0, check_strict, fsck_error_func))
return -1;
if (obj->type == OBJ_TREE) {
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index d7fcf4c13..615836331 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -10,35 +10,55 @@
#include "parse-options.h"
#include "exec_cmd.h"
-static void hash_fd(int fd, const char *type, int write_object, const char *path)
+/*
+ * This is to create corrupt objects for debugging and as such it
+ * needs to bypass the data conversion performed by, and the type
+ * limitation imposed by, index_fd() and its callees.
+ */
+static int hash_literally(unsigned char *sha1, int fd, const char *type, unsigned flags)
+{
+ struct strbuf buf = STRBUF_INIT;
+ int ret;
+
+ if (strbuf_read(&buf, fd, 4096) < 0)
+ ret = -1;
+ else if (flags & HASH_WRITE_OBJECT)
+ ret = write_sha1_file(buf.buf, buf.len, type, sha1);
+ else
+ ret = hash_sha1_file(buf.buf, buf.len, type, sha1);
+ strbuf_release(&buf);
+ return ret;
+}
+
+static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
+ int literally)
{
struct stat st;
unsigned char sha1[20];
- unsigned flags = (HASH_FORMAT_CHECK |
- (write_object ? HASH_WRITE_OBJECT : 0));
if (fstat(fd, &st) < 0 ||
- index_fd(sha1, fd, &st, type_from_string(type), path, flags))
- die(write_object
+ (literally
+ ? hash_literally(sha1, fd, type, flags)
+ : index_fd(sha1, fd, &st, type_from_string(type), path, flags)))
+ die((flags & HASH_WRITE_OBJECT)
? "Unable to add %s to database"
: "Unable to hash %s", path);
printf("%s\n", sha1_to_hex(sha1));
maybe_flush_or_die(stdout, "hash to stdout");
}
-static void hash_object(const char *path, const char *type, int write_object,
- const char *vpath)
+static void hash_object(const char *path, const char *type, const char *vpath,
+ unsigned flags, int literally)
{
int fd;
fd = open(path, O_RDONLY);
if (fd < 0)
die_errno("Cannot open '%s'", path);
- hash_fd(fd, type, write_object, vpath);
+ hash_fd(fd, type, vpath, flags, literally);
}
-static int no_filters;
-
-static void hash_stdin_paths(const char *type, int write_objects)
+static void hash_stdin_paths(const char *type, int no_filters, unsigned flags,
+ int literally)
{
struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
@@ -49,47 +69,46 @@ static void hash_stdin_paths(const char *type, int write_objects)
die("line is badly quoted");
strbuf_swap(&buf, &nbuf);
}
- hash_object(buf.buf, type, write_objects,
- no_filters ? NULL : buf.buf);
+ hash_object(buf.buf, type, no_filters ? NULL : buf.buf, flags,
+ literally);
}
strbuf_release(&buf);
strbuf_release(&nbuf);
}
-static const char * const hash_object_usage[] = {
- N_("git hash-object [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin] [--] <file>..."),
- N_("git hash-object --stdin-paths < <list-of-paths>"),
- NULL
-};
-
-static const char *type;
-static int write_object;
-static int hashstdin;
-static int stdin_paths;
-static const char *vpath;
-
-static const struct option hash_object_options[] = {
- OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
- OPT_BOOL('w', NULL, &write_object, N_("write the object into the object database")),
- OPT_COUNTUP( 0 , "stdin", &hashstdin, N_("read the object from stdin")),
- OPT_BOOL( 0 , "stdin-paths", &stdin_paths, N_("read file names from stdin")),
- OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")),
- OPT_STRING( 0 , "path", &vpath, N_("file"), N_("process file as it were from this path")),
- OPT_END()
-};
-
int cmd_hash_object(int argc, const char **argv, const char *prefix)
{
+ static const char * const hash_object_usage[] = {
+ N_("git hash-object [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin] [--] <file>..."),
+ N_("git hash-object --stdin-paths < <list-of-paths>"),
+ NULL
+ };
+ const char *type = blob_type;
+ int hashstdin = 0;
+ int stdin_paths = 0;
+ int no_filters = 0;
+ int literally = 0;
+ unsigned flags = HASH_FORMAT_CHECK;
+ const char *vpath = NULL;
+ const struct option hash_object_options[] = {
+ OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
+ OPT_BIT('w', NULL, &flags, N_("write the object into the object database"),
+ HASH_WRITE_OBJECT),
+ OPT_COUNTUP( 0 , "stdin", &hashstdin, N_("read the object from stdin")),
+ OPT_BOOL( 0 , "stdin-paths", &stdin_paths, N_("read file names from stdin")),
+ OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")),
+ OPT_BOOL( 0, "literally", &literally, N_("just hash any random garbage to create corrupt objects for debugging Git")),
+ OPT_STRING( 0 , "path", &vpath, N_("file"), N_("process file as it were from this path")),
+ OPT_END()
+ };
int i;
int prefix_length = -1;
const char *errstr = NULL;
- type = blob_type;
-
argc = parse_options(argc, argv, NULL, hash_object_options,
hash_object_usage, 0);
- if (write_object) {
+ if (flags & HASH_WRITE_OBJECT) {
prefix = setup_git_directory();
prefix_length = prefix ? strlen(prefix) : 0;
if (vpath && prefix)
@@ -119,19 +138,19 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
}
if (hashstdin)
- hash_fd(0, type, write_object, vpath);
+ hash_fd(0, type, vpath, flags, literally);
for (i = 0 ; i < argc; i++) {
const char *arg = argv[i];
if (0 <= prefix_length)
arg = prefix_filename(prefix, prefix_length, arg);
- hash_object(arg, type, write_object,
- no_filters ? NULL : vpath ? vpath : arg);
+ hash_object(arg, type, no_filters ? NULL : vpath ? vpath : arg,
+ flags, literally);
}
if (stdin_paths)
- hash_stdin_paths(type, write_object);
+ hash_stdin_paths(type, no_filters, flags, literally);
return 0;
}
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index eebf1a8fc..792c66ca5 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -779,7 +779,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (!obj)
die(_("invalid %s"), typename(type));
if (do_fsck_object &&
- fsck_object(obj, 1, fsck_error_function))
+ fsck_object(obj, buf, size, 1,
+ fsck_error_function))
die(_("Error in object"));
if (fsck_walk(obj, mark_link, NULL))
die(_("Not all child objects of %s are reachable"), sha1_to_hex(obj->sha1));
@@ -1169,9 +1170,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
int nr_objects_initial = nr_objects;
if (nr_unresolved <= 0)
die(_("confusion beyond insanity"));
- objects = xrealloc(objects,
- (nr_objects + nr_unresolved + 1)
- * sizeof(*objects));
+ REALLOC_ARRAY(objects, nr_objects + nr_unresolved + 1);
memset(objects + nr_objects + 1, 0,
nr_unresolved * sizeof(*objects));
f = sha1fd(output_fd, curr_pack);
diff --git a/builtin/log.c b/builtin/log.c
index 4ea71fee6..2fb34c7de 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1440,7 +1440,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
continue;
nr++;
- list = xrealloc(list, nr * sizeof(list[0]));
+ REALLOC_ARRAY(list, nr);
list[nr - 1] = commit;
}
if (nr == 0)
diff --git a/builtin/merge.c b/builtin/merge.c
index ec6fa9398..dff043dac 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -556,7 +556,7 @@ static void parse_branch_merge_options(char *bmo)
if (argc < 0)
die(_("Bad branch.%s.mergeoptions string: %s"), branch,
split_cmdline_strerror(argc));
- argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
+ REALLOC_ARRAY(argv, argc + 2);
memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
argc++;
argv[0] = "branch.*.mergeoptions";
diff --git a/builtin/mv.c b/builtin/mv.c
index bf784cb94..8883baa90 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -184,10 +184,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
modes[i] = WORKING_DIRECTORY;
n = argc + last - first;
- source = xrealloc(source, n * sizeof(char *));
- destination = xrealloc(destination, n * sizeof(char *));
- modes = xrealloc(modes, n * sizeof(enum update_mode));
- submodule_gitfile = xrealloc(submodule_gitfile, n * sizeof(char *));
+ REALLOC_ARRAY(source, n);
+ REALLOC_ARRAY(destination, n);
+ REALLOC_ARRAY(modes, n);
+ REALLOC_ARRAY(submodule_gitfile, n);
dst = add_slash(dst);
dst_len = strlen(dst);
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index b59f5d895..d39193453 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -89,8 +89,7 @@ static void index_commit_for_bitmap(struct commit *commit)
{
if (indexed_commits_nr >= indexed_commits_alloc) {
indexed_commits_alloc = (indexed_commits_alloc + 32) * 2;
- indexed_commits = xrealloc(indexed_commits,
- indexed_commits_alloc * sizeof(struct commit *));
+ REALLOC_ARRAY(indexed_commits, indexed_commits_alloc);
}
indexed_commits[indexed_commits_nr++] = commit;
diff --git a/builtin/prune-packed.c b/builtin/prune-packed.c
index 6879468c4..d430731d7 100644
--- a/builtin/prune-packed.c
+++ b/builtin/prune-packed.c
@@ -68,6 +68,7 @@ void prune_packed_objects(int opts)
rmdir(pathname.buf);
}
stop_progress(&progress);
+ strbuf_release(&pathname);
}
int cmd_prune_packed(int argc, const char **argv, const char *prefix)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index afb8d9926..daf0600ca 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -15,6 +15,7 @@
#include "connected.h"
#include "argv-array.h"
#include "version.h"
+#include "sigchain.h"
static const char receive_pack_usage[] = "git receive-pack <git-dir>";
@@ -287,6 +288,8 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
return code;
}
+ sigchain_push(SIGPIPE, SIG_IGN);
+
while (1) {
const char *buf;
size_t n;
@@ -298,6 +301,9 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
close(proc.in);
if (use_sideband)
finish_async(&muxer);
+
+ sigchain_pop(SIGPIPE);
+
return finish_command(&proc);
}
diff --git a/builtin/repack.c b/builtin/repack.c
index fc088dbe6..2aae05d36 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -377,6 +377,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
/* End of pack replacement. */
if (delete_redundant) {
+ int opts = 0;
sort_string_list(&names);
for_each_string_list_item(item, &existing_packs) {
char *sha1;
@@ -387,25 +388,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
if (!string_list_has_string(&names, sha1))
remove_redundant_pack(packdir, item->string);
}
- argv_array_push(&cmd_args, "prune-packed");
- if (quiet)
- argv_array_push(&cmd_args, "--quiet");
-
- memset(&cmd, 0, sizeof(cmd));
- cmd.argv = cmd_args.argv;
- cmd.git_cmd = 1;
- run_command(&cmd);
- argv_array_clear(&cmd_args);
+ if (!quiet && isatty(2))
+ opts |= PRUNE_PACKED_VERBOSE;
+ prune_packed_objects(opts);
}
- if (!no_update_server_info) {
- argv_array_push(&cmd_args, "update-server-info");
- memset(&cmd, 0, sizeof(cmd));
- cmd.argv = cmd_args.argv;
- cmd.git_cmd = 1;
- run_command(&cmd);
- argv_array_clear(&cmd_args);
- }
+ if (!no_update_server_info)
+ update_server_info(0);
remove_temporary_files();
string_list_clear(&names, 0);
string_list_clear(&rollback, 0);
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index c911b456d..35d3c43ed 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -508,7 +508,9 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
int has_dashdash = 0;
int output_prefix = 0;
unsigned char sha1[20];
+ unsigned int flags = 0;
const char *name = NULL;
+ struct object_context unused;
if (argc > 1 && !strcmp("--parseopt", argv[1]))
return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -596,6 +598,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
}
if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
quiet = 1;
+ flags |= GET_SHA1_QUIETLY;
continue;
}
if (!strcmp(arg, "--short") ||
@@ -818,7 +821,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
name++;
type = REVERSED;
}
- if (!get_sha1(name, sha1)) {
+ if (!get_sha1_with_context(name, flags, sha1, &unused)) {
if (verify)
revs_count++;
else
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 298c95e3f..199b081e9 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -563,7 +563,7 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
default_arg[default_num++] = "show-branch";
} else if (default_alloc <= default_num + 1) {
default_alloc = default_alloc * 3 / 2 + 20;
- default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);
+ REALLOC_ARRAY(default_arg, default_alloc);
}
default_arg[default_num++] = xstrdup(value);
default_arg[default_num] = NULL;
@@ -723,6 +723,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
char nth_desc[256];
char *ref;
int base = 0;
+ unsigned int flags = 0;
if (ac == 0) {
static const char *fake_av[2];
@@ -749,7 +750,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
/* Ah, that is a date spec... */
unsigned long at;
at = approxidate(reflog_base);
- read_ref_at(ref, at, -1, sha1, NULL,
+ read_ref_at(ref, flags, at, -1, sha1, NULL,
NULL, NULL, &base);
}
}
@@ -760,7 +761,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
unsigned long timestamp;
int tz;
- if (read_ref_at(ref, 0, base+i, sha1, &logmsg,
+ if (read_ref_at(ref, flags, 0, base+i, sha1, &logmsg,
&timestamp, &tz, NULL)) {
reflog = i;
break;
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 99cde4587..855d94b90 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -164,10 +164,10 @@ static unsigned nr_objects;
* Called only from check_object() after it verified this object
* is Ok.
*/
-static void write_cached_object(struct object *obj)
+static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
{
unsigned char sha1[20];
- struct obj_buffer *obj_buf = lookup_object_buffer(obj);
+
if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0)
die("failed to write object %s", sha1_to_hex(obj->sha1));
obj->flags |= FLAG_WRITTEN;
@@ -180,6 +180,8 @@ static void write_cached_object(struct object *obj)
*/
static int check_object(struct object *obj, int type, void *data)
{
+ struct obj_buffer *obj_buf;
+
if (!obj)
return 1;
@@ -198,11 +200,15 @@ static int check_object(struct object *obj, int type, void *data)
return 0;
}
- if (fsck_object(obj, 1, fsck_error_function))
+ obj_buf = lookup_object_buffer(obj);
+ if (!obj_buf)
+ die("Whoops! Cannot find object '%s'", sha1_to_hex(obj->sha1));
+ if (fsck_object(obj, obj_buf->buffer, obj_buf->size, 1,
+ fsck_error_function))
die("Error in object");
if (fsck_walk(obj, check_object, NULL))
die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
- write_cached_object(obj);
+ write_cached_object(obj, obj_buf);
return 0;
}
diff --git a/cache.h b/cache.h
index af590d507..8206039cf 100644
--- a/cache.h
+++ b/cache.h
@@ -482,7 +482,7 @@ extern int daemonize(void);
alloc = (nr); \
else \
alloc = alloc_nr(alloc); \
- x = xrealloc((x), alloc * sizeof(*(x))); \
+ REALLOC_ARRAY(x, alloc); \
} \
} while (0)
@@ -1430,6 +1430,8 @@ extern const char *git_mailmap_blob;
/* IO helper functions */
extern void maybe_flush_or_die(FILE *, const char *);
+__attribute__((format (printf, 2, 3)))
+extern void fprintf_or_die(FILE *, const char *fmt, ...);
extern int copy_fd(int ifd, int ofd);
extern int copy_file(const char *dst, const char *src, int mode);
extern int copy_file_with_time(const char *dst, const char *src, int mode);
diff --git a/column.c b/column.c
index 76b615db5..8082a944f 100644
--- a/column.c
+++ b/column.c
@@ -81,8 +81,7 @@ static void compute_column_width(struct column_data *data)
*/
static void shrink_columns(struct column_data *data)
{
- data->width = xrealloc(data->width,
- sizeof(*data->width) * data->cols);
+ REALLOC_ARRAY(data->width, data->cols);
while (data->rows > 1) {
int x, total_width, cols, rows;
rows = data->rows;
@@ -91,8 +90,7 @@ static void shrink_columns(struct column_data *data)
data->rows--;
data->cols = DIV_ROUND_UP(data->list->nr, data->rows);
if (data->cols != cols)
- data->width = xrealloc(data->width,
- sizeof(*data->width) * data->cols);
+ REALLOC_ARRAY(data->width, data->cols);
compute_column_width(data);
total_width = strlen(data->opts.indent);
diff --git a/commit-slab.h b/commit-slab.h
index 375c9c751..f37ec3831 100644
--- a/commit-slab.h
+++ b/commit-slab.h
@@ -90,8 +90,7 @@ static MAYBE_UNUSED elemtype *slabname## _at(struct slabname *s, \
\
if (s->slab_count <= nth_slab) { \
int i; \
- s->slab = xrealloc(s->slab, \
- (nth_slab + 1) * sizeof(*s->slab)); \
+ REALLOC_ARRAY(s->slab, nth_slab + 1); \
stat_ ##slabname## realloc++; \
for (i = s->slab_count; i <= nth_slab; i++) \
s->slab[i] = NULL; \
diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 3b370ca5e..c2f00498f 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -2,6 +2,7 @@
#include "credential.h"
#include "unix-socket.h"
#include "sigchain.h"
+#include "parse-options.h"
static const char *socket_path;
@@ -201,7 +202,7 @@ static int serve_cache_loop(int fd)
return 1;
}
-static void serve_cache(const char *socket_path)
+static void serve_cache(const char *socket_path, int debug)
{
int fd;
@@ -211,6 +212,10 @@ static void serve_cache(const char *socket_path)
printf("ok\n");
fclose(stdout);
+ if (!debug) {
+ if (!freopen("/dev/null", "w", stderr))
+ die_errno("unable to point stderr to /dev/null");
+ }
while (serve_cache_loop(fd))
; /* nothing */
@@ -252,16 +257,28 @@ static void check_socket_directory(const char *path)
int main(int argc, const char **argv)
{
- socket_path = argv[1];
+ static const char *usage[] = {
+ "git-credential-cache--daemon [opts] <socket_path>",
+ NULL
+ };
+ int debug = 0;
+ const struct option options[] = {
+ OPT_BOOL(0, "debug", &debug,
+ N_("print debugging messages to stderr")),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, NULL, options, usage, 0);
+ socket_path = argv[0];
if (!socket_path)
- die("usage: git-credential-cache--daemon <socket_path>");
+ usage_with_options(usage, options);
check_socket_directory(socket_path);
atexit(cleanup_socket);
sigchain_push_common(cleanup_socket_on_signal);
- serve_cache(socket_path);
+ serve_cache(socket_path, debug);
return 0;
}
diff --git a/fast-import.c b/fast-import.c
index 487f1f81a..96b0f4236 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -878,7 +878,7 @@ static void start_packfile(void)
pack_size = sizeof(hdr);
object_count = 0;
- all_packs = xrealloc(all_packs, sizeof(*all_packs) * (pack_id + 1));
+ REALLOC_ARRAY(all_packs, pack_id + 1);
all_packs[pack_id] = p;
}
diff --git a/fsck.c b/fsck.c
index 56156fff4..2fffa434a 100644
--- a/fsck.c
+++ b/fsck.c
@@ -6,6 +6,7 @@
#include "commit.h"
#include "tag.h"
#include "fsck.h"
+#include "refs.h"
static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)
{
@@ -237,6 +238,26 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
return retval;
}
+static int require_end_of_header(const void *data, unsigned long size,
+ struct object *obj, fsck_error error_func)
+{
+ const char *buffer = (const char *)data;
+ unsigned long i;
+
+ for (i = 0; i < size; i++) {
+ switch (buffer[i]) {
+ case '\0':
+ return error_func(obj, FSCK_ERROR,
+ "unterminated header: NUL at offset %d", i);
+ case '\n':
+ if (i + 1 < size && buffer[i + 1] == '\n')
+ return 0;
+ }
+ }
+
+ return error_func(obj, FSCK_ERROR, "unterminated header");
+}
+
static int fsck_ident(const char **ident, struct object *obj, fsck_error error_func)
{
char *end;
@@ -277,13 +298,16 @@ static int fsck_ident(const char **ident, struct object *obj, fsck_error error_f
}
static int fsck_commit_buffer(struct commit *commit, const char *buffer,
- fsck_error error_func)
+ unsigned long size, fsck_error error_func)
{
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
unsigned parent_count, parent_line_count = 0;
int err;
+ if (require_end_of_header(buffer, size, &commit->object, error_func))
+ return -1;
+
if (!skip_prefix(buffer, "tree ", &buffer))
return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'tree' line");
if (get_sha1_hex(buffer, tree_sha1) || buffer[40] != '\n')
@@ -322,24 +346,111 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
return 0;
}
-static int fsck_commit(struct commit *commit, fsck_error error_func)
+static int fsck_commit(struct commit *commit, const char *data,
+ unsigned long size, fsck_error error_func)
{
- const char *buffer = get_commit_buffer(commit, NULL);
- int ret = fsck_commit_buffer(commit, buffer, error_func);
- unuse_commit_buffer(commit, buffer);
+ const char *buffer = data ? data : get_commit_buffer(commit, &size);
+ int ret = fsck_commit_buffer(commit, buffer, size, error_func);
+ if (!data)
+ unuse_commit_buffer(commit, buffer);
return ret;
}
-static int fsck_tag(struct tag *tag, fsck_error error_func)
+static int fsck_tag_buffer(struct tag *tag, const char *data,
+ unsigned long size, fsck_error error_func)
+{
+ unsigned char sha1[20];
+ int ret = 0;
+ const char *buffer;
+ char *to_free = NULL, *eol;
+ struct strbuf sb = STRBUF_INIT;
+
+ if (data)
+ buffer = data;
+ else {
+ enum object_type type;
+
+ buffer = to_free =
+ read_sha1_file(tag->object.sha1, &type, &size);
+ if (!buffer)
+ return error_func(&tag->object, FSCK_ERROR,
+ "cannot read tag object");
+
+ if (type != OBJ_TAG) {
+ ret = error_func(&tag->object, FSCK_ERROR,
+ "expected tag got %s",
+ typename(type));
+ goto done;
+ }
+ }
+
+ if (require_end_of_header(buffer, size, &tag->object, error_func))
+ goto done;
+
+ if (!skip_prefix(buffer, "object ", &buffer)) {
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid format - expected 'object' line");
+ goto done;
+ }
+ if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n') {
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid 'object' line format - bad sha1");
+ goto done;
+ }
+ buffer += 41;
+
+ if (!skip_prefix(buffer, "type ", &buffer)) {
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid format - expected 'type' line");
+ goto done;
+ }
+ eol = strchr(buffer, '\n');
+ if (!eol) {
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid format - unexpected end after 'type' line");
+ goto done;
+ }
+ if (type_from_string_gently(buffer, eol - buffer, 1) < 0)
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid 'type' value");
+ if (ret)
+ goto done;
+ buffer = eol + 1;
+
+ if (!skip_prefix(buffer, "tag ", &buffer)) {
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid format - expected 'tag' line");
+ goto done;
+ }
+ eol = strchr(buffer, '\n');
+ if (!eol) {
+ ret = error_func(&tag->object, FSCK_ERROR, "invalid format - unexpected end after 'type' line");
+ goto done;
+ }
+ strbuf_addf(&sb, "refs/tags/%.*s", (int)(eol - buffer), buffer);
+ if (check_refname_format(sb.buf, 0))
+ error_func(&tag->object, FSCK_WARN, "invalid 'tag' name: %s", buffer);
+ buffer = eol + 1;
+
+ if (!skip_prefix(buffer, "tagger ", &buffer))
+ /* early tags do not contain 'tagger' lines; warn only */
+ error_func(&tag->object, FSCK_WARN, "invalid format - expected 'tagger' line");
+ else
+ ret = fsck_ident(&buffer, &tag->object, error_func);
+
+done:
+ strbuf_release(&sb);
+ free(to_free);
+ return ret;
+}
+
+static int fsck_tag(struct tag *tag, const char *data,
+ unsigned long size, fsck_error error_func)
{
struct object *tagged = tag->tagged;
if (!tagged)
return error_func(&tag->object, FSCK_ERROR, "could not load tagged object");
- return 0;
+
+ return fsck_tag_buffer(tag, data, size, error_func);
}
-int fsck_object(struct object *obj, int strict, fsck_error error_func)
+int fsck_object(struct object *obj, void *data, unsigned long size,
+ int strict, fsck_error error_func)
{
if (!obj)
return error_func(obj, FSCK_ERROR, "no valid object to fsck");
@@ -349,9 +460,11 @@ int fsck_object(struct object *obj, int strict, fsck_error error_func)
if (obj->type == OBJ_TREE)
return fsck_tree((struct tree *) obj, strict, error_func);
if (obj->type == OBJ_COMMIT)
- return fsck_commit((struct commit *) obj, error_func);
+ return fsck_commit((struct commit *) obj, (const char *) data,
+ size, error_func);
if (obj->type == OBJ_TAG)
- return fsck_tag((struct tag *) obj, error_func);
+ return fsck_tag((struct tag *) obj, (const char *) data,
+ size, error_func);
return error_func(obj, FSCK_ERROR, "unknown type '%d' (internal fsck error)",
obj->type);
diff --git a/fsck.h b/fsck.h
index 1e4f52731..d1e6387a4 100644
--- a/fsck.h
+++ b/fsck.h
@@ -28,6 +28,8 @@ int fsck_error_function(struct object *obj, int type, const char *fmt, ...);
* 0 everything OK
*/
int fsck_walk(struct object *obj, fsck_walk_func walk, void *data);
-int fsck_object(struct object *obj, int strict, fsck_error error_func);
+/* If NULL is passed for data, we assume the object is local and read it. */
+int fsck_object(struct object *obj, void *data, unsigned long size,
+ int strict, fsck_error error_func);
#endif
diff --git a/git-compat-util.h b/git-compat-util.h
index 08a9ee297..0c4e66392 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -627,6 +627,8 @@ extern int odb_mkstemp(char *template, size_t limit, const char *pattern);
extern int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1);
extern char *xgetcwd(void);
+#define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), (alloc) * sizeof(*(x)))
+
static inline size_t xsize_t(off_t len)
{
if (len > (size_t) len)
diff --git a/git-stash.sh b/git-stash.sh
index 0158c7338..d4cf818be 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -50,7 +50,7 @@ clear_stash () {
then
die "$(gettext "git stash clear with parameters is unimplemented")"
fi
- if current=$(git rev-parse --verify $ref_stash 2>/dev/null)
+ if current=$(git rev-parse --verify --quiet $ref_stash)
then
git update-ref -d $ref_stash $current
fi
@@ -292,7 +292,7 @@ save_stash () {
}
have_stash () {
- git rev-parse --verify $ref_stash >/dev/null 2>&1
+ git rev-parse --verify --quiet $ref_stash >/dev/null
}
list_stash () {
@@ -392,12 +392,12 @@ parse_flags_and_rev()
;;
esac
- REV=$(git rev-parse --quiet --symbolic --verify "$1" 2>/dev/null) || {
+ REV=$(git rev-parse --symbolic --verify --quiet "$1") || {
reference="$1"
die "$(eval_gettext "\$reference is not a valid reference")"
}
- i_commit=$(git rev-parse --quiet --verify "$REV^2" 2>/dev/null) &&
+ i_commit=$(git rev-parse --verify --quiet "$REV^2") &&
set -- $(git rev-parse "$REV" "$REV^1" "$REV:" "$REV^1:" "$REV^2:" 2>/dev/null) &&
s=$1 &&
w_commit=$1 &&
@@ -409,7 +409,7 @@ parse_flags_and_rev()
test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${REV%@*}")" &&
IS_STASH_REF=t
- u_commit=$(git rev-parse --quiet --verify "$REV^3" 2>/dev/null) &&
+ u_commit=$(git rev-parse --verify --quiet "$REV^3") &&
u_tree=$(git rev-parse "$REV^3:" 2>/dev/null)
}
@@ -531,7 +531,8 @@ drop_stash () {
die "$(eval_gettext "\${REV}: Could not drop stash entry")"
# clear_stash if we just dropped the last stash entry
- git rev-parse --verify "$ref_stash@{0}" >/dev/null 2>&1 || clear_stash
+ git rev-parse --verify --quiet "$ref_stash@{0}" >/dev/null ||
+ clear_stash
}
apply_to_branch () {
diff --git a/git.c b/git.c
index 523768da6..4076b014a 100644
--- a/git.c
+++ b/git.c
@@ -282,8 +282,7 @@ static int handle_alias(int *argcp, const char ***argv)
"trace: alias expansion: %s =>",
alias_command);
- new_argv = xrealloc(new_argv, sizeof(char *) *
- (count + *argcp));
+ REALLOC_ARRAY(new_argv, count + *argcp);
/* insert after command name */
memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);
diff --git a/graph.c b/graph.c
index dfb99f643..c25a09a8f 100644
--- a/graph.c
+++ b/graph.c
@@ -267,16 +267,10 @@ static void graph_ensure_capacity(struct git_graph *graph, int num_columns)
graph->column_capacity *= 2;
} while (graph->column_capacity < num_columns);
- graph->columns = xrealloc(graph->columns,
- sizeof(struct column) *
- graph->column_capacity);
- graph->new_columns = xrealloc(graph->new_columns,
- sizeof(struct column) *
- graph->column_capacity);
- graph->mapping = xrealloc(graph->mapping,
- sizeof(int) * 2 * graph->column_capacity);
- graph->new_mapping = xrealloc(graph->new_mapping,
- sizeof(int) * 2 * graph->column_capacity);
+ REALLOC_ARRAY(graph->columns, graph->column_capacity);
+ REALLOC_ARRAY(graph->new_columns, graph->column_capacity);
+ REALLOC_ARRAY(graph->mapping, graph->column_capacity * 2);
+ REALLOC_ARRAY(graph->new_mapping, graph->column_capacity * 2);
}
/*
@@ -1161,20 +1155,11 @@ static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
*/
for (i = 0; i < graph->num_columns; i++) {
struct column *col = &graph->columns[i];
- struct commit *col_commit = col->commit;
- if (col_commit == graph->commit) {
- strbuf_write_column(sb, col, '|');
-
- if (graph->num_parents < 3)
- strbuf_addch(sb, ' ');
- else {
- int num_spaces = ((graph->num_parents - 2) * 2);
- strbuf_addchars(sb, ' ', num_spaces);
- }
- } else {
- strbuf_write_column(sb, col, '|');
+ strbuf_write_column(sb, col, '|');
+ if (col->commit == graph->commit && graph->num_parents > 2)
+ strbuf_addchars(sb, ' ', (graph->num_parents - 2) * 2);
+ else
strbuf_addch(sb, ' ');
- }
}
graph_pad_horizontally(graph, sb, graph->num_columns);
diff --git a/help.c b/help.c
index 7af65e205..2072a873e 100644
--- a/help.c
+++ b/help.c
@@ -305,7 +305,7 @@ const char *help_unknown_cmd(const char *cmd)
add_cmd_list(&main_cmds, &aliases);
add_cmd_list(&main_cmds, &other_cmds);
qsort(main_cmds.names, main_cmds.cnt,
- sizeof(main_cmds.names), cmdname_compare);
+ sizeof(*main_cmds.names), cmdname_compare);
uniq(&main_cmds);
/* This abuses cmdname->len for levenshtein distance */
diff --git a/khash.h b/khash.h
index 06c790654..376475a5e 100644
--- a/khash.h
+++ b/khash.h
@@ -121,13 +121,9 @@ static const double __ac_HASH_UPPER = 0.77;
if (!new_flags) return -1; \
memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
if (h->n_buckets < new_n_buckets) { /* expand */ \
- khkey_t *new_keys = (khkey_t*)xrealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
- if (!new_keys) return -1; \
- h->keys = new_keys; \
+ REALLOC_ARRAY(h->keys, new_n_buckets); \
if (kh_is_map) { \
- khval_t *new_vals = (khval_t*)xrealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
- if (!new_vals) return -1; \
- h->vals = new_vals; \
+ REALLOC_ARRAY(h->vals, new_n_buckets); \
} \
} /* otherwise shrink */ \
} \
@@ -160,8 +156,8 @@ static const double __ac_HASH_UPPER = 0.77;
} \
} \
if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
- h->keys = (khkey_t*)xrealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
- if (kh_is_map) h->vals = (khval_t*)xrealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
+ REALLOC_ARRAY(h->keys, new_n_buckets); \
+ if (kh_is_map) REALLOC_ARRAY(h->vals, new_n_buckets); \
} \
free(h->flags); /* free the working space */ \
h->flags = new_flags; \
diff --git a/line-log.c b/line-log.c
index 1008e7225..038c58a39 100644
--- a/line-log.c
+++ b/line-log.c
@@ -533,7 +533,7 @@ static void fill_line_ends(struct diff_filespec *spec, long *lines,
}
/* shrink the array to fit the elements */
- ends = xrealloc(ends, cur * sizeof(*ends));
+ REALLOC_ARRAY(ends, cur);
*lines = cur-1;
*line_ends = ends;
}
diff --git a/log-tree.c b/log-tree.c
index bcee7c596..cff7ac1db 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -174,14 +174,16 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre
}
/*
- * The caller makes sure there is no funny color before
- * calling. format_decorations makes sure the same after return.
+ * The caller makes sure there is no funny color before calling.
+ * format_decorations_extended makes sure the same after return.
*/
-void format_decorations(struct strbuf *sb,
+void format_decorations_extended(struct strbuf *sb,
const struct commit *commit,
- int use_color)
+ int use_color,
+ const char *prefix,
+ const char *separator,
+ const char *suffix)
{
- const char *prefix;
const struct name_decoration *decoration;
const char *color_commit =
diff_get_color(use_color, DIFF_COMMIT);
@@ -191,7 +193,6 @@ void format_decorations(struct strbuf *sb,
decoration = get_name_decoration(&commit->object);
if (!decoration)
return;
- prefix = " (";
while (decoration) {
strbuf_addstr(sb, color_commit);
strbuf_addstr(sb, prefix);
@@ -200,11 +201,11 @@ void format_decorations(struct strbuf *sb,
strbuf_addstr(sb, "tag: ");
strbuf_addstr(sb, decoration->name);
strbuf_addstr(sb, color_reset);
- prefix = ", ";
+ prefix = separator;
decoration = decoration->next;
}
strbuf_addstr(sb, color_commit);
- strbuf_addch(sb, ')');
+ strbuf_addstr(sb, suffix);
strbuf_addstr(sb, color_reset);
}
diff --git a/log-tree.h b/log-tree.h
index d6ecd4dc4..b26160c4d 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -13,7 +13,13 @@ int log_tree_diff_flush(struct rev_info *);
int log_tree_commit(struct rev_info *, struct commit *);
int log_tree_opt_parse(struct rev_info *, const char **, int);
void show_log(struct rev_info *opt);
-void format_decorations(struct strbuf *sb, const struct commit *commit, int use_color);
+void format_decorations_extended(struct strbuf *sb, const struct commit *commit,
+ int use_color,
+ const char *prefix,
+ const char *separator,
+ const char *suffix);
+#define format_decorations(strbuf, commit, color) \
+ format_decorations_extended((strbuf), (commit), (color), " (", ", ", ")")
void show_decorations(struct rev_info *opt, struct commit *commit);
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **subject_p,
diff --git a/object.c b/object.c
index a16b9f9e9..ca9d790f4 100644
--- a/object.c
+++ b/object.c
@@ -33,13 +33,20 @@ const char *typename(unsigned int type)
return object_type_strings[type];
}
-int type_from_string(const char *str)
+int type_from_string_gently(const char *str, ssize_t len, int gentle)
{
int i;
+ if (len < 0)
+ len = strlen(str);
+
for (i = 1; i < ARRAY_SIZE(object_type_strings); i++)
- if (!strcmp(str, object_type_strings[i]))
+ if (!strncmp(str, object_type_strings[i], len))
return i;
+
+ if (gentle)
+ return -1;
+
die("invalid object type \"%s\"", str);
}
@@ -312,7 +319,7 @@ static void add_object_array_with_mode_context(struct object *obj, const char *n
if (nr >= alloc) {
alloc = (alloc + 32) * 2;
- objects = xrealloc(objects, alloc * sizeof(*objects));
+ REALLOC_ARRAY(objects, alloc);
array->alloc = alloc;
array->objects = objects;
}
diff --git a/object.h b/object.h
index 5e8d8ee54..e028ced74 100644
--- a/object.h
+++ b/object.h
@@ -53,7 +53,8 @@ struct object {
};
extern const char *typename(unsigned int type);
-extern int type_from_string(const char *str);
+extern int type_from_string_gently(const char *str, ssize_t, int gentle);
+#define type_from_string(str) type_from_string_gently(str, -1, 0)
/*
* Return the current number of buckets in the object hashmap.
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 5f1791a59..8029ae356 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -111,8 +111,7 @@ static inline void push_bitmapped_commit(struct commit *commit, struct ewah_bitm
{
if (writer.selected_nr >= writer.selected_alloc) {
writer.selected_alloc = (writer.selected_alloc + 32) * 2;
- writer.selected = xrealloc(writer.selected,
- writer.selected_alloc * sizeof(struct bitmapped_commit));
+ REALLOC_ARRAY(writer.selected, writer.selected_alloc);
}
writer.selected[writer.selected_nr].commit = commit;
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 91e410153..a1f3c0d34 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -400,10 +400,8 @@ static int ext_index_add_object(struct object *object, const char *name)
if (hash_ret > 0) {
if (eindex->count >= eindex->alloc) {
eindex->alloc = (eindex->alloc + 16) * 3 / 2;
- eindex->objects = xrealloc(eindex->objects,
- eindex->alloc * sizeof(struct object *));
- eindex->hashes = xrealloc(eindex->hashes,
- eindex->alloc * sizeof(uint32_t));
+ REALLOC_ARRAY(eindex->objects, eindex->alloc);
+ REALLOC_ARRAY(eindex->hashes, eindex->alloc);
}
bitmap_pos = eindex->count;
diff --git a/pack-objects.c b/pack-objects.c
index 9992f3ecf..6398a8aa9 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -92,8 +92,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
if (pdata->nr_objects >= pdata->nr_alloc) {
pdata->nr_alloc = (pdata->nr_alloc + 1024) * 3 / 2;
- pdata->objects = xrealloc(pdata->objects,
- pdata->nr_alloc * sizeof(*new_entry));
+ REALLOC_ARRAY(pdata->objects, pdata->nr_alloc);
}
new_entry = pdata->objects + pdata->nr_objects++;
diff --git a/po/TEAMS b/po/TEAMS
index 461cc1435..a33a38e7d 100644
--- a/po/TEAMS
+++ b/po/TEAMS
@@ -17,6 +17,7 @@ Members: Thomas Rast <tr@thomasrast.ch>
Christian Stimming <stimming@tuhh.de>
Phillip Szelat <phillip.szelat@gmail.com>
Matthias Rüster <matthias.ruester@gmail.com>
+ Magnus Görlitz <magnus.goerlitz@googlemail.com>
Language: fr (French)
Repository: https://github.com/jnavila/git
diff --git a/po/de.po b/po/de.po
index e5d2b25f4..c807967cf 100644
--- a/po/de.po
+++ b/po/de.po
@@ -29,7 +29,7 @@ msgid ""
"'git commit -a'."
msgstr ""
"Korrigieren Sie dies im Arbeitsverzeichnis, und benutzen Sie\n"
-"dann 'git add/rm <Datei>' um die Auflösung entsprechend zu markieren\n"
+"dann 'git add/rm <Datei>', um die Auflösung entsprechend zu markieren\n"
"und zu committen, oder benutzen Sie 'git commit -a'."
#: archive.c:10
@@ -619,7 +619,7 @@ msgstr "Fehler beim Erstellen des Pfades '%s'%s"
#: merge-recursive.c:703
#, c-format
msgid "Removing %s to make room for subdirectory\n"
-msgstr "Entferne %s um Platz für Unterverzeichnis zu schaffen\n"
+msgstr "Entferne %s, um Platz für Unterverzeichnis zu schaffen\n"
#: merge-recursive.c:717 merge-recursive.c:738
msgid ": perhaps a D/F conflict?"
@@ -1037,7 +1037,7 @@ msgstr[1] "Ihr Branch ist vor '%s' um %d Commits.\n"
#: remote.c:1960
msgid " (use \"git push\" to publish your local commits)\n"
-msgstr " (benutzen Sie \"git push\" um lokale Commits zu publizieren)\n"
+msgstr " (benutzen Sie \"git push\", um lokale Commits zu publizieren)\n"
#: remote.c:1963
#, c-format
@@ -1052,7 +1052,7 @@ msgstr[1] ""
#: remote.c:1971
msgid " (use \"git pull\" to update your local branch)\n"
msgstr ""
-" (benutzen Sie \"git pull\" um Ihren lokalen Branch zu aktualisieren)\n"
+" (benutzen Sie \"git pull\", um Ihren lokalen Branch zu aktualisieren)\n"
#: remote.c:1974
#, c-format
@@ -1072,7 +1072,7 @@ msgstr[1] ""
#: remote.c:1984
msgid " (use \"git pull\" to merge the remote branch into yours)\n"
msgstr ""
-" (benutzen Sie \"git pull\" um Ihren Branch mit dem Remote-Branch "
+" (benutzen Sie \"git pull\", um Ihren Branch mit dem Remote-Branch "
"zusammenzuführen)\n"
#: run-command.c:80
@@ -1136,7 +1136,7 @@ msgstr "Ihre lokalen Änderungen würden von \"revert\" überschrieben werden."
#: sequencer.c:233
msgid "Commit your changes or stash them to proceed."
msgstr ""
-"Tragen Sie Ihre Änderungen ein oder benutzen Sie \"stash\" um fortzufahren."
+"Tragen Sie Ihre Änderungen ein oder benutzen Sie \"stash\", um fortzufahren."
#: sequencer.c:250
msgid "Failed to lock HEAD during fast_forward_to"
@@ -1488,18 +1488,18 @@ msgstr ""
#: wt-status.c:183
msgid " (use \"git add <file>...\" to mark resolution)"
msgstr ""
-" (benutzen Sie \"git add/rm <Datei>...\" um die Auflösung zu markieren)"
+" (benutzen Sie \"git add/rm <Datei>...\", um die Auflösung zu markieren)"
#: wt-status.c:185 wt-status.c:189
msgid " (use \"git add/rm <file>...\" as appropriate to mark resolution)"
msgstr ""
-" (benutzen Sie \"git add/rm <Datei>...\" um die Auflösung entsprechend zu "
+" (benutzen Sie \"git add/rm <Datei>...\", um die Auflösung entsprechend zu "
"markieren)"
#: wt-status.c:187
msgid " (use \"git rm <file>...\" to mark resolution)"
msgstr ""
-" (benutzen Sie \"git add/rm <Datei>...\" um die Auflösung zu markieren)"
+" (benutzen Sie \"git add/rm <Datei>...\", um die Auflösung zu markieren)"
#: wt-status.c:198
msgid "Changes to be committed:"
@@ -1512,20 +1512,20 @@ msgstr "Änderungen, die nicht zum Commit vorgemerkt sind:"
#: wt-status.c:220
msgid " (use \"git add <file>...\" to update what will be committed)"
msgstr ""
-" (benutzen Sie \"git add <Datei>...\" um die Änderungen zum Commit "
+" (benutzen Sie \"git add <Datei>...\", um die Änderungen zum Commit "
"vorzumerken)"
#: wt-status.c:222
msgid " (use \"git add/rm <file>...\" to update what will be committed)"
msgstr ""
-" (benutzen Sie \"git add/rm <Datei>...\" um die Änderungen zum Commit "
+" (benutzen Sie \"git add/rm <Datei>...\", um die Änderungen zum Commit "
"vorzumerken)"
#: wt-status.c:223
msgid ""
" (use \"git checkout -- <file>...\" to discard changes in working directory)"
msgstr ""
-" (benutzen Sie \"git checkout -- <Datei>...\" um die Änderungen im "
+" (benutzen Sie \"git checkout -- <Datei>...\", um die Änderungen im "
"Arbeitsverzeichnis zu verwerfen)"
#: wt-status.c:225
@@ -1538,7 +1538,7 @@ msgstr ""
#, c-format
msgid " (use \"git %s <file>...\" to include in what will be committed)"
msgstr ""
-" (benutzen Sie \"git %s <Datei>...\" um die Änderungen zum Commit "
+" (benutzen Sie \"git %s <Datei>...\", um die Änderungen zum Commit "
"vorzumerken)"
#: wt-status.c:252
@@ -1653,7 +1653,7 @@ msgstr "Alle Konflikte sind behoben, aber Sie sind immer noch beim Merge."
#: wt-status.c:945
msgid " (use \"git commit\" to conclude merge)"
-msgstr " (benutzen Sie \"git commit\" um den Merge abzuschließen)"
+msgstr " (benutzen Sie \"git commit\", um den Merge abzuschließen)"
#: wt-status.c:955
msgid "You are in the middle of an am session."
@@ -1670,12 +1670,12 @@ msgstr ""
#: wt-status.c:964
msgid " (use \"git am --skip\" to skip this patch)"
-msgstr " (benutzen Sie \"git am --skip\" um diesen Patch auszulassen)"
+msgstr " (benutzen Sie \"git am --skip\", um diesen Patch auszulassen)"
#: wt-status.c:966
msgid " (use \"git am --abort\" to restore the original branch)"
msgstr ""
-" (benutzen Sie \"git am --abort\" um den ursprünglichen Branch "
+" (benutzen Sie \"git am --abort\", um den ursprünglichen Branch "
"wiederherzustellen)"
#: wt-status.c:1026 wt-status.c:1043
@@ -1695,12 +1695,12 @@ msgstr ""
#: wt-status.c:1036
msgid " (use \"git rebase --skip\" to skip this patch)"
-msgstr " (benutzen Sie \"git rebase --skip\" um diesen Patch auszulassen)"
+msgstr " (benutzen Sie \"git rebase --skip\", um diesen Patch auszulassen)"
#: wt-status.c:1038
msgid " (use \"git rebase --abort\" to check out the original branch)"
msgstr ""
-" (benutzen Sie \"git rebase --abort\" um den ursprünglichen Branch "
+" (benutzen Sie \"git rebase --abort\", um den ursprünglichen Branch "
"auszuchecken)"
#: wt-status.c:1051
@@ -1739,7 +1739,7 @@ msgstr "Sie editieren gerade einen Commit während eines Rebase."
#: wt-status.c:1075
msgid " (use \"git commit --amend\" to amend the current commit)"
msgstr ""
-" (benutzen Sie \"git commit --amend\" um den aktuellen Commit nachzubessern)"
+" (benutzen Sie \"git commit --amend\", um den aktuellen Commit nachzubessern)"
#: wt-status.c:1077
msgid ""
@@ -1767,7 +1767,7 @@ msgstr ""
#: wt-status.c:1097
msgid " (use \"git cherry-pick --abort\" to cancel the cherry-pick operation)"
msgstr ""
-" (benutzen Sie \"git cherry-pick --abort\" um die Cherry-Pick-Operation "
+" (benutzen Sie \"git cherry-pick --abort\", um die Cherry-Pick-Operation "
"abzubrechen)"
#: wt-status.c:1106
@@ -1788,7 +1788,7 @@ msgstr " (alle Konflikte behoben: führen Sie \"git revert --continue\" aus)"
#: wt-status.c:1116
msgid " (use \"git revert --abort\" to cancel the revert operation)"
msgstr ""
-" (benutzen Sie \"git revert --abort\" um die Revert-Operation abzubrechen)"
+" (benutzen Sie \"git revert --abort\", um die Revert-Operation abzubrechen)"
#: wt-status.c:1127
#, c-format
@@ -1802,7 +1802,7 @@ msgstr "Sie sind gerade bei einer binären Suche."
#: wt-status.c:1134
msgid " (use \"git bisect reset\" to get back to the original branch)"
msgstr ""
-" (benutzen Sie \"git bisect reset\" um zum ursprünglichen Branch "
+" (benutzen Sie \"git bisect reset\", um zum ursprünglichen Branch "
"zurückzukehren)"
#: wt-status.c:1309
@@ -1855,7 +1855,7 @@ msgstr "Unbeobachtete Dateien nicht aufgelistet%s"
#: wt-status.c:1373
msgid " (use -u option to show untracked files)"
-msgstr " (benutzen Sie die Option -u um unbeobachteten Dateien anzuzeigen)"
+msgstr " (benutzen Sie die Option -u, um unbeobachteten Dateien anzuzeigen)"
#: wt-status.c:1379
msgid "No changes"
@@ -2235,7 +2235,7 @@ msgstr[1] ""
#: builtin/apply.c:2818
#, c-format
msgid "Context reduced to (%ld/%ld) to apply fragment at %d"
-msgstr "Kontext reduziert zu (%ld/%ld) um Patch-Bereich bei %d anzuwenden"
+msgstr "Kontext reduziert zu (%ld/%ld), um Patch-Bereich bei %d anzuwenden"
#: builtin/apply.c:2824
#, c-format
@@ -2691,7 +2691,7 @@ msgstr "Unterdrückt den Namen des Autors und den Zeitstempel (Standard: aus)"
#: builtin/blame.c:2514
msgid "Show author email instead of name (Default: off)"
-msgstr "Zeigt anstatt des Namens die Email-Adresse des Autors (Standard: aus)"
+msgstr "Zeigt anstatt des Namens die E-Mail-Adresse des Autors (Standard: aus)"
#: builtin/blame.c:2515
msgid "Ignore whitespace differences"
@@ -3085,7 +3085,7 @@ msgstr "zu viele Branches für eine Umbenennen-Operation angegeben"
#: builtin/branch.c:952
msgid "too many branches to set new upstream"
-msgstr "zu viele Branches angegeben um Upstream-Branch zu setzen"
+msgstr "zu viele Branches angegeben, um Upstream-Branch zu setzen"
#: builtin/branch.c:956
#, c-format
@@ -3108,7 +3108,7 @@ msgstr "Branch '%s' existiert nicht"
#: builtin/branch.c:975
msgid "too many branches to unset upstream"
msgstr ""
-"zu viele Branches angegeben um Konfiguration zu Upstream-Branch zu entfernen"
+"zu viele Branches angegeben, um Konfiguration zu Upstream-Branch zu entfernen"
#: builtin/branch.c:979
msgid "could not unset upstream of HEAD when it does not point to any branch."
@@ -5071,7 +5071,7 @@ msgstr "gibt für jeden Commit das gesamte Verzeichnis aus"
#: builtin/fast-export.c:718
msgid "Use the done feature to terminate the stream"
-msgstr "Benutzt die \"done\"-Funktion um den Strom abzuschließen"
+msgstr "Benutzt die \"done\"-Funktion, um den Strom abzuschließen"
#: builtin/fast-export.c:719
msgid "Skip output of blob data"
@@ -5268,7 +5268,7 @@ msgid ""
" 'git remote prune %s' to remove any old, conflicting branches"
msgstr ""
"Einige lokale Referenzen konnten nicht aktualisiert werden; versuchen Sie\n"
-"'git remote prune %s' um jeden älteren, widersprüchlichen Branch zu löschen."
+"'git remote prune %s', um jeden älteren, widersprüchlichen Branch zu löschen."
#: builtin/fetch.c:759
#, c-format
@@ -6535,7 +6535,7 @@ msgstr "zeigt Patchformat anstatt des Standards (Patch + Zusammenfassung)"
#: builtin/log.c:1217
msgid "Messaging"
-msgstr "Email-Einstellungen"
+msgstr "E-Mail-Einstellungen"
#: builtin/log.c:1218
msgid "header"
@@ -6543,11 +6543,11 @@ msgstr "Header"
#: builtin/log.c:1219
msgid "add email header"
-msgstr "fügt Email-Header hinzu"
+msgstr "fügt E-Mail-Header hinzu"
#: builtin/log.c:1220 builtin/log.c:1222
msgid "email"
-msgstr "Email"
+msgstr "E-Mail"
#: builtin/log.c:1220
msgid "add To: header"
@@ -6573,7 +6573,7 @@ msgstr "message-id"
#: builtin/log.c:1228
msgid "make first mail a reply to <message-id>"
-msgstr "macht aus erster Email eine Antwort zu <message-id>"
+msgstr "macht aus erster E-Mail eine Antwort zu <message-id>"
#: builtin/log.c:1229 builtin/log.c:1232
msgid "boundary"
@@ -6978,7 +6978,7 @@ msgstr "konnte nicht von '%s' lesen"
#, c-format
msgid "Not committing merge; use 'git commit' to complete the merge.\n"
msgstr ""
-"Merge wurde nicht committet; benutzen Sie 'git commit' um den Merge "
+"Merge wurde nicht committet; benutzen Sie 'git commit', um den Merge "
"abzuschließen.\n"
#: builtin/merge.c:809
@@ -6990,7 +6990,7 @@ msgid ""
"Lines starting with '%c' will be ignored, and an empty message aborts\n"
"the commit.\n"
msgstr ""
-"Bitte geben Sie eine Commit-Beschreibung ein um zu erklären, warum dieser\n"
+"Bitte geben Sie eine Commit-Beschreibung ein, um zu erklären, warum dieser\n"
"Merge erforderlich ist, insbesondere wenn es einen aktualisierten\n"
"Upstream-Branch mit einem Thema-Branch zusammenführt.\n"
"\n"
@@ -7156,7 +7156,7 @@ msgstr "Merge mit Strategie %s fehlgeschlagen.\n"
#: builtin/merge.c:1539
#, c-format
msgid "Using the %s to prepare resolving by hand.\n"
-msgstr "Benutzen Sie \"%s\" um die Auflösung per Hand vorzubereiten.\n"
+msgstr "Benutzen Sie \"%s\", um die Auflösung per Hand vorzubereiten.\n"
#: builtin/merge.c:1551
#, c-format
@@ -7299,7 +7299,7 @@ msgid "Please, stage your changes to .gitmodules or stash them to proceed"
msgstr ""
"Bitte merken Sie Ihre Änderungen in .gitmodules zum Commit vor oder "
"benutzen\n"
-"Sie \"stash\" um fortzufahren."
+"Sie \"stash\", um fortzufahren."
#: builtin/mv.c:156
#, c-format
@@ -7368,7 +7368,7 @@ msgstr "zeigt nur Namen an (keine SHA-1)"
#: builtin/name-rev.c:310
msgid "only use tags to name the commits"
-msgstr "verwendet nur Tags um die Commits zu benennen"
+msgstr "verwendet nur Tags, um die Commits zu benennen"
#: builtin/name-rev.c:312
msgid "only use refs matching <pattern>"
@@ -7621,7 +7621,7 @@ msgid ""
"existing notes"
msgstr ""
"Konnte Notizen nicht hinzufügen. Existierende Notizen für Objekt %s "
-"gefunden. Verwenden Sie '-f' um die existierenden Notizen zu überschreiben."
+"gefunden. Verwenden Sie '-f', um die existierenden Notizen zu überschreiben."
#: builtin/notes.c:460 builtin/notes.c:537
#, c-format
@@ -7649,7 +7649,7 @@ msgid ""
"existing notes"
msgstr ""
"Kann Notizen nicht kopieren. Existierende Notizen für Objekt %s gefunden. "
-"Verwenden Sie '-f' um die existierenden Notizen zu überschreiben."
+"Verwenden Sie '-f', um die existierenden Notizen zu überschreiben."
#: builtin/notes.c:543
#, c-format
@@ -9359,7 +9359,7 @@ msgid ""
"(use -f to force removal)"
msgstr ""
"\n"
-"(benutzen Sie -f um die Löschung zu erzwingen)"
+"(benutzen Sie -f, um die Löschung zu erzwingen)"
#: builtin/rm.c:240
msgid "the following file has changes staged in the index:"
@@ -9373,7 +9373,7 @@ msgid ""
"(use --cached to keep the file, or -f to force removal)"
msgstr ""
"\n"
-"(benutzen Sie --cached um die Datei zu behalten, oder -f um die Entfernung "
+"(benutzen Sie --cached, um die Datei zu behalten, oder -f, um die Entfernung "
"zu erzwingen)"
#: builtin/rm.c:252
@@ -9431,7 +9431,7 @@ msgstr "Unterdrückt Commit-Beschreibungen, liefert nur Anzahl der Commits"
#: builtin/shortlog.c:234
msgid "Show the email address of each author"
-msgstr "Zeigt die Email-Adresse von jedem Autor"
+msgstr "Zeigt die E-Mail-Adresse von jedem Autor"
#: builtin/shortlog.c:235
msgid "w[,i1[,i2]]"
@@ -9751,7 +9751,7 @@ msgstr "annotiertes und GPG-signiertes Tag"
#: builtin/tag.c:605
msgid "use another key to sign the tag"
-msgstr "verwendet einen anderen Schlüssel um das Tag zu signieren"
+msgstr "verwendet einen anderen Schlüssel, um das Tag zu signieren"
#: builtin/tag.c:606
msgid "replace the tag if exists"
@@ -10046,7 +10046,7 @@ msgid ""
msgstr ""
"'git help -a' und 'git help -g' listet verfügbare Unterkommandos und\n"
"einige Anleitungen zu Git-Konzepten auf. Benutzen Sie 'git help <Kommando>'\n"
-"oder 'git help <Konzept>' um mehr über ein spezifisches Kommando oder\n"
+"oder 'git help <Konzept>', um mehr über ein spezifisches Kommando oder\n"
"Konzept zu erfahren."
#: parse-options.h:143
@@ -10200,7 +10200,7 @@ msgstr ""
#: git-am.sh:141
msgid "Using index info to reconstruct a base tree..."
msgstr ""
-"Verwende Informationen aus der Staging-Area um einen Basisverzeichnis "
+"Verwende Informationen aus der Staging-Area, um einen Basisverzeichnis "
"nachzustellen"
#: git-am.sh:156
@@ -10257,7 +10257,7 @@ msgid ""
"Use \"git am --abort\" to remove it."
msgstr ""
"Stray $dotest Verzeichnis gefunden.\n"
-"Benutzen Sie \"git am --abort\" um es zu entfernen."
+"Benutzen Sie \"git am --abort\", um es zu entfernen."
#: git-am.sh:535
msgid "Resolve operation not in progress, we are not resuming."
@@ -10284,7 +10284,7 @@ msgstr ""
#: git-am.sh:732
msgid "Patch does not have a valid e-mail address."
-msgstr "Patch enthält keine gültige Email-Adresse."
+msgstr "Patch enthält keine gültige E-Mail-Adresse."
#: git-am.sh:779
msgid "cannot be interactive without stdin connected to a terminal."
@@ -10515,7 +10515,7 @@ msgid ""
msgstr ""
"\"pull\" ist nicht möglich, weil Sie nicht zusammengeführte Dateien haben.\n"
"Bitte korrigieren Sie dies im Arbeitsverzeichnis und benutzen Sie dann \n"
-"'git add/rm <Datei>' um die Auflösung entsprechend zu markieren, oder\n"
+"'git add/rm <Datei>', um die Auflösung entsprechend zu markieren, oder\n"
"benutzen Sie 'git commit -a'."
#: git-pull.sh:25
@@ -11014,7 +11014,7 @@ msgid ""
"discard them"
msgstr ""
"Arbeitsverzeichnis von Submodul in '$displaypath' enthält lokale Änderungen; "
-"verwenden Sie '-f' um diese zu verwerfen"
+"verwenden Sie '-f', um diese zu verwerfen"
#: git-submodule.sh:701
#, sh-format
diff --git a/pretty.c b/pretty.c
index 31f2edef1..5fd9de6ce 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1179,6 +1179,10 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
load_ref_decorations(DECORATE_SHORT_REFS);
format_decorations(sb, commit, c->auto_color);
return 1;
+ case 'D':
+ load_ref_decorations(DECORATE_SHORT_REFS);
+ format_decorations_extended(sb, commit, c->auto_color, "", ", ", "");
+ return 1;
case 'g': /* reflog info */
switch(placeholder[1]) {
case 'd': /* reflog selector */
diff --git a/refs.c b/refs.c
index 2ce5d6909..ffd45e929 100644
--- a/refs.c
+++ b/refs.c
@@ -784,37 +784,32 @@ static void prime_ref_dir(struct ref_dir *dir)
prime_ref_dir(get_ref_dir(entry));
}
}
-/*
- * Return true iff refname1 and refname2 conflict with each other.
- * Two reference names conflict if one of them exactly matches the
- * leading components of the other; e.g., "foo/bar" conflicts with
- * both "foo" and with "foo/bar/baz" but not with "foo/bar" or
- * "foo/barbados".
- */
-static int names_conflict(const char *refname1, const char *refname2)
+
+static int entry_matches(struct ref_entry *entry, const char *refname)
{
- for (; *refname1 && *refname1 == *refname2; refname1++, refname2++)
- ;
- return (*refname1 == '\0' && *refname2 == '/')
- || (*refname1 == '/' && *refname2 == '\0');
+ return refname && !strcmp(entry->name, refname);
}
-struct name_conflict_cb {
- const char *refname;
- const char *oldrefname;
- const char *conflicting_refname;
+struct nonmatching_ref_data {
+ const char *skip;
+ struct ref_entry *found;
};
-static int name_conflict_fn(struct ref_entry *entry, void *cb_data)
+static int nonmatching_ref_fn(struct ref_entry *entry, void *vdata)
{
- struct name_conflict_cb *data = (struct name_conflict_cb *)cb_data;
- if (data->oldrefname && !strcmp(data->oldrefname, entry->name))
+ struct nonmatching_ref_data *data = vdata;
+
+ if (entry_matches(entry, data->skip))
return 0;
- if (names_conflict(data->refname, entry->name)) {
- data->conflicting_refname = entry->name;
- return 1;
- }
- return 0;
+
+ data->found = entry;
+ return 1;
+}
+
+static void report_refname_conflict(struct ref_entry *entry,
+ const char *refname)
+{
+ error("'%s' exists; cannot create '%s'", entry->name, refname);
}
/*
@@ -823,21 +818,84 @@ static int name_conflict_fn(struct ref_entry *entry, void *cb_data)
* oldrefname is non-NULL, ignore potential conflicts with oldrefname
* (e.g., because oldrefname is scheduled for deletion in the same
* operation).
+ *
+ * Two reference names conflict if one of them exactly matches the
+ * leading components of the other; e.g., "foo/bar" conflicts with
+ * both "foo" and with "foo/bar/baz" but not with "foo/bar" or
+ * "foo/barbados".
*/
static int is_refname_available(const char *refname, const char *oldrefname,
struct ref_dir *dir)
{
- struct name_conflict_cb data;
- data.refname = refname;
- data.oldrefname = oldrefname;
- data.conflicting_refname = NULL;
+ const char *slash;
+ size_t len;
+ int pos;
+ char *dirname;
- sort_ref_dir(dir);
- if (do_for_each_entry_in_dir(dir, 0, name_conflict_fn, &data)) {
- error("'%s' exists; cannot create '%s'",
- data.conflicting_refname, refname);
+ for (slash = strchr(refname, '/'); slash; slash = strchr(slash + 1, '/')) {
+ /*
+ * We are still at a leading dir of the refname; we are
+ * looking for a conflict with a leaf entry.
+ *
+ * If we find one, we still must make sure it is
+ * not "oldrefname".
+ */
+ pos = search_ref_dir(dir, refname, slash - refname);
+ if (pos >= 0) {
+ struct ref_entry *entry = dir->entries[pos];
+ if (entry_matches(entry, oldrefname))
+ return 1;
+ report_refname_conflict(entry, refname);
+ return 0;
+ }
+
+
+ /*
+ * Otherwise, we can try to continue our search with
+ * the next component; if we come up empty, we know
+ * there is nothing under this whole prefix.
+ */
+ pos = search_ref_dir(dir, refname, slash + 1 - refname);
+ if (pos < 0)
+ return 1;
+
+ dir = get_ref_dir(dir->entries[pos]);
+ }
+
+ /*
+ * We are at the leaf of our refname; we want to
+ * make sure there are no directories which match it.
+ */
+ len = strlen(refname);
+ dirname = xmallocz(len + 1);
+ sprintf(dirname, "%s/", refname);
+ pos = search_ref_dir(dir, dirname, len + 1);
+ free(dirname);
+
+ if (pos >= 0) {
+ /*
+ * We found a directory named "refname". It is a
+ * problem iff it contains any ref that is not
+ * "oldrefname".
+ */
+ struct ref_entry *entry = dir->entries[pos];
+ struct ref_dir *dir = get_ref_dir(entry);
+ struct nonmatching_ref_data data;
+
+ data.skip = oldrefname;
+ sort_ref_dir(dir);
+ if (!do_for_each_entry_in_dir(dir, 0, nonmatching_ref_fn, &data))
+ return 1;
+
+ report_refname_conflict(data.found, refname);
return 0;
}
+
+ /*
+ * There is no point in searching for another leaf
+ * node which matches it; such an entry would be the
+ * ref we are looking for, not a conflict.
+ */
return 1;
}
@@ -2190,25 +2248,12 @@ struct ref_lock *lock_any_ref_for_update(const char *refname,
* Write an entry to the packed-refs file for the specified refname.
* If peeled is non-NULL, write it as the entry's peeled value.
*/
-static void write_packed_entry(int fd, char *refname, unsigned char *sha1,
+static void write_packed_entry(FILE *fh, char *refname, unsigned char *sha1,
unsigned char *peeled)
{
- char line[PATH_MAX + 100];
- int len;
-
- len = snprintf(line, sizeof(line), "%s %s\n",
- sha1_to_hex(sha1), refname);
- /* this should not happen but just being defensive */
- if (len > sizeof(line))
- die("too long a refname '%s'", refname);
- write_or_die(fd, line, len);
-
- if (peeled) {
- if (snprintf(line, sizeof(line), "^%s\n",
- sha1_to_hex(peeled)) != PEELED_LINE_LENGTH)
- die("internal error");
- write_or_die(fd, line, PEELED_LINE_LENGTH);
- }
+ fprintf_or_die(fh, "%s %s\n", sha1_to_hex(sha1), refname);
+ if (peeled)
+ fprintf_or_die(fh, "^%s\n", sha1_to_hex(peeled));
}
/*
@@ -2216,13 +2261,12 @@ static void write_packed_entry(int fd, char *refname, unsigned char *sha1,
*/
static int write_packed_entry_fn(struct ref_entry *entry, void *cb_data)
{
- int *fd = cb_data;
enum peel_status peel_status = peel_entry(entry, 0);
if (peel_status != PEEL_PEELED && peel_status != PEEL_NON_TAG)
error("internal error: %s is not a valid packed reference!",
entry->name);
- write_packed_entry(*fd, entry->name, entry->u.value.sha1,
+ write_packed_entry(cb_data, entry->name, entry->u.value.sha1,
peel_status == PEEL_PEELED ?
entry->u.value.peeled : NULL);
return 0;
@@ -2258,15 +2302,22 @@ int commit_packed_refs(void)
get_packed_ref_cache(&ref_cache);
int error = 0;
int save_errno = 0;
+ FILE *out;
if (!packed_ref_cache->lock)
die("internal error: packed-refs not locked");
- write_or_die(packed_ref_cache->lock->fd,
- PACKED_REFS_HEADER, strlen(PACKED_REFS_HEADER));
+ out = fdopen(packed_ref_cache->lock->fd, "w");
+ if (!out)
+ die_errno("unable to fdopen packed-refs descriptor");
+
+ fprintf_or_die(out, "%s", PACKED_REFS_HEADER);
do_for_each_entry_in_dir(get_packed_ref_dir(packed_ref_cache),
- 0, write_packed_entry_fn,
- &packed_ref_cache->lock->fd);
+ 0, write_packed_entry_fn, out);
+ if (fclose(out))
+ die_errno("write error");
+ packed_ref_cache->lock->fd = -1;
+
if (commit_lock_file(packed_ref_cache->lock)) {
save_errno = errno;
error = -1;
@@ -3108,7 +3159,7 @@ static int read_ref_at_ent_oldest(unsigned char *osha1, unsigned char *nsha1,
return 1;
}
-int read_ref_at(const char *refname, unsigned long at_time, int cnt,
+int read_ref_at(const char *refname, unsigned int flags, unsigned long at_time, int cnt,
unsigned char *sha1, char **msg,
unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
{
@@ -3126,8 +3177,12 @@ int read_ref_at(const char *refname, unsigned long at_time, int cnt,
for_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb);
- if (!cb.reccnt)
- die("Log for %s is empty.", refname);
+ if (!cb.reccnt) {
+ if (flags & GET_SHA1_QUIETLY)
+ exit(128);
+ else
+ die("Log for %s is empty.", refname);
+ }
if (cb.found_it)
return 0;
diff --git a/refs.h b/refs.h
index 10fc3a263..2328f06e7 100644
--- a/refs.h
+++ b/refs.h
@@ -206,7 +206,8 @@ extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, cons
int log_ref_setup(const char *refname, char *logfile, int bufsize);
/** Reads log for the value of ref during at_time. **/
-extern int read_ref_at(const char *refname, unsigned long at_time, int cnt,
+extern int read_ref_at(const char *refname, unsigned int flags,
+ unsigned long at_time, int cnt,
unsigned char *sha1, char **msg,
unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
diff --git a/revision.c b/revision.c
index 0d3e4171e..e498b7c33 100644
--- a/revision.c
+++ b/revision.c
@@ -1397,7 +1397,7 @@ static void prepare_show_merge(struct rev_info *revs)
continue;
if (ce_path_match(ce, &revs->prune_data, NULL)) {
prune_num++;
- prune = xrealloc(prune, sizeof(*prune) * prune_num);
+ REALLOC_ARRAY(prune, prune_num);
prune[prune_num-2] = ce->name;
prune[prune_num-1] = NULL;
}
diff --git a/server-info.c b/server-info.c
index 9ec744e9f..31f4a749f 100644
--- a/server-info.c
+++ b/server-info.c
@@ -4,45 +4,80 @@
#include "commit.h"
#include "tag.h"
-/* refs */
-static FILE *info_ref_fp;
+/*
+ * Create the file "path" by writing to a temporary file and renaming
+ * it into place. The contents of the file come from "generate", which
+ * should return non-zero if it encounters an error.
+ */
+static int update_info_file(char *path, int (*generate)(FILE *))
+{
+ char *tmp = mkpathdup("%s_XXXXXX", path);
+ int ret = -1;
+ int fd = -1;
+ FILE *fp = NULL;
+
+ safe_create_leading_directories(path);
+ fd = mkstemp(tmp);
+ if (fd < 0)
+ goto out;
+ fp = fdopen(fd, "w");
+ if (!fp)
+ goto out;
+ ret = generate(fp);
+ if (ret)
+ goto out;
+ if (fclose(fp))
+ goto out;
+ if (adjust_shared_perm(tmp) < 0)
+ goto out;
+ if (rename(tmp, path) < 0)
+ goto out;
+ ret = 0;
+
+out:
+ if (ret) {
+ error("unable to update %s: %s", path, strerror(errno));
+ if (fp)
+ fclose(fp);
+ else if (fd >= 0)
+ close(fd);
+ unlink(tmp);
+ }
+ free(tmp);
+ return ret;
+}
static int add_info_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
+ FILE *fp = cb_data;
struct object *o = parse_object(sha1);
if (!o)
return -1;
- fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path);
+ if (fprintf(fp, "%s %s\n", sha1_to_hex(sha1), path) < 0)
+ return -1;
+
if (o->type == OBJ_TAG) {
o = deref_tag(o, path, 0);
if (o)
- fprintf(info_ref_fp, "%s %s^{}\n",
- sha1_to_hex(o->sha1), path);
+ if (fprintf(fp, "%s %s^{}\n",
+ sha1_to_hex(o->sha1), path) < 0)
+ return -1;
}
return 0;
}
+static int generate_info_refs(FILE *fp)
+{
+ return for_each_ref(add_info_ref, fp);
+}
+
static int update_info_refs(int force)
{
- char *path0 = git_pathdup("info/refs");
- int len = strlen(path0);
- char *path1 = xmalloc(len + 2);
-
- strcpy(path1, path0);
- strcpy(path1 + len, "+");
-
- safe_create_leading_directories(path0);
- info_ref_fp = fopen(path1, "w");
- if (!info_ref_fp)
- return error("unable to update %s", path1);
- for_each_ref(add_info_ref, NULL);
- fclose(info_ref_fp);
- adjust_shared_perm(path1);
- rename(path1, path0);
- free(path0);
- free(path1);
- return 0;
+ char *path = git_pathdup("info/refs");
+ int ret = update_info_file(path, generate_info_refs);
+ free(path);
+ return ret;
}
/* packs */
@@ -198,36 +233,36 @@ static void init_pack_info(const char *infofile, int force)
info[i]->new_num = i;
}
-static void write_pack_info_file(FILE *fp)
+static void free_pack_info(void)
{
int i;
for (i = 0; i < num_pack; i++)
- fprintf(fp, "P %s\n", info[i]->p->pack_name + objdirlen + 6);
- fputc('\n', fp);
+ free(info[i]);
+ free(info);
}
-static int update_info_packs(int force)
+static int write_pack_info_file(FILE *fp)
{
- char infofile[PATH_MAX];
- char name[PATH_MAX];
- int namelen;
- FILE *fp;
+ int i;
+ for (i = 0; i < num_pack; i++) {
+ if (fprintf(fp, "P %s\n", info[i]->p->pack_name + objdirlen + 6) < 0)
+ return -1;
+ }
+ if (fputc('\n', fp) == EOF)
+ return -1;
+ return 0;
+}
- namelen = sprintf(infofile, "%s/info/packs", get_object_directory());
- strcpy(name, infofile);
- strcpy(name + namelen, "+");
+static int update_info_packs(int force)
+{
+ char *infofile = mkpathdup("%s/info/packs", get_object_directory());
+ int ret;
init_pack_info(infofile, force);
-
- safe_create_leading_directories(name);
- fp = fopen(name, "w");
- if (!fp)
- return error("cannot open %s", name);
- write_pack_info_file(fp);
- fclose(fp);
- adjust_shared_perm(name);
- rename(name, infofile);
- return 0;
+ ret = update_info_file(infofile, write_pack_info_file);
+ free_pack_info();
+ free(infofile);
+ return ret;
}
/* public */
diff --git a/sh-i18n--envsubst.c b/sh-i18n--envsubst.c
index 6dd03a974..2842a22d7 100644
--- a/sh-i18n--envsubst.c
+++ b/sh-i18n--envsubst.c
@@ -208,11 +208,8 @@ string_list_append (string_list_ty *slp, const char *s)
/* Grow the list. */
if (slp->nitems >= slp->nitems_max)
{
- size_t nbytes;
-
slp->nitems_max = slp->nitems_max * 2 + 4;
- nbytes = slp->nitems_max * sizeof (slp->item[0]);
- slp->item = (const char **) xrealloc (slp->item, nbytes);
+ REALLOC_ARRAY(slp->item, slp->nitems_max);
}
/* Add the string to the end of the list. */
diff --git a/sha1_name.c b/sha1_name.c
index 7098b10e3..5b004f513 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -432,7 +432,8 @@ static inline int upstream_mark(const char *string, int len)
static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned lookup_flags);
static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf);
-static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
+static int get_sha1_basic(const char *str, int len, unsigned char *sha1,
+ unsigned int flags)
{
static const char *warn_msg = "refname '%.*s' is ambiguous.";
static const char *object_name_msg = N_(
@@ -511,7 +512,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
if (!refs_found)
return -1;
- if (warn_ambiguous_refs &&
+ if (warn_ambiguous_refs && !(flags & GET_SHA1_QUIETLY) &&
(refs_found > 1 ||
!get_short_sha1(str, len, tmp_sha1, GET_SHA1_QUIETLY)))
warning(warn_msg, len, str);
@@ -545,7 +546,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
return -1;
}
}
- if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
+ if (read_ref_at(real_ref, flags, at_time, nth, sha1, NULL,
&co_time, &co_tz, &co_cnt)) {
if (!len) {
if (starts_with(real_ref, "refs/heads/")) {
@@ -557,11 +558,16 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
len = 4;
}
}
- if (at_time)
- warning("Log for '%.*s' only goes "
- "back to %s.", len, str,
- show_date(co_time, co_tz, DATE_RFC2822));
- else {
+ if (at_time) {
+ if (!(flags & GET_SHA1_QUIETLY)) {
+ warning("Log for '%.*s' only goes "
+ "back to %s.", len, str,
+ show_date(co_time, co_tz, DATE_RFC2822));
+ }
+ } else {
+ if (flags & GET_SHA1_QUIETLY) {
+ exit(128);
+ }
die("Log for '%.*s' only has %d entries.",
len, str, co_cnt);
}
@@ -801,7 +807,7 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l
if (!ret)
return 0;
- ret = get_sha1_basic(name, len, sha1);
+ ret = get_sha1_basic(name, len, sha1, lookup_flags);
if (!ret)
return 0;
diff --git a/shallow.c b/shallow.c
index de07709e3..57f4afa6b 100644
--- a/shallow.c
+++ b/shallow.c
@@ -392,8 +392,7 @@ static uint32_t *paint_alloc(struct paint_info *info)
void *p;
if (!info->slab_count || info->free + size > info->end) {
info->slab_count++;
- info->slab = xrealloc(info->slab,
- info->slab_count * sizeof(*info->slab));
+ REALLOC_ARRAY(info->slab, info->slab_count);
info->free = xmalloc(COMMIT_SLAB_SIZE);
info->slab[info->slab_count - 1] = info->free;
info->end = info->free + COMMIT_SLAB_SIZE;
diff --git a/string-list.c b/string-list.c
index db38b62b4..c5aa0765e 100644
--- a/string-list.c
+++ b/string-list.c
@@ -43,8 +43,7 @@ static int add_entry(int insert_at, struct string_list *list, const char *string
if (list->nr + 1 >= list->alloc) {
list->alloc += 32;
- list->items = xrealloc(list->items, list->alloc
- * sizeof(struct string_list_item));
+ REALLOC_ARRAY(list->items, list->alloc);
}
if (index < list->nr)
memmove(list->items + index + 1, list->items + index,
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index b52397afd..019fddd4e 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -214,6 +214,44 @@ test_expect_success 'tag pointing to something else than its type' '
test_must_fail git fsck --tags
'
+test_expect_success 'tag with incorrect tag name & missing tagger' '
+ sha=$(git rev-parse HEAD) &&
+ cat >wrong-tag <<-EOF &&
+ object $sha
+ type commit
+ tag wrong name format
+
+ This is an invalid tag.
+ EOF
+
+ tag=$(git hash-object -t tag -w --stdin <wrong-tag) &&
+ test_when_finished "remove_object $tag" &&
+ echo $tag >.git/refs/tags/wrong &&
+ test_when_finished "git update-ref -d refs/tags/wrong" &&
+ git fsck --tags 2>out &&
+ grep "invalid .tag. name" out &&
+ grep "expected .tagger. line" out
+'
+
+test_expect_success 'tag with bad tagger' '
+ sha=$(git rev-parse HEAD) &&
+ cat >wrong-tag <<-EOF &&
+ object $sha
+ type commit
+ tag not-quite-wrong
+ tagger Bad Tagger Name
+
+ This is an invalid tag.
+ EOF
+
+ tag=$(git hash-object --literally -t tag -w --stdin <wrong-tag) &&
+ test_when_finished "remove_object $tag" &&
+ echo $tag >.git/refs/tags/wrong &&
+ test_when_finished "git update-ref -d refs/tags/wrong" &&
+ test_must_fail git fsck --tags 2>out &&
+ grep "error in tag .*: invalid author/committer" out
+'
+
test_expect_success 'cleaned up' '
git fsck >actual 2>&1 &&
test_cmp empty actual
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 813cc1b3e..823fe1d79 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -72,15 +72,42 @@ test_expect_success 'fails with any bad rev or many good revs' '
test_expect_success 'fails silently when using -q' '
test_must_fail git rev-parse --verify --quiet 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse -q --verify foo 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse --verify -q HEAD bar 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse --quiet --verify baz HEAD 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error &&
- test -z "$(cat error)"
+ test_must_be_empty error
+'
+
+test_expect_success 'fails silently when using -q with deleted reflogs' '
+ ref=$(git rev-parse HEAD) &&
+ : >.git/logs/refs/test &&
+ git update-ref -m "message for refs/test" refs/test "$ref" &&
+ git reflog delete --updateref --rewrite refs/test@{0} &&
+ test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 &&
+ test_must_be_empty error
+'
+
+test_expect_success 'fails silently when using -q with not enough reflogs' '
+ ref=$(git rev-parse HEAD) &&
+ : >.git/logs/refs/test2 &&
+ git update-ref -m "message for refs/test2" refs/test2 "$ref" &&
+ test_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 &&
+ test_must_be_empty error
+'
+
+test_expect_success 'succeeds silently with -q and reflogs that do not go far back enough in time' '
+ ref=$(git rev-parse HEAD) &&
+ : >.git/logs/refs/test3 &&
+ git update-ref -m "message for refs/test3" refs/test3 "$ref" &&
+ git rev-parse -q --verify refs/test3@{1.year.ago} >actual 2>error &&
+ test_must_be_empty error &&
+ echo "$ref" >expect &&
+ test_cmp expect actual
'
test_expect_success 'no stdout output on error' '
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index 141b0611e..912a6635a 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -130,4 +130,33 @@ test_expect_success 'implicit --list conflicts with modification options' '
'
+# We want to set up a case where the walk for the tracking info
+# of one branch crosses the tip of another branch (and make sure
+# that the latter walk does not mess up our flag to see if it was
+# merged).
+#
+# Here "topic" tracks "master" with one extra commit, and "zzz" points to the
+# same tip as master The name "zzz" must come alphabetically after "topic"
+# as we process them in that order.
+test_expect_success 'branch --merged with --verbose' '
+ git branch --track topic master &&
+ git branch zzz topic &&
+ git checkout topic &&
+ test_commit foo &&
+ git branch --merged topic >actual &&
+ cat >expect <<-\EOF &&
+ master
+ * topic
+ zzz
+ EOF
+ test_cmp expect actual &&
+ git branch --verbose --merged topic >actual &&
+ cat >expect <<-\EOF &&
+ master c77a0a9 second on master
+ * topic 2c939f4 [ahead 1] foo
+ zzz c77a0a9 second on master
+ EOF
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 3a017bf43..aa9eb3a3e 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -11,7 +11,9 @@ semantic is still the same.
'
. ./test-lib.sh
-echo '[core] logallrefupdates = true' >>.git/config
+test_expect_success 'enable reflogs' '
+ git config core.logallrefupdates true
+'
test_expect_success \
'prepare a trivial repository' \
@@ -158,4 +160,31 @@ test_expect_success 'pack ref directly below refs/' '
test_path_is_missing .git/refs/top
'
+test_expect_success 'disable reflogs' '
+ git config core.logallrefupdates false &&
+ rm -rf .git/logs
+'
+
+test_expect_success 'create packed foo/bar/baz branch' '
+ git branch foo/bar/baz &&
+ git pack-refs --all --prune &&
+ test_path_is_missing .git/refs/heads/foo/bar/baz &&
+ test_path_is_missing .git/logs/refs/heads/foo/bar/baz
+'
+
+test_expect_success 'notice d/f conflict with existing directory' '
+ test_must_fail git branch foo &&
+ test_must_fail git branch foo/bar
+'
+
+test_expect_success 'existing directory reports concrete ref' '
+ test_must_fail git branch foo 2>stderr &&
+ grep refs/heads/foo/bar/baz stderr
+'
+
+test_expect_success 'notice d/f conflict with existing ref' '
+ test_must_fail git branch foo/bar/baz/extra &&
+ test_must_fail git branch foo/bar/baz/lots/of/extra/components
+'
+
test_done
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 9b7539957..7398605e7 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -465,4 +465,15 @@ EOF
test_cmp expected actual1
'
+test_expect_success 'clean log decoration' '
+ git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
+ cat >expected <<EOF &&
+$head1 tag: refs/tags/tag2
+$head2 tag: refs/tags/message-one
+$old_head1 tag: refs/tags/message-two
+EOF
+ sort actual >actual1 &&
+ test_cmp expected actual1
+'
+
test_done
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index 4bbb71875..61bc8da56 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -243,4 +243,23 @@ test_expect_success 'running index-pack in the object store' '
test -f .git/objects/pack/pack-${pack1}.idx
'
+test_expect_success 'index-pack --strict warns upon missing tagger in tag' '
+ sha=$(git rev-parse HEAD) &&
+ cat >wrong-tag <<EOF &&
+object $sha
+type commit
+tag guten tag
+
+This is an invalid tag.
+EOF
+
+ tag=$(git hash-object -t tag -w --stdin <wrong-tag) &&
+ pack1=$(echo $tag $sha | git pack-objects tag-test) &&
+ echo remove tag object &&
+ thirtyeight=${tag#??} &&
+ rm -f .git/objects/${tag%$thirtyeight}/$thirtyeight &&
+ git index-pack --strict tag-test-${pack1}.pack 2>err &&
+ grep "^error:.* expected .tagger. line" err
+'
+
test_done
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 17bcb0b04..7f278d8ce 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -135,4 +135,17 @@ test_expect_success 'send-pack stderr contains hook messages' '
test_cmp expect actual
'
+test_expect_success 'pre-receive hook that forgets to read its input' '
+ write_script victim.git/hooks/pre-receive <<-\EOF &&
+ exit 0
+ EOF
+ rm -f victim.git/hooks/update victim.git/hooks/post-update &&
+
+ for v in $(test_seq 100 999)
+ do
+ git branch branch_$v master || return
+ done &&
+ git push ./victim.git "+refs/heads/*:refs/heads/*"
+'
+
test_done
diff --git a/walker.c b/walker.c
index f8d370913..18a67d33c 100644
--- a/walker.c
+++ b/walker.c
@@ -228,8 +228,8 @@ int walker_targets_stdin(char ***target, const char ***write_ref)
if (targets >= targets_alloc) {
targets_alloc = targets_alloc ? targets_alloc * 2 : 64;
- *target = xrealloc(*target, targets_alloc * sizeof(**target));
- *write_ref = xrealloc(*write_ref, targets_alloc * sizeof(**write_ref));
+ REALLOC_ARRAY(*target, targets_alloc);
+ REALLOC_ARRAY(*write_ref, targets_alloc);
}
(*target)[targets] = xstrdup(tg_one);
(*write_ref)[targets] = rf_one ? xstrdup(rf_one) : NULL;
diff --git a/write_or_die.c b/write_or_die.c
index b50f99a93..e7afe7a29 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -49,6 +49,21 @@ void maybe_flush_or_die(FILE *f, const char *desc)
}
}
+void fprintf_or_die(FILE *f, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, fmt);
+ ret = vfprintf(f, fmt, ap);
+ va_end(ap);
+
+ if (ret < 0) {
+ check_pipe(errno);
+ die_errno("write error");
+ }
+}
+
void fsync_or_die(int fd, const char *msg)
{
if (fsync(fd) < 0) {