OSDN Git Service

rebase--merge: fix --skip with two conflicts in a row
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 16 Jun 2014 00:01:25 +0000 (00:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 20:29:16 +0000 (13:29 -0700)
If git rebase --merge encountered a conflict, --skip would not work if the
next commit also conflicted.  The msgnum file would never be updated with
the new patch number, so no patch would actually be skipped, resulting in an
inescapable loop.

Update the msgnum file's value as the first thing in call_merge.  This also
avoids an "Already applied" message when skipping a commit.  There is no
visible change for the other contexts in which call_merge is invoked, as the
msgnum file's value remains unchanged in those situations.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase--merge.sh
t/t3402-rebase-merge.sh

index 838fbed..f6b5dd0 100644 (file)
@@ -53,11 +53,12 @@ continue_merge () {
 }
 
 call_merge () {
-       cmt="$(cat "$state_dir/cmt.$1")"
+       msgnum="$1"
+       echo "$msgnum" >"$state_dir/msgnum"
+       cmt="$(cat "$state_dir/cmt.$msgnum")"
        echo "$cmt" > "$state_dir/current"
        hd=$(git rev-parse --verify HEAD)
        cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
-       msgnum=$(cat "$state_dir/msgnum")
        eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
        eval GITHEAD_$hd='$onto_name'
        export GITHEAD_$cmt GITHEAD_$hd
index be8c1d5..5a27ec9 100755 (executable)
@@ -33,6 +33,7 @@ test_expect_success setup '
        tr "[a-z]" "[A-Z]" <original >newfile &&
        git add newfile &&
        git commit -a -m"side edits further." &&
+       git branch second-side &&
 
        tr "[a-m]" "[A-M]" <original >newfile &&
        rm -f original &&
@@ -41,6 +42,7 @@ test_expect_success setup '
        git branch test-rebase side &&
        git branch test-rebase-pick side &&
        git branch test-reference-pick side &&
+       git branch test-conflicts side &&
        git checkout -b test-merge side
 '
 
@@ -138,4 +140,17 @@ test_expect_success 'rebase -s funny -Xopt' '
        test -f funny.was.run
 '
 
+test_expect_success 'rebase --skip works with two conflicts in a row' '
+       git checkout second-side  &&
+       tr "[A-Z]" "[a-z]" <newfile >tmp &&
+       mv tmp newfile &&
+       git commit -a -m"edit conflicting with side" &&
+       tr "[d-f]" "[D-F]" <newfile >tmp &&
+       mv tmp newfile &&
+       git commit -a -m"another edit conflicting with side" &&
+       test_must_fail git rebase --merge test-conflicts &&
+       test_must_fail git rebase --skip &&
+       git rebase --skip
+'
+
 test_done