From 2c970c9ec3af9e162951a1b22d42c1a4dd9a8fed Mon Sep 17 00:00:00 2001 From: Paul Tan Date: Sat, 6 Jun 2015 19:46:08 +0800 Subject: am -3: support 3way merge on unborn branch While on an unborn branch, git am -3 will fail to do a threeway merge as it references HEAD as "our tree", but HEAD does not point to a valid tree. Fix this by using an empty tree as "our tree" when we are on an unborn branch. Signed-off-by: Paul Tan Signed-off-by: Junio C Hamano --- git-am.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-am.sh') diff --git a/git-am.sh b/git-am.sh index 80a7fdbd24..c5e139ff33 100755 --- a/git-am.sh +++ b/git-am.sh @@ -178,7 +178,8 @@ It does not apply to blobs recorded in its index.")" then GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY fi - git-merge-recursive $orig_tree -- HEAD $his_tree || { + our_tree=$(git rev-parse --verify -q HEAD || echo $empty_tree) + git-merge-recursive $orig_tree -- $our_tree $his_tree || { git rerere $allow_rerere_autoupdate die "$(gettext "Failed to merge in the changes.")" } -- cgit v1.2.3