{"thread":{"id":"6048","subject":"Re: [PATCH 2/3] Add a test for git-rerere","startedAt":"2006-12-20T16:37:45Z","lastAt":"2006-12-21T09:21:28Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"294584","messageId":"Pine.LNX.4.63.0612201737190.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6048","inReplyTo":null,"subject":"[PATCH 2/3] Add a test for git-rerere","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-20T16:37:45Z","receivedAt":"2006-12-20T16:37:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n t/t4200-rerere.sh |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 154 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh\nnew file mode 100644\nindex 0000000..263c3d4\n--- /dev/null\n+++ b/t/t4200-rerere.sh\n@@ -0,0 +1,154 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Johannes E. Schindelin\n+#\n+\n+test_description='git-rerere\n+'\n+\n+. ./test-lib.sh\n+\n+cat > a1 << EOF\n+Whether 'tis nobler in the mind to suffer\n+The slings and arrows of outrageous fortune,\n+Or to take arms against a sea of troubles,\n+And by opposing end them? To die: to sleep;\n+No more; and by a sleep to say we end\n+The heart-ache and the thousand natural shocks\n+That flesh is heir to, 'tis a consummation\n+Devoutly to be wish'd.\n+EOF\n+\n+git add a1\n+git commit -q -a -m initial\n+\n+git checkout -b first\n+cat >> a1 << EOF\n+To die, to sleep;\n+To sleep: perchance to dream: ay, there's the rub;\n+For in that sleep of death what dreams may come\n+When we have shuffled off this mortal coil,\n+Must give us pause: there's the respect\n+That makes calamity of so long life;\n+EOF\n+git commit -q -a -m first\n+\n+git checkout -b second master\n+git show first:a1 | sed 's/To die, t/To die! T/' > a1\n+git commit -q -a -m second\n+\n+# activate rerere\n+mkdir .git/rr-cache\n+\n+test_expect_failure 'conflicting merge' 'git pull . first'\n+\n+sha1=4f58849a60b4f969a2848966b6d02893b783e8fb\n+rr=.git/rr-cache/$sha1\n+test_expect_success 'recorded preimage' \"grep ======= $rr/preimage\"\n+\n+test_expect_success 'no postimage or thisimage yet' \\\n+\t\"test ! -f $rr/postimage -a ! -f $rr/thisimage\"\n+\n+git show first:a1 > a1\n+\n+cat > expect << EOF\n+--- a/a1\n++++ b/a1\n+@@ -6,11 +6,7 @@\n+ The heart-ache and the thousand natural shocks\n+ That flesh is heir to, 'tis a consummation\n+ Devoutly to be wish'd.\n+-<<<<<<<\n+-To die! To sleep;\n+-=======\n+ To die, to sleep;\n+->>>>>>>\n+ To sleep: perchance to dream: ay, there's the rub;\n+ For in that sleep of death what dreams may come\n+ When we have shuffled off this mortal coil,\n+EOF\n+\n+git rerere diff > out\n+\n+test_expect_success 'rerere diff' 'diff -u expect out'\n+\n+cat > expect << EOF\n+a1\n+EOF\n+\n+git rerere status > out\n+\n+test_expect_success 'rerere status' 'diff -u expect out'\n+\n+test_expect_success 'commit succeeds' \\\n+\t\"git commit -q -a -m 'prefer first over second'\"\n+\n+test_expect_success 'recorded postimage' \"test -f $rr/postimage\"\n+\n+git checkout -b third master\n+git show second^:a1 | sed 's/To die: t/To die! T/' > a1\n+git commit -q -a -m third\n+\n+test_expect_failure 'another conflicting merge' 'git pull . first'\n+\n+git show first:a1 | sed 's/To die: t/To die! T/' > expect\n+test_expect_success 'rerere kicked in' \"! grep ======= a1\"\n+\n+test_expect_success 'rerere prefers first change' 'diff -u a1 expect'\n+\n+rm $rr/postimage\n+echo -ne \"$sha1\\ta1\\0\" > .git/rr-cache/MERGE_RR\n+\n+test_expect_success 'rerere clear' 'git rerere clear'\n+\n+test_expect_success 'clear removed the directory' \"test ! -d $rr\"\n+\n+mkdir $rr\n+echo Hello > $rr/preimage\n+echo World > $rr/postimage\n+\n+sha2=4000000000000000000000000000000000000000\n+rr2=.git/rr-cache/$sha2\n+mkdir $rr2\n+echo Hello > $rr2/preimage\n+\n+case \"$(date -d @11111111 +%s 2>/dev/null)\" in\n+[1-9]*)\n+\t# it is a recent GNU date. good.\n+\tnow=$(date +%s)\n+\tlet almost_15_days_ago=$now+60-15*86400\n+\tlet just_over_15_days_ago=$now-1-15*86400\n+\tlet almost_60_days_ago=$now+60-60*86400\n+\tlet just_over_60_days_ago=$now-1-60*86400\n+\tpredate1=\"$(date -d \"@$almost_60_days_ago\" +%c)\"\n+\tpredate2=\"$(date -d \"@$almost_15_days_ago\" +%c)\"\n+\tpostdate1=\"$(date -d \"@$just_over_60_days_ago\" +%c)\"\n+\tpostdate2=\"$(date -d \"@$just_over_15_days_ago\" +%c)\"\n+\t;;\n+*)\n+\t# it is not GNU date. oh, well.\n+\tpredate1=\"$(date)\"\n+\tpredate2=\"$(date)\"\n+\tpostdate1='1 Oct 2006 00:00:00'\n+\tpostdate2='1 Dec 2006 00:00:00'\n+esac\n+\n+touch -m -d \"$predate1\" $rr/preimage\n+touch -m -d \"$predate2\" $rr2/preimage\n+\n+test_expect_success 'garbage collection (part1)' 'git rerere gc'\n+\n+test_expect_success 'young records still live' \\\n+\t\"test -f $rr/preimage -a -f $rr2/preimage\"\n+\n+touch -m -d \"$postdate1\" $rr/preimage\n+touch -m -d \"$postdate2\" $rr2/preimage\n+\n+test_expect_success 'garbage collection (part2)' 'git rerere gc'\n+\n+test_expect_success 'old records rest in peace' \\\n+\t\"test ! -f $rr/preimage -a ! -f $rr2/preimage\"\n+\n+test_done\n+\n+\n-- \n1.4.4.2.g35224\n"},{"id":"296679","messageId":"7v4prqfm6c.fsf@assigned-by-dhcp.cox.net","threadId":"6048","inReplyTo":"Pine.LNX.4.63.0612201737190.19693@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 2/3] Add a test for git-rerere","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-20T18:37:47Z","receivedAt":"2006-12-20T18:37:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> +cat > a1 << EOF\n> +Whether 'tis nobler in the mind to suffer\n> +The slings and arrows of outrageous fortune,\n> +Or to take arms against a sea of troubles,\n> +And by opposing end them? To die: to sleep;\n> +No more; and by a sleep to say we end\n> +The heart-ache and the thousand natural shocks\n> +That flesh is heir to, 'tis a consummation\n> +Devoutly to be wish'd.\n> +EOF\n\nThis is out of copyright protection long time ago, so it would\nbe fine to use in example ;-).\n\n> +sha1=4f58849a60b4f969a2848966b6d02893b783e8fb\n> +rr=.git/rr-cache/$sha1\n> +test_expect_success 'recorded preimage' \"grep ======= $rr/preimage\"\n> +\n> +test_expect_success 'no postimage or thisimage yet' \\\n> +\t\"test ! -f $rr/postimage -a ! -f $rr/thisimage\"\n\nI am worried that this test specifies the behaviour a bit too\nprecisely.  It is not t0000 basic where we want bit-for-bit\nmatch with the expected result.  Wouldn't this test break when\nyou further improve xdl_merge, for example?\n\n> +rm $rr/postimage\n> +echo -ne \"$sha1\\ta1\\0\" > .git/rr-cache/MERGE_RR\n\nHmmmmmm.  I've stayed away from \"echo -e\" so far...\n\n> +sha2=4000000000000000000000000000000000000000\n> +rr2=.git/rr-cache/$sha2\n> +mkdir $rr2\n> +echo Hello > $rr2/preimage\n\nCollisions are not so likely and perhaps we do not care.\n\n> +case \"$(date -d @11111111 +%s 2>/dev/null)\" in\n> +[1-9]*)\n> +\t# it is a recent GNU date. good.\n> +\tnow=$(date +%s)\n> +\tlet almost_15_days_ago=$now+60-15*86400\n> +\tlet just_over_15_days_ago=$now-1-15*86400\n> +\tlet almost_60_days_ago=$now+60-60*86400\n> +\tlet just_over_60_days_ago=$now-1-60*86400\n\nHmmmmm.  I've stayed away from \"let\" so far as well...\n"},{"id":"29909","messageId":"Pine.LNX.4.63.0612210927150.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6048","inReplyTo":"7v4prqfm6c.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/3] Add a test for git-rerere","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-21T08:34:07Z","receivedAt":"2006-12-21T08:34:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 20 Dec 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > +sha1=4f58849a60b4f969a2848966b6d02893b783e8fb\n> > +rr=.git/rr-cache/$sha1\n> > +test_expect_success 'recorded preimage' \"grep ======= $rr/preimage\"\n> > +\n> > +test_expect_success 'no postimage or thisimage yet' \\\n> > +\t\"test ! -f $rr/postimage -a ! -f $rr/thisimage\"\n> \n> I am worried that this test specifies the behaviour a bit too\n> precisely.  It is not t0000 basic where we want bit-for-bit\n> match with the expected result.  Wouldn't this test break when\n> you further improve xdl_merge, for example?\n\nIn this case, I doubt that xdl_merge() can do _anything_. The example is \nset up so it _must_ fail with any sane merge algorithm.\n\nAnd I very much wanted the behaviour put down very precisely, so that I \ncatch any bugs in builtin-rerere. In fact, as I went, I wrote the test \nwith the original rerere, and then whipped the builtin until it conformed.\n\nSince anyone modifying rerere's behaviour can modify this test to catch \nthat behaviour, too, I am not so worried.\n \n> > +rm $rr/postimage\n> > +echo -ne \"$sha1\\ta1\\0\" > .git/rr-cache/MERGE_RR\n> \n> Hmmmmmm.  I've stayed away from \"echo -e\" so far...\n\nRather do it with tr? Like this:\n\n\techo -n \"$sha1\ta1X\" | tr X '\\0' > .git/rr-cache/MERGE_RR\n\n> > +sha2=4000000000000000000000000000000000000000\n> > +rr2=.git/rr-cache/$sha2\n> > +mkdir $rr2\n> > +echo Hello > $rr2/preimage\n> \n> Collisions are not so likely and perhaps we do not care.\n\nBoth. If collisions were likely, we both would know by now _and_ would be \nin serious trouble. And we do not care, since there cannot be any other \ndirectory in rr-cache, apart from $sha1/.\n\n> > +case \"$(date -d @11111111 +%s 2>/dev/null)\" in\n> > +[1-9]*)\n> > +\t# it is a recent GNU date. good.\n> > +\tnow=$(date +%s)\n> > +\tlet almost_15_days_ago=$now+60-15*86400\n> > +\tlet just_over_15_days_ago=$now-1-15*86400\n> > +\tlet almost_60_days_ago=$now+60-60*86400\n> > +\tlet just_over_60_days_ago=$now-1-60*86400\n> \n> Hmmmmm.  I've stayed away from \"let\" so far as well...\n\nIs $((1+2)) portable enough? I always thought this is a bashism...\n\nCiao,\nDscho\n"},{"id":"29911","messageId":"7vhcvpej3i.fsf@assigned-by-dhcp.cox.net","threadId":"6048","inReplyTo":"Pine.LNX.4.63.0612210927150.19693@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 2/3] Add a test for git-rerere","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-21T08:41:53Z","receivedAt":"2006-12-21T08:41:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> > +rm $rr/postimage\n>> > +echo -ne \"$sha1\\ta1\\0\" > .git/rr-cache/MERGE_RR\n>> \n>> Hmmmmmm.  I've stayed away from \"echo -e\" so far...\n>\n> Rather do it with tr? Like this:\n>\n> \techo -n \"$sha1\ta1X\" | tr X '\\0' > .git/rr-cache/MERGE_RR\n\nBog-standard old timer's way is not to use -n nor X but just do:\n\n\techo \"stuff you want to NUL terminate\" | tr '\\012' '\\0'\n\n> Is $((1+2)) portable enough? I always thought this is a bashism...\n\nThat's also in ksh and dash (and in POSIX) and recent updates to\nout *.sh scripts make liberal use of them.  As long as you do\nnot overflow you are fine.\n"},{"id":"29920","messageId":"Pine.LNX.4.63.0612211018430.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6048","inReplyTo":"7vhcvpej3i.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Add a test for git-rerere","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-21T09:21:28Z","receivedAt":"2006-12-21T09:21:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tOn Thu, 21 Dec 2006, Junio C Hamano wrote:\n\n\t> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\t> \n\t> >> > +rm $rr/postimage\n\t> >> > +echo -ne \"$sha1\\ta1\\0\" > .git/rr-cache/MERGE_RR\n\t> >> \n\t> >> Hmmmmmm.  I've stayed away from \"echo -e\" so far...\n\t> >\n\t> > Rather do it with tr? Like this:\n\t> >\n\t> > \techo -n \"$sha1\ta1X\" | tr X '\\0' > .git/rr-cache/MERGE_RR\n\t> \n\t> Bog-standard old timer's way is not to use -n nor X but just do:\n\t> \n\t> \techo \"stuff you want to NUL terminate\" | tr '\\012' '\\0'\n\t> \n\t> > Is $((1+2)) portable enough? I always thought this is a bashism...\n\t> \n\t> That's also in ksh and dash (and in POSIX) and recent updates to\n\t> out *.sh scripts make liberal use of them.  As long as you do\n\t> not overflow you are fine.\n\n\tDone.\n\n\tBTW I think this test should be 3/3 instead of 2/3, since it fails \n\twith the Perl rerere if you do not have the required modules \n\tinstalled.\n\n t/t4200-rerere.sh |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 154 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh\nnew file mode 100644\nindex 0000000..5ee5b23\n--- /dev/null\n+++ b/t/t4200-rerere.sh\n@@ -0,0 +1,154 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Johannes E. Schindelin\n+#\n+\n+test_description='git-rerere\n+'\n+\n+. ./test-lib.sh\n+\n+cat > a1 << EOF\n+Whether 'tis nobler in the mind to suffer\n+The slings and arrows of outrageous fortune,\n+Or to take arms against a sea of troubles,\n+And by opposing end them? To die: to sleep;\n+No more; and by a sleep to say we end\n+The heart-ache and the thousand natural shocks\n+That flesh is heir to, 'tis a consummation\n+Devoutly to be wish'd.\n+EOF\n+\n+git add a1\n+git commit -q -a -m initial\n+\n+git checkout -b first\n+cat >> a1 << EOF\n+To die, to sleep;\n+To sleep: perchance to dream: ay, there's the rub;\n+For in that sleep of death what dreams may come\n+When we have shuffled off this mortal coil,\n+Must give us pause: there's the respect\n+That makes calamity of so long life;\n+EOF\n+git commit -q -a -m first\n+\n+git checkout -b second master\n+git show first:a1 | sed 's/To die, t/To die! T/' > a1\n+git commit -q -a -m second\n+\n+# activate rerere\n+mkdir .git/rr-cache\n+\n+test_expect_failure 'conflicting merge' 'git pull . first'\n+\n+sha1=4f58849a60b4f969a2848966b6d02893b783e8fb\n+rr=.git/rr-cache/$sha1\n+test_expect_success 'recorded preimage' \"grep ======= $rr/preimage\"\n+\n+test_expect_success 'no postimage or thisimage yet' \\\n+\t\"test ! -f $rr/postimage -a ! -f $rr/thisimage\"\n+\n+git show first:a1 > a1\n+\n+cat > expect << EOF\n+--- a/a1\n++++ b/a1\n+@@ -6,11 +6,7 @@\n+ The heart-ache and the thousand natural shocks\n+ That flesh is heir to, 'tis a consummation\n+ Devoutly to be wish'd.\n+-<<<<<<<\n+-To die! To sleep;\n+-=======\n+ To die, to sleep;\n+->>>>>>>\n+ To sleep: perchance to dream: ay, there's the rub;\n+ For in that sleep of death what dreams may come\n+ When we have shuffled off this mortal coil,\n+EOF\n+\n+git rerere diff > out\n+\n+test_expect_success 'rerere diff' 'diff -u expect out'\n+\n+cat > expect << EOF\n+a1\n+EOF\n+\n+git rerere status > out\n+\n+test_expect_success 'rerere status' 'diff -u expect out'\n+\n+test_expect_success 'commit succeeds' \\\n+\t\"git commit -q -a -m 'prefer first over second'\"\n+\n+test_expect_success 'recorded postimage' \"test -f $rr/postimage\"\n+\n+git checkout -b third master\n+git show second^:a1 | sed 's/To die: t/To die! T/' > a1\n+git commit -q -a -m third\n+\n+test_expect_failure 'another conflicting merge' 'git pull . first'\n+\n+git show first:a1 | sed 's/To die: t/To die! T/' > expect\n+test_expect_success 'rerere kicked in' \"! grep ======= a1\"\n+\n+test_expect_success 'rerere prefers first change' 'diff -u a1 expect'\n+\n+rm $rr/postimage\n+echo \"$sha1\ta1\" | tr '\\012' '\\0' > .git/rr-cache/MERGE_RR\n+\n+test_expect_success 'rerere clear' 'git rerere clear'\n+\n+test_expect_success 'clear removed the directory' \"test ! -d $rr\"\n+\n+mkdir $rr\n+echo Hello > $rr/preimage\n+echo World > $rr/postimage\n+\n+sha2=4000000000000000000000000000000000000000\n+rr2=.git/rr-cache/$sha2\n+mkdir $rr2\n+echo Hello > $rr2/preimage\n+\n+case \"$(date -d @11111111 +%s 2>/dev/null)\" in\n+[1-9]*)\n+\t# it is a recent GNU date. good.\n+\tnow=$(date +%s)\n+\talmost_15_days_ago=$(($now+60-15*86400))\n+\tjust_over_15_days_ago=$(($now-1-15*86400))\n+\talmost_60_days_ago=$(($now+60-60*86400))\n+\tjust_over_60_days_ago=$(($now-1-60*86400))\n+\tpredate1=\"$(date -d \"@$almost_60_days_ago\" +%c)\"\n+\tpredate2=\"$(date -d \"@$almost_15_days_ago\" +%c)\"\n+\tpostdate1=\"$(date -d \"@$just_over_60_days_ago\" +%c)\"\n+\tpostdate2=\"$(date -d \"@$just_over_15_days_ago\" +%c)\"\n+\t;;\n+*)\n+\t# it is not GNU date. oh, well.\n+\tpredate1=\"$(date)\"\n+\tpredate2=\"$(date)\"\n+\tpostdate1='1 Oct 2006 00:00:00'\n+\tpostdate2='1 Dec 2006 00:00:00'\n+esac\n+\n+touch -m -d \"$predate1\" $rr/preimage\n+touch -m -d \"$predate2\" $rr2/preimage\n+\n+test_expect_success 'garbage collection (part1)' 'git rerere gc'\n+\n+test_expect_success 'young records still live' \\\n+\t\"test -f $rr/preimage -a -f $rr2/preimage\"\n+\n+touch -m -d \"$postdate1\" $rr/preimage\n+touch -m -d \"$postdate2\" $rr2/preimage\n+\n+test_expect_success 'garbage collection (part2)' 'git rerere gc'\n+\n+test_expect_success 'old records rest in peace' \\\n+\t\"test ! -f $rr/preimage -a ! -f $rr2/preimage\"\n+\n+test_done\n+\n+\n"}]}