Re: [PATCH 2/3] Add a test for git-rerere

2 messages, 2 authors, 2016-08-11 · open the first message on its own page

Re: [PATCH 2/3] Add a test for git-rerere

From: Junio C Hamano <hidden>
Date: 2016-08-11 20:10:25

Johannes Schindelin [off-list ref] writes:
+cat > a1 << EOF
+Whether 'tis nobler in the mind to suffer
+The slings and arrows of outrageous fortune,
+Or to take arms against a sea of troubles,
+And by opposing end them? To die: to sleep;
+No more; and by a sleep to say we end
+The heart-ache and the thousand natural shocks
+That flesh is heir to, 'tis a consummation
+Devoutly to be wish'd.
+EOF
This is out of copyright protection long time ago, so it would
be fine to use in example ;-).
+sha1=4f58849a60b4f969a2848966b6d02893b783e8fb
+rr=.git/rr-cache/$sha1
+test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
+
+test_expect_success 'no postimage or thisimage yet' \
+	"test ! -f $rr/postimage -a ! -f $rr/thisimage"
I am worried that this test specifies the behaviour a bit too
precisely.  It is not t0000 basic where we want bit-for-bit
match with the expected result.  Wouldn't this test break when
you further improve xdl_merge, for example?
+rm $rr/postimage
+echo -ne "$sha1\ta1\0" > .git/rr-cache/MERGE_RR
Hmmmmmm.  I've stayed away from "echo -e" so far...
+sha2=4000000000000000000000000000000000000000
+rr2=.git/rr-cache/$sha2
+mkdir $rr2
+echo Hello > $rr2/preimage
Collisions are not so likely and perhaps we do not care.
+case "$(date -d @11111111 +%s 2>/dev/null)" in
+[1-9]*)
+	# it is a recent GNU date. good.
+	now=$(date +%s)
+	let almost_15_days_ago=$now+60-15*86400
+	let just_over_15_days_ago=$now-1-15*86400
+	let almost_60_days_ago=$now+60-60*86400
+	let just_over_60_days_ago=$now-1-60*86400
Hmmmmm.  I've stayed away from "let" so far as well...

Re: [PATCH 2/3] Add a test for git-rerere

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:42:46

Hi,

On Wed, 20 Dec 2006, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
+sha1=4f58849a60b4f969a2848966b6d02893b783e8fb
+rr=.git/rr-cache/$sha1
+test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
+
+test_expect_success 'no postimage or thisimage yet' \
+	"test ! -f $rr/postimage -a ! -f $rr/thisimage"
I am worried that this test specifies the behaviour a bit too
precisely.  It is not t0000 basic where we want bit-for-bit
match with the expected result.  Wouldn't this test break when
you further improve xdl_merge, for example?
In this case, I doubt that xdl_merge() can do _anything_. The example is 
set up so it _must_ fail with any sane merge algorithm.

And I very much wanted the behaviour put down very precisely, so that I 
catch any bugs in builtin-rerere. In fact, as I went, I wrote the test 
with the original rerere, and then whipped the builtin until it conformed.

Since anyone modifying rerere's behaviour can modify this test to catch 
that behaviour, too, I am not so worried.
 
quoted
+rm $rr/postimage
+echo -ne "$sha1\ta1\0" > .git/rr-cache/MERGE_RR
Hmmmmmm.  I've stayed away from "echo -e" so far...
Rather do it with tr? Like this:

	echo -n "$sha1	a1X" | tr X '\0' > .git/rr-cache/MERGE_RR
quoted
+sha2=4000000000000000000000000000000000000000
+rr2=.git/rr-cache/$sha2
+mkdir $rr2
+echo Hello > $rr2/preimage
Collisions are not so likely and perhaps we do not care.
Both. If collisions were likely, we both would know by now _and_ would be 
in serious trouble. And we do not care, since there cannot be any other 
directory in rr-cache, apart from $sha1/.
quoted
+case "$(date -d @11111111 +%s 2>/dev/null)" in
+[1-9]*)
+	# it is a recent GNU date. good.
+	now=$(date +%s)
+	let almost_15_days_ago=$now+60-15*86400
+	let just_over_15_days_ago=$now-1-15*86400
+	let almost_60_days_ago=$now+60-60*86400
+	let just_over_60_days_ago=$now-1-60*86400
Hmmmmm.  I've stayed away from "let" so far as well...
Is $((1+2)) portable enough? I always thought this is a bashism...

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help