mergetool: Fix typo in options passed to kdiff3
[git/mergetool.git] / t / t4200-rerere.sh
blobcfcdb69dc890aed55eabf9ec8d13529538e50465
1 #!/bin/sh
3 # Copyright (c) 2006 Johannes E. Schindelin
6 test_description='git rerere
9 . ./test-lib.sh
11 cat > a1 << EOF
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.
20 EOF
22 git add a1
23 git commit -q -a -m initial
25 git checkout -b first
26 cat >> a1 << EOF
27 To die, to sleep;
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;
33 EOF
34 git commit -q -a -m first
36 git checkout -b second master
37 git show first:a1 |
38 sed -e 's/To die, t/To die! T/' > a1
39 echo "* END *" >>a1
40 git commit -q -a -m second
42 test_expect_success 'nothing recorded without rerere' '
43 (rm -rf .git/rr-cache; git config rerere.enabled false) &&
44 ! git merge first &&
45 ! test -d .git/rr-cache
48 # activate rerere, old style
49 test_expect_success 'conflicting merge' '
50 git reset --hard &&
51 mkdir .git/rr-cache &&
52 git config --unset rerere.enabled &&
53 ! git merge first
56 sha1=$(sed -e 's/ .*//' .git/rr-cache/MERGE_RR)
57 rr=.git/rr-cache/$sha1
58 test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
60 test_expect_success 'rerere.enabled works, too' '
61 rm -rf .git/rr-cache &&
62 git config rerere.enabled true &&
63 git reset --hard &&
64 ! git merge first &&
65 grep ======= $rr/preimage
68 test_expect_success 'no postimage or thisimage yet' \
69 "test ! -f $rr/postimage -a ! -f $rr/thisimage"
71 test_expect_success 'preimage has right number of lines' '
73 cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
74 test $cnt = 9
78 git show first:a1 > a1
80 cat > expect << EOF
81 --- a/a1
82 +++ b/a1
83 @@ -6,17 +6,9 @@
84 The heart-ache and the thousand natural shocks
85 That flesh is heir to, 'tis a consummation
86 Devoutly to be wish'd.
87 -<<<<<<<
88 -To die! To sleep;
89 -=======
90 To die, to sleep;
91 ->>>>>>>
92 To sleep: perchance to dream: ay, there's the rub;
93 For in that sleep of death what dreams may come
94 When we have shuffled off this mortal coil,
95 Must give us pause: there's the respect
96 That makes calamity of so long life;
97 -<<<<<<<
98 -=======
99 -* END *
100 ->>>>>>>
102 git rerere diff > out
104 test_expect_success 'rerere diff' 'git diff expect out'
106 cat > expect << EOF
110 git rerere status > out
112 test_expect_success 'rerere status' 'git diff expect out'
114 test_expect_success 'commit succeeds' \
115 "git commit -q -a -m 'prefer first over second'"
117 test_expect_success 'recorded postimage' "test -f $rr/postimage"
119 test_expect_success 'another conflicting merge' '
120 git checkout -b third master &&
121 git show second^:a1 | sed "s/To die: t/To die! T/" > a1 &&
122 git commit -q -a -m third &&
123 ! git pull . first
126 git show first:a1 | sed 's/To die: t/To die! T/' > expect
127 test_expect_success 'rerere kicked in' "! grep ======= a1"
129 test_expect_success 'rerere prefers first change' 'git diff a1 expect'
131 rm $rr/postimage
132 echo "$sha1 a1" | tr '\012' '\0' > .git/rr-cache/MERGE_RR
134 test_expect_success 'rerere clear' 'git rerere clear'
136 test_expect_success 'clear removed the directory' "test ! -d $rr"
138 mkdir $rr
139 echo Hello > $rr/preimage
140 echo World > $rr/postimage
142 sha2=4000000000000000000000000000000000000000
143 rr2=.git/rr-cache/$sha2
144 mkdir $rr2
145 echo Hello > $rr2/preimage
147 almost_15_days_ago=$((60-15*86400))
148 just_over_15_days_ago=$((-1-15*86400))
149 almost_60_days_ago=$((60-60*86400))
150 just_over_60_days_ago=$((-1-60*86400))
152 test-chmtime =$almost_60_days_ago $rr/preimage
153 test-chmtime =$almost_15_days_ago $rr2/preimage
155 test_expect_success 'garbage collection (part1)' 'git rerere gc'
157 test_expect_success 'young records still live' \
158 "test -f $rr/preimage && test -f $rr2/preimage"
160 test-chmtime =$just_over_60_days_ago $rr/preimage
161 test-chmtime =$just_over_15_days_ago $rr2/preimage
163 test_expect_success 'garbage collection (part2)' 'git rerere gc'
165 test_expect_success 'old records rest in peace' \
166 "test ! -f $rr/preimage && test ! -f $rr2/preimage"
168 test_expect_success 'file2 added differently in two branches' '
169 git reset --hard &&
170 git checkout -b fourth &&
171 echo Hallo > file2 &&
172 git add file2 &&
173 git commit -m version1 &&
174 git checkout third &&
175 echo Bello > file2 &&
176 git add file2 &&
177 git commit -m version2 &&
178 ! git merge fourth &&
179 sha1=$(sed -e "s/ .*//" .git/rr-cache/MERGE_RR) &&
180 rr=.git/rr-cache/$sha1 &&
181 echo Cello > file2 &&
182 git add file2 &&
183 git commit -m resolution
186 test_expect_success 'resolution was recorded properly' '
187 git reset --hard HEAD~2 &&
188 git checkout -b fifth &&
189 echo Hallo > file3 &&
190 git add file3 &&
191 git commit -m version1 &&
192 git checkout third &&
193 echo Bello > file3 &&
194 git add file3 &&
195 git commit -m version2 &&
196 ! git merge fifth &&
197 git diff-files -q &&
198 test Cello = "$(cat file3)"
201 test_done