@matheusbsbs / matheus-bagliano / commits / 95f8ebbfc7
Fork 0

git am --skip: clean the index while preserving local changes

In 3-way merge, "am" will let the index with unmerged path waiting for us to resolve conflicts and continue. But if we want to --skip instead, "am" refuses to continue because of the dirty index. With this patch, "am" will clean the index without touching files locally modified, before continuing. Signed-off-by: Olivier Marin <dkr@freesurf.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Olivier Marin committed Jul 21, 2008 at 15:39 UTC 95f8ebbfc7997b3114d4f09360501324905c4e6d
2 files changed +18 -5
git-am.sh
+9 -3
@@ -202,8 +202,15 @@ then
202 die "previous rebase directory $dotest still exists but mbox given."
203 resume=yes
204
205 - case "$abort" in
206 - t)
205 + case "$skip,$abort" in
206 + t,)
207 + git rerere clear
208 + git read-tree --reset -u HEAD HEAD
209 + orig_head=$(cat "$GIT_DIR/ORIG_HEAD")
210 + git reset HEAD
211 + git update-ref ORIG_HEAD $orig_head
212 + ;;
213 + ,t)
214 git rerere clear
215 git read-tree --reset -u HEAD ORIG_HEAD
216 git reset ORIG_HEAD
@@ -297,7 +304,6 @@ last=`cat "$dotest/last"`
304 this=`cat "$dotest/next"`
305 if test "$skip" = t
306 then
300 - git rerere clear
307 this=`expr "$this" + 1`
308 resume=
309 fi
t/t4151-am-abort.sh
+9 -2
@@ -14,7 +14,7 @@ test_expect_success setup '
14 git add file-1 file-2 &&
15 git commit -m initial &&
16 git tag initial &&
17 - for i in 2 3 4 5
17 + for i in 2 3 4 5 6
18 do
19 echo $i >>file-1 &&
20 test_tick &&
@@ -32,7 +32,7 @@ do
32 git reset --hard initial &&
33 cp file-2-expect file-2 &&
34
35 - test_must_fail git am$with3 000[124]-*.patch &&
35 + test_must_fail git am$with3 000[1245]-*.patch &&
36 git log --pretty=tformat:%s >actual &&
37 for i in 3 2 initial
38 do
@@ -41,6 +41,13 @@ do
41 test_cmp expect actual
42 '
43
44 + test_expect_success "am$with3 --skip continue after failed am$with3" '
45 + test_must_fail git-am$with3 --skip >output &&
46 + test "$(grep "^Applying" output)" = "Applying 6" &&
47 + test_cmp file-2-expect file-2 &&
48 + test ! -f .git/rr-cache/MERGE_RR
49 + '
50 +
51 test_expect_success "am --abort goes back after failed am$with3" '
52 git-am --abort &&
53 git rev-parse HEAD >actual &&