summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-08-19 15:34:13 -0700
committerJunio C Hamano <gitster@pobox.com>2016-08-19 15:34:14 -0700
commitaeb1b7f55d5db4eda968de5eb27f04d42df9edc1 (patch)
treefdea1fcbbbb3837bb82b38dc0d578c46020c0c4c /commit.c
parentd63263a4dee8fc7da9b97bbdedf9c0d1f33024d4 (diff)
parent5447a76aad4074c31e7c8a6299cc586435f385e9 (diff)
downloadgit-aeb1b7f55d5db4eda968de5eb27f04d42df9edc1.tar.gz
Merge branch 'rs/pull-signed-tag'
When "git merge-recursive" works on history with many criss-cross merges in "verbose" mode, the names the command assigns to the virtual merge bases could have overwritten each other by unintended reuse of the same piece of memory. * rs/pull-signed-tag: commit: use FLEX_ARRAY in struct merge_remote_desc merge-recursive: fix verbose output for multiple base trees commit: factor out set_merge_remote_desc() commit: use xstrdup() in get_merge_parent()
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/commit.c b/commit.c
index 71a360dad3..ba6dee37aa 100644
--- a/commit.c
+++ b/commit.c
@@ -1576,6 +1576,15 @@ int commit_tree_extended(const char *msg, size_t msg_len,
return result;
}
+void set_merge_remote_desc(struct commit *commit,
+ const char *name, struct object *obj)
+{
+ struct merge_remote_desc *desc;
+ FLEX_ALLOC_STR(desc, name, name);
+ desc->obj = obj;
+ commit->util = desc;
+}
+
struct commit *get_merge_parent(const char *name)
{
struct object *obj;
@@ -1585,13 +1594,8 @@ struct commit *get_merge_parent(const char *name)
return NULL;
obj = parse_object(oid.hash);
commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
- if (commit && !commit->util) {
- struct merge_remote_desc *desc;
- desc = xmalloc(sizeof(*desc));
- desc->obj = obj;
- desc->name = strdup(name);
- commit->util = desc;
- }
+ if (commit && !commit->util)
+ set_merge_remote_desc(commit, name, obj);
return commit;
}