3 # Copyright (c) 2006 Johannes E. Schindelin
6 test_description='git-rerere
12 Whether 'tis nobler in the mind to suffer
13 The slings and arrows of outrageous fortune,
14 Or to take arms against a sea of troubles,
15 And by opposing end them? To die: to sleep;
16 No more; and by a sleep to say we end
17 The heart-ache and the thousand natural shocks
18 That flesh is heir to, 'tis a consummation
19 Devoutly to be wish'd.
23 git commit -q -a -m initial
28 To sleep: perchance to dream: ay, there's the rub;
29 For in that sleep of death what dreams may come
30 When we have shuffled off this mortal coil,
31 Must give us pause: there's the respect
32 That makes calamity of so long life;
34 git commit -q -a -m first
36 git checkout -b second master
38 sed -e 's/To die, t/To die! T/' > a1
40 git commit -q -a -m second
45 test_expect_failure 'conflicting merge' 'git pull . first'
47 sha1=$(sed -e 's/\t.*//' .git/rr-cache/MERGE_RR)
48 rr=.git/rr-cache/$sha1
49 test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
51 test_expect_success 'no postimage or thisimage yet' \
52 "test ! -f $rr/postimage -a ! -f $rr/thisimage"
54 test_expect_success 'preimage has right number of lines' '
56 cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
61 git show first:a1 > a1
67 The heart-ache and the thousand natural shocks
68 That flesh is heir to, 'tis a consummation
69 Devoutly to be wish'd.
75 To sleep: perchance to dream: ay, there's the rub;
76 For in that sleep of death what dreams may come
77 When we have shuffled off this mortal coil,
78 Must give us pause: there's the respect
79 That makes calamity of so long life;
87 test_expect_success 'rerere diff' 'git diff expect out'
93 git rerere status > out
95 test_expect_success 'rerere status' 'git diff expect out'
97 test_expect_success 'commit succeeds' \
98 "git commit -q -a -m 'prefer first over second'"
100 test_expect_success 'recorded postimage' "test -f $rr/postimage"
102 git checkout -b third master
103 git show second^:a1 | sed 's/To die: t/To die! T/' > a1
104 git commit -q -a -m third
106 test_expect_failure 'another conflicting merge' 'git pull . first'
108 git show first:a1 | sed 's/To die: t/To die! T/' > expect
109 test_expect_success 'rerere kicked in' "! grep ======= a1"
111 test_expect_success 'rerere prefers first change' 'git diff a1 expect'
114 echo "$sha1 a1" | tr '\012' '\0' > .git/rr-cache/MERGE_RR
116 test_expect_success 'rerere clear' 'git rerere clear'
118 test_expect_success 'clear removed the directory' "test ! -d $rr"
121 echo Hello > $rr/preimage
122 echo World > $rr/postimage
124 sha2=4000000000000000000000000000000000000000
125 rr2=.git/rr-cache/$sha2
127 echo Hello > $rr2/preimage
129 almost_15_days_ago=$((60-15*86400))
130 just_over_15_days_ago=$((-1-15*86400))
131 almost_60_days_ago=$((60-60*86400))
132 just_over_60_days_ago=$((-1-60*86400))
134 test-chmtime =$almost_60_days_ago $rr/preimage
135 test-chmtime =$almost_15_days_ago $rr2/preimage
137 test_expect_success 'garbage collection (part1)' 'git rerere gc'
139 test_expect_success 'young records still live' \
140 "test -f $rr/preimage && test -f $rr2/preimage"
142 test-chmtime =$just_over_60_days_ago $rr/preimage
143 test-chmtime =$just_over_15_days_ago $rr2/preimage
145 test_expect_success 'garbage collection (part2)' 'git rerere gc'
147 test_expect_success 'old records rest in peace' \
148 "test ! -f $rr/preimage && test ! -f $rr2/preimage"