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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jun 16, 2014 at 00:01 UTC
95104c7e257652b82aed089494def344e3938928
2 files changed
+18
-2
git-rebase--merge.sh
+3
-2
@@ -53,11 +53,12 @@ continue_merge () {
53
}
54
55
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")"
59
echo "$cmt" > "$state_dir/current"
60
hd=$(git rev-parse --verify HEAD)
61
cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
60
- msgnum=$(cat "$state_dir/msgnum")
62
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
63
eval GITHEAD_$hd='$onto_name'
64
export GITHEAD_$cmt GITHEAD_$hd
t/t3402-rebase-merge.sh
+15
@@ -33,6 +33,7 @@ test_expect_success setup '
33
tr "[a-z]" "[A-Z]" <original >newfile &&
34
git add newfile &&
35
git commit -a -m"side edits further." &&
36
+ git branch second-side &&
37
38
tr "[a-m]" "[A-M]" <original >newfile &&
39
rm -f original &&
@@ -41,6 +42,7 @@ test_expect_success setup '
42
git branch test-rebase side &&
43
git branch test-rebase-pick side &&
44
git branch test-reference-pick side &&
45
+ git branch test-conflicts side &&
46
git checkout -b test-merge side
47
'
48
@@ -138,4 +140,17 @@ test_expect_success 'rebase -s funny -Xopt' '
140
test -f funny.was.run
141
'
142
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
+
156
test_done