X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=builtin%2Fmerge.c;h=a437ecba297e76eab1b72a2966b2b0b1cf3b49bc;hb=d9ac3e41c37ea565d8227d942b4f468616c9813a;hp=0f03dff1160f68de6f406f038c1b5c2bbd6529c8;hpb=8de43386505b503e25788f75f89802495828e6c0;p=git.git diff --git a/builtin/merge.c b/builtin/merge.c index 0f03dff11..a437ecba2 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -599,6 +599,14 @@ static void write_tree_trivial(unsigned char *sha1) die(_("git write-tree failed to write a tree")); } +static const char *merge_argument(struct commit *commit) +{ + if (commit) + return sha1_to_hex(commit->object.sha1); + else + return EMPTY_TREE_SHA1_HEX; +} + int try_merge_command(const char *strategy, size_t xopts_nr, const char **xopts, struct commit_list *common, const char *head_arg, struct commit_list *remotes) @@ -619,11 +627,11 @@ int try_merge_command(const char *strategy, size_t xopts_nr, args[i++] = s; } for (j = common; j; j = j->next) - args[i++] = xstrdup(sha1_to_hex(j->item->object.sha1)); + args[i++] = xstrdup(merge_argument(j->item)); args[i++] = "--"; args[i++] = head_arg; for (j = remotes; j; j = j->next) - args[i++] = xstrdup(sha1_to_hex(j->item->object.sha1)); + args[i++] = xstrdup(merge_argument(j->item)); args[i] = NULL; ret = run_command_v_opt(args, RUN_GIT_CMD); strbuf_release(&buf);