Subject: Re: jn/shortlog

From: Jonathan Nieder <[email-masked]>
Date: Mon, 3 May 2010 20:56:35 -0500

Jonathan Nieder wrote:
> Will Palmer wrote:

>> Haven't been able to reproduce here (just running make -m4 in a
>> while-loop all night) Any specific tests failing?
>
> In t4201-shortlog.sh:
> 
> --- expect.template     2010-05-04 00:17:41.609754167 +0000
> +++ log.predictable     2010-05-04 00:17:41.613754428 +0000
> @@ -1,10 +0,0 @@
[etc]

So apparently shortlog does not default to HEAD when stdin is not a
tty.

Possible fixes:

 - document the current unfriendly behavior
 - default to HEAD when input is empty

Jonathan

-- 8< --
Subject: t4200 (rerere): guard setup with test_expect_success

Ensure that GIT_SKIP_TESTS='t4200.*' actually suppresses all of t4200.

Also quote some stray dollar signs and test the result from some
git config invocations.

Signed-off-by: Jonathan Nieder <[email-masked]>
---
 t/t4200-rerere.sh |  189 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 106 insertions(+), 83 deletions(-)

diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 70856d0..d9b87c9 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -56,23 +56,27 @@ test_expect_success 'conflicting merge' '
 	git reset --hard &&
 	mkdir .git/rr-cache &&
 	git config --unset rerere.enabled &&
-	test_must_fail git merge first
+	test_must_fail git merge first &&
+	sha1=$(perl -pe "s/	.*//" .git/MERGE_RR) &&
+	rr=.git/rr-cache/$sha1
 '
 
-sha1=$(perl -pe 's/	.*//' .git/MERGE_RR)
-rr=.git/rr-cache/$sha1
-test_expect_success 'recorded preimage' "grep ^=======$ $rr/preimage"
+test_expect_success 'recorded preimage' '
+	grep "^=======\$" "$rr/preimage"
+'
 
 test_expect_success 'rerere.enabled works, too' '
 	rm -rf .git/rr-cache &&
 	git config rerere.enabled true &&
 	git reset --hard &&
 	test_must_fail git merge first &&
-	grep ^=======$ $rr/preimage
+	grep "^=======\$" "$rr/preimage"
 '
 
-test_expect_success 'no postimage or thisimage yet' \
-	"test ! -f $rr/postimage -a ! -f $rr/thisimage"
+test_expect_success 'no postimage or thisimage yet' '
+	! test -f "$rr/postimage" &&
+	! test -f "$rr/thisimage"
+'
 
 test_expect_success 'preimage has right number of lines' '
 
@@ -81,56 +85,60 @@ test_expect_success 'preimage has right number of lines' '
 
 '
 
-git show first:a1 > a1
-
-cat > expect << EOF
---- a/a1
-+++ b/a1
-@@ -1,4 +1,4 @@
--Some Title
-+Some title
- ==========
- Whether 'tis nobler in the mind to suffer
- The slings and arrows of outrageous fortune,
-@@ -8,21 +8,11 @@
- The heart-ache and the thousand natural shocks
- That flesh is heir to, 'tis a consummation
- Devoutly to be wish'd.
--<<<<<<<
--Some Title
--==========
--To die! To sleep;
--=======
- Some title
- ==========
- To die, to sleep;
-->>>>>>>
- To sleep: perchance to dream: ay, there's the rub;
- For in that sleep of death what dreams may come
- When we have shuffled off this mortal coil,
- Must give us pause: there's the respect
- That makes calamity of so long life;
--<<<<<<<
--=======
--* END *
-->>>>>>>
-EOF
-git rerere diff > out
-
-test_expect_success 'rerere diff' 'test_cmp expect out'
-
-cat > expect << EOF
-a1
-EOF
-
-git rerere status > out
-
-test_expect_success 'rerere status' 'test_cmp expect out'
+test_expect_success 'rerere diff' "
+	git show first:a1 >a1 &&
+
+	cat >expect <<-\EOF
+	--- a/a1
+	+++ b/a1
+	@@ -1,4 +1,4 @@
+	-Some Title
+	+Some title
+	 ==========
+	 Whether 'tis nobler in the mind to suffer
+	 The slings and arrows of outrageous fortune,
+	@@ -8,21 +8,11 @@
+	 The heart-ache and the thousand natural shocks
+	 That flesh is heir to, 'tis a consummation
+	 Devoutly to be wish'd.
+	-<<<<<<<
+	-Some Title
+	-==========
+	-To die! To sleep;
+	-=======
+	 Some title
+	 ==========
+	 To die, to sleep;
+	->>>>>>>
+	 To sleep: perchance to dream: ay, there's the rub;
+	 For in that sleep of death what dreams may come
+	 When we have shuffled off this mortal coil,
+	 Must give us pause: there's the respect
+	 That makes calamity of so long life;
+	-<<<<<<<
+	-=======
+	-* END *
+	->>>>>>>
+	EOF
+	git rerere diff >out &&
+	test_cmp expect out
+"
+
+test_expect_success 'rerere status' '
+	cat >expect <<-\EOF &&
+	a1
+	EOF
+
+	git rerere status >out &&
+	test_cmp expect out
+'
 
 test_expect_success 'commit succeeds' \
 	"git commit -q -a -m 'prefer first over second'"
 
-test_expect_success 'recorded postimage' "test -f $rr/postimage"
+test_expect_success 'recorded postimage' '
+	test -f "$rr/postimage"
+'
 
 test_expect_success 'another conflicting merge' '
 	git checkout -b third master &&
@@ -139,47 +147,62 @@ test_expect_success 'another conflicting merge' '
 	test_must_fail git pull . first
 '
 
-git show first:a1 | sed 's/To die: t/To die! T/' > expect
-test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
+test_expect_success 'rerere kicked in' '
+	! grep "^=======\$" a1
+'
 
-test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
+test_expect_success 'rerere prefers first change' '
+	git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
+	test_cmp a1 expect
+'
 
-rm $rr/postimage
-echo "$sha1	a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
+test_expect_success 'cleanup' '
+	rm $rr/postimage &&
+	echo "$sha1	a1" |
+		perl -pe "y/\012/\000/" >.git/MERGE_RR
+'
 
 test_expect_success 'rerere clear' 'git rerere clear'
 
 test_expect_success 'clear removed the directory' "test ! -d $rr"
 
-mkdir $rr
-echo Hello > $rr/preimage
-echo World > $rr/postimage
-
-sha2=4000000000000000000000000000000000000000
-rr2=.git/rr-cache/$sha2
-mkdir $rr2
-echo Hello > $rr2/preimage
-
-almost_15_days_ago=$((60-15*86400))
-just_over_15_days_ago=$((-1-15*86400))
-almost_60_days_ago=$((60-60*86400))
-just_over_60_days_ago=$((-1-60*86400))
+test_expect_success 'gc setup' '
+	mkdir "$rr" &&
+	echo Hello >"$rr/preimage" &&
+	echo World >"$rr/postimage" &&
 
-test-chmtime =$almost_60_days_ago $rr/preimage
-test-chmtime =$almost_15_days_ago $rr2/preimage
+	sha2=4000000000000000000000000000000000000000 &&
+	rr2=.git/rr-cache/$sha2 &&
+	mkdir "$rr2" &&
+	echo Hello >"$rr2/preimage" &&
 
-test_expect_success 'garbage collection (part1)' 'git rerere gc'
+	almost_15_days_ago=$((60-15*86400)) &&
+	just_over_15_days_ago=$((-1-15*86400)) &&
+	almost_60_days_ago=$((60-60*86400)) &&
+	just_over_60_days_ago=$((-1-60*86400))
+'
 
-test_expect_success 'young records still live' \
-	"test -f $rr/preimage && test -f $rr2/preimage"
+test_expect_success 'garbage collection (part1)' '
+	test-chmtime "=$almost_60_days_ago" "$rr/preimage" &&
+	test-chmtime "=$almost_15_days_ago" "$rr2/preimage" &&
+	git rerere gc
+'
 
-test-chmtime =$just_over_60_days_ago $rr/preimage
-test-chmtime =$just_over_15_days_ago $rr2/preimage
+test_expect_success 'young records still live' '
+	test -f "$rr/preimage" &&
+	test -f "$rr2/preimage"
+'
 
-test_expect_success 'garbage collection (part2)' 'git rerere gc'
+test_expect_success 'garbage collection (part2)' '
+	test-chmtime "=$just_over_60_days_ago" "$rr/preimage" &&
+	test-chmtime "=$just_over_15_days_ago" "$rr2/preimage" &&
+	git rerere gc
+'
 
-test_expect_success 'old records rest in peace' \
-	"test ! -f $rr/preimage && test ! -f $rr2/preimage"
+test_expect_success 'old records rest in peace' '
+	! test -f "$rr/preimage" &&
+	! test -f "$rr2/preimage"
+'
 
 test_expect_success 'file2 added differently in two branches' '
 	git reset --hard &&
@@ -214,7 +237,7 @@ test_expect_success 'resolution was recorded properly' '
 '
 
 test_expect_success 'rerere.autoupdate' '
-	git config rerere.autoupdate true
+	git config rerere.autoupdate true &&
 	git reset --hard &&
 	git checkout version2 &&
 	test_must_fail git merge fifth &&
@@ -230,7 +253,7 @@ test_expect_success 'merge --rerere-autoupdate' '
 '
 
 test_expect_success 'merge --no-rerere-autoupdate' '
-	git config rerere.autoupdate true
+	git config rerere.autoupdate true &&
 	git reset --hard &&
 	git checkout version2 &&
 	test_must_fail git merge --no-rerere-autoupdate fifth &&
-- 
1.7.1.5.g8d03f