Subject: [PATCH/RFC] Add two basic tests for "rerere remaining"

From: Phil Hord <[email-masked]>
Date: Fri, 15 Jul 2011 17:05:05 -0400

After a 'git stash apply' which results in a conflicted file,
git mergetool can be used to work on the conflicts.  However,
when rerere.enabled=true, git mergetool determines the list
of unresolved file conflicts by asking 'git rerere remaining'.

There is a problem with this because rerere does not record
the 'git stash apply' conflicts and so 'git rerere remaining'
does not report them.

Demonstrate this failing so it can be studied and addressed.

Also add a very basic test for 'git rerere remaining' after
a normal merge conflict.

Signed-off-by: Phil Hord <[email-masked]>
---

This patch adds one failing test and one working test.

The working test is very limited and just repeats the
same test as the 'rerere status' one for 'rerere remaining'.
A better test should probably be added, one that demonstrates
and confirms the differences between 'rerere status' and
'rerere remaining'.  I don't understand this difference
well enough to code that test, though.
 
 t/t4200-rerere.sh |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 36255d6..a96ebad 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -96,10 +96,42 @@ test_expect_success 'rerere.enabled works, too' '
 	grep ^=======$ $rr/preimage
 '
 
+test_expect_success 'set up conflicted stash apply' '
+	rm -rf .git/rr-cache &&
+	git config rerere.enabled true &&
+
+	git reset --hard &&
+	git checkout master &&
+	git show second:a1 >a1 &&
+
+	# should be 1 modified file and no unmerged files
+	test $(git ls-files -m |wc -l) = 1 &&
+	test $(git ls-files -u |wc -l) = 0 &&
+
+	git stash save &&
+	git checkout first &&
+
+	test_must_fail git stash apply &&
+
+	# there should be three states for one unresolved file
+	cnt=$(git ls-files -u | wc -l) &&
+	echo $cnt &&
+	test $cnt = 3
+'
+
+test_expect_failure 'rerere-remaining correctly reports stash-apply conflicts' '
+	echo a1 >expect &&
+	git rerere status >out &&
+	test_cmp expect out &&
+	git rerere remaining >out &&
+	test_cmp expect out
+'
+
 test_expect_success 'set up rr-cache' '
 	rm -rf .git/rr-cache &&
 	git config rerere.enabled true &&
 	git reset --hard &&
+	git checkout second &&
 	test_must_fail git merge first &&
 	sha1=$(perl -pe "s/	.*//" .git/MERGE_RR) &&
 	rr=.git/rr-cache/$sha1
@@ -160,6 +192,12 @@ test_expect_success 'rerere status' '
 	test_cmp expect out
 '
 
+test_expect_success 'rerere remaining' '
+	echo a1 >expect &&
+	git rerere remaining >out &&
+	test_cmp expect out
+'
+
 test_expect_success 'first postimage wins' '
 	git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
 
-- 
1.7.6.8.gd2879