am --skip: support skipping while on unborn branch
When git am --skip is run, git am will copy HEAD's tree entries to the index with "git reset HEAD". However, on an unborn branch, HEAD does not point to a tree, so "git reset HEAD" will fail. Fix this by treating HEAD as en empty tree when we are on an unborn branch. Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Paul Tan committed
Jun 6, 2015 at 19:46 UTC
f8da6801e2fb3e46a42031b860c6411ef76a0335
2 files changed
+11
-3
git-am.sh
+1
-3
@@ -499,9 +499,7 @@ then
499
git read-tree --reset -u $head_tree $head_tree &&
500
index_tree=$(git write-tree) &&
501
git read-tree -m -u $index_tree $head_tree
502
- orig_head=$(cat "$GIT_DIR/ORIG_HEAD")
503
- git reset HEAD
504
- git update-ref ORIG_HEAD $orig_head
502
+ git read-tree $head_tree
503
;;
504
,t)
505
if test -f "$dotest/rebasing"
t/t4151-am-abort.sh
+10
@@ -92,4 +92,14 @@ test_expect_success 'am -3 stops on conflict on unborn branch' '
92
test 4 = "$(cat otherfile-4)"
93
'
94
95
+test_expect_success 'am -3 --skip clears index on unborn branch' '
96
+ test_path_is_dir .git/rebase-apply &&
97
+ echo tmpfile >tmpfile &&
98
+ git add tmpfile &&
99
+ git am --skip &&
100
+ test -z "$(git ls-files)" &&
101
+ test_path_is_missing otherfile-4 &&
102
+ test_path_is_missing tmpfile
103
+'
104
+
105
test_done