summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-am.sh3
-rwxr-xr-xt/t4151-am-abort.sh9
2 files changed, 11 insertions, 1 deletions
diff --git a/git-am.sh b/git-am.sh
index 80a7fdb..c5e139f 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.")"
}
diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
index 5ac741a..2683ffa 100755
--- a/t/t4151-am-abort.sh
+++ b/t/t4151-am-abort.sh
@@ -83,4 +83,13 @@ test_expect_success 'am --abort will keep the local commits intact' '
test_cmp expect actual
'
+test_expect_success 'am -3 stops on conflict on unborn branch' '
+ git checkout -f --orphan orphan &&
+ git reset &&
+ rm -f otherfile-4 &&
+ test_must_fail git am -3 0003-*.patch &&
+ test 2 -eq $(git ls-files -u | wc -l) &&
+ test 4 = "$(cat otherfile-4)"
+'
+
test_done