Skip to content

Commit 79dc2d0

Browse files
phordgitster
authored andcommitted
test: git-stash conflict sets up rerere
Add a test to make sure that a conflicted "stash apply" invokes rerere to record the conflicts and resolve the the files it can (the current code doesn't, so the test is marked as failing). Without correct state recorded for rerere, mergetool may be confused, causing it to think no files have conflicts even though they do. This condition is not verified by this test since a subsequent commit will change the behavior to enable rerere for stash conflicts. Also, the next test expected us to finish up with a reset, which is impossible to do if we fail (as we must) and it's an unreasonable expectation anyway. Begin the next test with a reset of its own instead. Signed-off-by: Phil Hord <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0f1ea6 commit 79dc2d0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

t/t7610-mergetool.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ test_expect_success 'setup' '
5555
git rm file12 &&
5656
git commit -m "branch1 changes" &&
5757
58+
git checkout -b stash1 master &&
59+
echo stash1 change file11 >file11 &&
60+
git add file11 &&
61+
git commit -m "stash1 changes" &&
62+
63+
git checkout -b stash2 master &&
64+
echo stash2 change file11 >file11 &&
65+
git add file11 &&
66+
git commit -m "stash2 changes" &&
67+
5868
git checkout master &&
5969
git submodule update -N &&
6070
echo master updated >file1 &&
@@ -193,7 +203,35 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '
193203
git reset --hard
194204
'
195205

206+
test_expect_failure 'conflicted stash sets up rerere' '
207+
git config rerere.enabled true &&
208+
git checkout stash1 &&
209+
echo "Conflicting stash content" >file11 &&
210+
git stash &&
211+
212+
git checkout --detach stash2 &&
213+
test_must_fail git stash apply &&
214+
215+
test -n "$(git ls-files -u)" &&
216+
conflicts="$(git rerere remaining)" &&
217+
test "$conflicts" = "file11" &&
218+
output="$(git mergetool --no-prompt)" &&
219+
test "$output" != "No files need merging" &&
220+
221+
git commit -am "save the stash resolution" &&
222+
223+
git reset --hard stash2 &&
224+
test_must_fail git stash apply &&
225+
226+
test -n "$(git ls-files -u)" &&
227+
conflicts="$(git rerere remaining)" &&
228+
test -z "$conflicts" &&
229+
output="$(git mergetool --no-prompt)" &&
230+
test "$output" = "No files need merging"
231+
'
232+
196233
test_expect_success 'mergetool takes partial path' '
234+
git reset --hard
197235
git config rerere.enabled false &&
198236
git checkout -b test12 branch1 &&
199237
git submodule update -N &&

0 commit comments

Comments
 (0)