diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-05-19 20:37:19 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-19 20:37:19 -0700 |
commit | 6699c959efccc7cb969b87bdf8e0154a0fe9ccc8 (patch) | |
tree | 96b536942f08c30e8d5f9f7dc6ec950ddd67f0e3 /builtin/merge.c | |
parent | e2e4aed5defb2df8dbd523613ff4ef46050abb07 (diff) | |
parent | e9fe74cba4ed4577dcc02f61094c611a1c216fee (diff) | |
download | git-6699c959efccc7cb969b87bdf8e0154a0fe9ccc8.tar.gz |
Merge branch 'jk/cherry-pick-root-with-resolve'
* jk/cherry-pick-root-with-resolve:
t3503: test cherry picking and reverting root commits
revert: allow reverting a root commit
cherry-pick: handle root commits with external strategies
Diffstat (limited to 'builtin/merge.c')
-rw-r--r-- | builtin/merge.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index 7eebb71491..5a2a1eb797 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -608,6 +608,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) @@ -628,11 +636,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); |