Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 95104c7

Browse files
bk2204gitster
authored andcommitted
rebase--merge: fix --skip with two conflicts in a row
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34d5217 commit 95104c7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

git-rebase--merge.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ continue_merge () {
5353
}
5454

5555
call_merge () {
56-
cmt="$(cat "$state_dir/cmt.$1")"
56+
msgnum="$1"
57+
echo "$msgnum" >"$state_dir/msgnum"
58+
cmt="$(cat "$state_dir/cmt.$msgnum")"
5759
echo "$cmt" > "$state_dir/current"
5860
hd=$(git rev-parse --verify HEAD)
5961
cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
60-
msgnum=$(cat "$state_dir/msgnum")
6162
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
6263
eval GITHEAD_$hd='$onto_name'
6364
export GITHEAD_$cmt GITHEAD_$hd

t/t3402-rebase-merge.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ test_expect_success setup '
3333
tr "[a-z]" "[A-Z]" <original >newfile &&
3434
git add newfile &&
3535
git commit -a -m"side edits further." &&
36+
git branch second-side &&
3637
3738
tr "[a-m]" "[A-M]" <original >newfile &&
3839
rm -f original &&
@@ -41,6 +42,7 @@ test_expect_success setup '
4142
git branch test-rebase side &&
4243
git branch test-rebase-pick side &&
4344
git branch test-reference-pick side &&
45+
git branch test-conflicts side &&
4446
git checkout -b test-merge side
4547
'
4648

@@ -138,4 +140,17 @@ test_expect_success 'rebase -s funny -Xopt' '
138140
test -f funny.was.run
139141
'
140142

143+
test_expect_success 'rebase --skip works with two conflicts in a row' '
144+
git checkout second-side &&
145+
tr "[A-Z]" "[a-z]" <newfile >tmp &&
146+
mv tmp newfile &&
147+
git commit -a -m"edit conflicting with side" &&
148+
tr "[d-f]" "[D-F]" <newfile >tmp &&
149+
mv tmp newfile &&
150+
git commit -a -m"another edit conflicting with side" &&
151+
test_must_fail git rebase --merge test-conflicts &&
152+
test_must_fail git rebase --skip &&
153+
git rebase --skip
154+
'
155+
141156
test_done

0 commit comments

Comments
 (0)