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 <hordp@cisco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phil Hord committed Jul 10, 2012 at 18:52 UTC 79dc2d0b0250b4a90dfc83ae69c116e08c9df0a3
1 file changed +38
t/t7610-mergetool.sh
+38
@@ -55,6 +55,16 @@ test_expect_success 'setup' '
55 git rm file12 &&
56 git commit -m "branch1 changes" &&
57
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 +
68 git checkout master &&
69 git submodule update -N &&
70 echo master updated >file1 &&
@@ -193,7 +203,35 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '
203 git reset --hard
204 '
205
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 +
233 test_expect_success 'mergetool takes partial path' '
234 + git reset --hard
235 git config rerere.enabled false &&
236 git checkout -b test12 branch1 &&
237 git submodule update -N &&