Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Johannes E. Schindelin |
| 4 | # |
| 5 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 6 | test_description='git rerere |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 7 | |
| 8 | ! [fifth] version1 |
| 9 | ! [first] first |
| 10 | ! [fourth] version1 |
| 11 | ! [master] initial |
| 12 | ! [second] prefer first over second |
| 13 | ! [third] version2 |
| 14 | ------ |
| 15 | + [third] version2 |
| 16 | + [fifth] version1 |
| 17 | + [fourth] version1 |
| 18 | + + + [third^] third |
| 19 | - [second] prefer first over second |
| 20 | + + [first] first |
| 21 | + [second^] second |
| 22 | ++++++ [master] initial |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 23 | ' |
| 24 | |
| 25 | . ./test-lib.sh |
| 26 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 27 | test_expect_success 'setup' ' |
| 28 | cat >a1 <<-\EOF && |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 29 | Some title |
| 30 | ========== |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 31 | Whether '\''tis nobler in the mind to suffer |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 32 | The slings and arrows of outrageous fortune, |
| 33 | Or to take arms against a sea of troubles, |
| 34 | And by opposing end them? To die: to sleep; |
| 35 | No more; and by a sleep to say we end |
| 36 | The heart-ache and the thousand natural shocks |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 37 | That flesh is heir to, '\''tis a consummation |
| 38 | Devoutly to be wish'\''d. |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 39 | EOF |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 40 | |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 41 | git add a1 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 42 | test_tick && |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 43 | git commit -q -a -m initial && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 44 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 45 | cat >>a1 <<-\EOF && |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 46 | Some title |
| 47 | ========== |
| 48 | To die, to sleep; |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 49 | To sleep: perchance to dream: ay, there'\''s the rub; |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 50 | For in that sleep of death what dreams may come |
| 51 | When we have shuffled off this mortal coil, |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 52 | Must give us pause: there'\''s the respect |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 53 | That makes calamity of so long life; |
| 54 | EOF |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 55 | |
| 56 | git checkout -b first && |
| 57 | test_tick && |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 58 | git commit -q -a -m first && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 59 | |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 60 | git checkout -b second master && |
| 61 | git show first:a1 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 62 | sed -e "s/To die, t/To die! T/" -e "s/Some title/Some Title/" >a1 && |
| 63 | echo "* END *" >>a1 && |
| 64 | test_tick && |
Brian Gernhardt | 4a45f7d | 2010-03-20 04:29:11 -0400 | [diff] [blame] | 65 | git commit -q -a -m second |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 66 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 67 | |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 68 | test_expect_success 'nothing recorded without rerere' ' |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 69 | rm -rf .git/rr-cache && |
| 70 | git config rerere.enabled false && |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 71 | test_must_fail git merge first && |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 72 | ! test -d .git/rr-cache |
| 73 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 74 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 75 | test_expect_success 'activate rerere, old style (conflicting merge)' ' |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 76 | git reset --hard && |
| 77 | mkdir .git/rr-cache && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 78 | test_might_fail git config --unset rerere.enabled && |
| 79 | test_must_fail git merge first && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 80 | |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 81 | sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 82 | rr=.git/rr-cache/$sha1 && |
| 83 | grep "^=======\$" $rr/preimage && |
| 84 | ! test -f $rr/postimage && |
| 85 | ! test -f $rr/thisimage |
| 86 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 87 | |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 88 | test_expect_success 'rerere.enabled works, too' ' |
| 89 | rm -rf .git/rr-cache && |
| 90 | git config rerere.enabled true && |
| 91 | git reset --hard && |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 92 | test_must_fail git merge first && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 93 | |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 94 | sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 95 | rr=.git/rr-cache/$sha1 && |
Olivier Marin | 99d698f | 2008-07-07 14:42:48 +0200 | [diff] [blame] | 96 | grep ^=======$ $rr/preimage |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 97 | ' |
| 98 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 99 | test_expect_success 'set up rr-cache' ' |
| 100 | rm -rf .git/rr-cache && |
| 101 | git config rerere.enabled true && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 102 | git reset --hard && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 103 | test_must_fail git merge first && |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 104 | sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 105 | rr=.git/rr-cache/$sha1 |
| 106 | ' |
Junio C Hamano | eb33596 | 2007-04-03 16:28:46 -0700 | [diff] [blame] | 107 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 108 | test_expect_success 'rr-cache looks sane' ' |
| 109 | # no postimage or thisimage yet |
| 110 | ! test -f $rr/postimage && |
| 111 | ! test -f $rr/thisimage && |
Junio C Hamano | eb33596 | 2007-04-03 16:28:46 -0700 | [diff] [blame] | 112 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 113 | # preimage has right number of lines |
Junio C Hamano | eb33596 | 2007-04-03 16:28:46 -0700 | [diff] [blame] | 114 | cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 115 | echo $cnt && |
Junio C Hamano | eb33596 | 2007-04-03 16:28:46 -0700 | [diff] [blame] | 116 | test $cnt = 13 |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 117 | ' |
| 118 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 119 | test_expect_success 'rerere diff' ' |
| 120 | git show first:a1 >a1 && |
| 121 | cat >expect <<-\EOF && |
| 122 | --- a/a1 |
| 123 | +++ b/a1 |
| 124 | @@ -1,4 +1,4 @@ |
| 125 | -Some Title |
| 126 | +Some title |
| 127 | ========== |
| 128 | Whether '\''tis nobler in the mind to suffer |
| 129 | The slings and arrows of outrageous fortune, |
| 130 | @@ -8,21 +8,11 @@ |
| 131 | The heart-ache and the thousand natural shocks |
| 132 | That flesh is heir to, '\''tis a consummation |
| 133 | Devoutly to be wish'\''d. |
| 134 | -<<<<<<< |
| 135 | -Some Title |
| 136 | -========== |
| 137 | -To die! To sleep; |
| 138 | -======= |
| 139 | Some title |
| 140 | ========== |
| 141 | To die, to sleep; |
| 142 | ->>>>>>> |
| 143 | To sleep: perchance to dream: ay, there'\''s the rub; |
| 144 | For in that sleep of death what dreams may come |
| 145 | When we have shuffled off this mortal coil, |
| 146 | Must give us pause: there'\''s the respect |
| 147 | That makes calamity of so long life; |
| 148 | -<<<<<<< |
| 149 | -======= |
| 150 | -* END * |
| 151 | ->>>>>>> |
| 152 | EOF |
| 153 | git rerere diff >out && |
| 154 | test_cmp expect out |
| 155 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 156 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 157 | test_expect_success 'rerere status' ' |
| 158 | echo a1 >expect && |
| 159 | git rerere status >out && |
| 160 | test_cmp expect out |
| 161 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 162 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 163 | test_expect_success 'first postimage wins' ' |
| 164 | git show first:a1 | sed "s/To die: t/To die! T/" >expect && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 165 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 166 | git commit -q -a -m "prefer first over second" && |
| 167 | test -f $rr/postimage && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 168 | |
Junio C Hamano | 8aed4a5 | 2010-09-03 09:43:41 -0700 | [diff] [blame] | 169 | oldmtimepost=$(test-chmtime -v -60 $rr/postimage | cut -f 1) && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 170 | |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 171 | git checkout -b third master && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 172 | git show second^:a1 | sed "s/To die: t/To die! T/" >a1 && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 173 | git commit -q -a -m third && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 174 | |
Felipe Contreras | 501a75a | 2013-10-31 03:25:33 -0600 | [diff] [blame] | 175 | test_must_fail git merge first && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 176 | # rerere kicked in |
| 177 | ! grep "^=======\$" a1 && |
| 178 | test_cmp expect a1 |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 179 | ' |
| 180 | |
SZEDER Gábor | 7d7ff15 | 2010-07-13 01:42:04 +0200 | [diff] [blame] | 181 | test_expect_success 'rerere updates postimage timestamp' ' |
Junio C Hamano | 8aed4a5 | 2010-09-03 09:43:41 -0700 | [diff] [blame] | 182 | newmtimepost=$(test-chmtime -v +0 $rr/postimage | cut -f 1) && |
SZEDER Gábor | 7d7ff15 | 2010-07-13 01:42:04 +0200 | [diff] [blame] | 183 | test $oldmtimepost -lt $newmtimepost |
| 184 | ' |
| 185 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 186 | test_expect_success 'rerere clear' ' |
| 187 | rm $rr/postimage && |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 188 | echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 189 | git rerere clear && |
| 190 | ! test -d $rr |
| 191 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 192 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 193 | test_expect_success 'set up for garbage collection tests' ' |
| 194 | mkdir -p $rr && |
| 195 | echo Hello >$rr/preimage && |
| 196 | echo World >$rr/postimage && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 197 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 198 | sha2=4000000000000000000000000000000000000000 && |
| 199 | rr2=.git/rr-cache/$sha2 && |
| 200 | mkdir $rr2 && |
| 201 | echo Hello >$rr2/preimage && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 202 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 203 | almost_15_days_ago=$((60-15*86400)) && |
| 204 | just_over_15_days_ago=$((-1-15*86400)) && |
| 205 | almost_60_days_ago=$((60-60*86400)) && |
| 206 | just_over_60_days_ago=$((-1-60*86400)) && |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 207 | |
Junio C Hamano | 8aed4a5 | 2010-09-03 09:43:41 -0700 | [diff] [blame] | 208 | test-chmtime =$just_over_60_days_ago $rr/preimage && |
| 209 | test-chmtime =$almost_60_days_ago $rr/postimage && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 210 | test-chmtime =$almost_15_days_ago $rr2/preimage |
| 211 | ' |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 212 | |
Junio C Hamano | 8aed4a5 | 2010-09-03 09:43:41 -0700 | [diff] [blame] | 213 | test_expect_success 'gc preserves young or recently used records' ' |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 214 | git rerere gc && |
| 215 | test -f $rr/preimage && |
| 216 | test -f $rr2/preimage |
| 217 | ' |
Junio C Hamano | fa1b4d2 | 2007-02-07 10:42:08 -0800 | [diff] [blame] | 218 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 219 | test_expect_success 'old records rest in peace' ' |
Junio C Hamano | 8aed4a5 | 2010-09-03 09:43:41 -0700 | [diff] [blame] | 220 | test-chmtime =$just_over_60_days_ago $rr/postimage && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 221 | test-chmtime =$just_over_15_days_ago $rr2/preimage && |
| 222 | git rerere gc && |
| 223 | ! test -f $rr/preimage && |
| 224 | ! test -f $rr2/preimage |
| 225 | ' |
Junio C Hamano | fa1b4d2 | 2007-02-07 10:42:08 -0800 | [diff] [blame] | 226 | |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 227 | test_expect_success 'setup: file2 added differently in two branches' ' |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 228 | git reset --hard && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 229 | |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 230 | git checkout -b fourth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 231 | echo Hallo >file2 && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 232 | git add file2 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 233 | test_tick && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 234 | git commit -m version1 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 235 | |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 236 | git checkout third && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 237 | echo Bello >file2 && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 238 | git add file2 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 239 | test_tick && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 240 | git commit -m version2 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 241 | |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 242 | test_must_fail git merge fourth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 243 | echo Cello >file2 && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 244 | git add file2 && |
| 245 | git commit -m resolution |
| 246 | ' |
| 247 | |
| 248 | test_expect_success 'resolution was recorded properly' ' |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 249 | echo Cello >expected && |
| 250 | |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 251 | git reset --hard HEAD~2 && |
| 252 | git checkout -b fifth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 253 | |
| 254 | echo Hallo >file3 && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 255 | git add file3 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 256 | test_tick && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 257 | git commit -m version1 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 258 | |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 259 | git checkout third && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 260 | echo Bello >file3 && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 261 | git add file3 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 262 | test_tick && |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 263 | git commit -m version2 && |
Junio C Hamano | 121c813 | 2008-06-22 02:04:31 -0700 | [diff] [blame] | 264 | git tag version2 && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 265 | |
Junio C Hamano | 7f8365f | 2008-06-22 02:03:26 -0700 | [diff] [blame] | 266 | test_must_fail git merge fifth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 267 | test_cmp expected file3 && |
| 268 | test_must_fail git update-index --refresh |
Johannes Schindelin | 52aaf64 | 2007-07-09 14:47:24 +0100 | [diff] [blame] | 269 | ' |
| 270 | |
Junio C Hamano | 121c813 | 2008-06-22 02:04:31 -0700 | [diff] [blame] | 271 | test_expect_success 'rerere.autoupdate' ' |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 272 | git config rerere.autoupdate true && |
Junio C Hamano | 121c813 | 2008-06-22 02:04:31 -0700 | [diff] [blame] | 273 | git reset --hard && |
| 274 | git checkout version2 && |
| 275 | test_must_fail git merge fifth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 276 | git update-index --refresh |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 277 | ' |
Junio C Hamano | 121c813 | 2008-06-22 02:04:31 -0700 | [diff] [blame] | 278 | |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 279 | test_expect_success 'merge --rerere-autoupdate' ' |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 280 | test_might_fail git config --unset rerere.autoupdate && |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 281 | git reset --hard && |
| 282 | git checkout version2 && |
| 283 | test_must_fail git merge --rerere-autoupdate fifth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 284 | git update-index --refresh |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 285 | ' |
| 286 | |
| 287 | test_expect_success 'merge --no-rerere-autoupdate' ' |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 288 | headblob=$(git rev-parse version2:file3) && |
| 289 | mergeblob=$(git rev-parse fifth:file3) && |
| 290 | cat >expected <<-EOF && |
| 291 | 100644 $headblob 2 file3 |
| 292 | 100644 $mergeblob 3 file3 |
| 293 | EOF |
| 294 | |
| 295 | git config rerere.autoupdate true && |
Junio C Hamano | cb6020b | 2009-12-04 00:20:48 -0800 | [diff] [blame] | 296 | git reset --hard && |
| 297 | git checkout version2 && |
| 298 | test_must_fail git merge --no-rerere-autoupdate fifth && |
Jonathan Nieder | f731488 | 2010-08-05 06:25:34 -0500 | [diff] [blame] | 299 | git ls-files -u >actual && |
| 300 | test_cmp expected actual |
Junio C Hamano | 121c813 | 2008-06-22 02:04:31 -0700 | [diff] [blame] | 301 | ' |
| 302 | |
Jonathan Nieder | 672d1b7 | 2010-08-05 06:28:37 -0500 | [diff] [blame] | 303 | test_expect_success 'set up an unresolved merge' ' |
| 304 | headblob=$(git rev-parse version2:file3) && |
| 305 | mergeblob=$(git rev-parse fifth:file3) && |
| 306 | cat >expected.unresolved <<-EOF && |
| 307 | 100644 $headblob 2 file3 |
| 308 | 100644 $mergeblob 3 file3 |
| 309 | EOF |
| 310 | |
| 311 | test_might_fail git config --unset rerere.autoupdate && |
| 312 | git reset --hard && |
| 313 | git checkout version2 && |
| 314 | fifth=$(git rev-parse fifth) && |
| 315 | echo "$fifth branch 'fifth' of ." | |
| 316 | git fmt-merge-msg >msg && |
| 317 | ancestor=$(git merge-base version2 fifth) && |
| 318 | test_must_fail git merge-recursive "$ancestor" -- HEAD fifth && |
| 319 | |
| 320 | git ls-files --stage >failedmerge && |
| 321 | cp file3 file3.conflict && |
| 322 | |
| 323 | git ls-files -u >actual && |
| 324 | test_cmp expected.unresolved actual |
| 325 | ' |
| 326 | |
| 327 | test_expect_success 'explicit rerere' ' |
| 328 | test_might_fail git config --unset rerere.autoupdate && |
| 329 | git rm -fr --cached . && |
| 330 | git update-index --index-info <failedmerge && |
| 331 | cp file3.conflict file3 && |
| 332 | test_must_fail git update-index --refresh -q && |
| 333 | |
| 334 | git rerere && |
| 335 | git ls-files -u >actual && |
| 336 | test_cmp expected.unresolved actual |
| 337 | ' |
| 338 | |
| 339 | test_expect_success 'explicit rerere with autoupdate' ' |
| 340 | git config rerere.autoupdate true && |
| 341 | git rm -fr --cached . && |
| 342 | git update-index --index-info <failedmerge && |
| 343 | cp file3.conflict file3 && |
| 344 | test_must_fail git update-index --refresh -q && |
| 345 | |
| 346 | git rerere && |
| 347 | git update-index --refresh |
| 348 | ' |
| 349 | |
| 350 | test_expect_success 'explicit rerere --rerere-autoupdate overrides' ' |
| 351 | git config rerere.autoupdate false && |
| 352 | git rm -fr --cached . && |
| 353 | git update-index --index-info <failedmerge && |
| 354 | cp file3.conflict file3 && |
| 355 | git rerere && |
| 356 | git ls-files -u >actual1 && |
| 357 | |
| 358 | git rm -fr --cached . && |
| 359 | git update-index --index-info <failedmerge && |
| 360 | cp file3.conflict file3 && |
| 361 | git rerere --rerere-autoupdate && |
| 362 | git update-index --refresh && |
| 363 | |
| 364 | git rm -fr --cached . && |
| 365 | git update-index --index-info <failedmerge && |
| 366 | cp file3.conflict file3 && |
| 367 | git rerere --rerere-autoupdate --no-rerere-autoupdate && |
| 368 | git ls-files -u >actual2 && |
| 369 | |
| 370 | git rm -fr --cached . && |
| 371 | git update-index --index-info <failedmerge && |
| 372 | cp file3.conflict file3 && |
| 373 | git rerere --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate && |
| 374 | git update-index --refresh && |
| 375 | |
| 376 | test_cmp expected.unresolved actual1 && |
| 377 | test_cmp expected.unresolved actual2 |
| 378 | ' |
| 379 | |
| 380 | test_expect_success 'rerere --no-no-rerere-autoupdate' ' |
| 381 | git rm -fr --cached . && |
| 382 | git update-index --index-info <failedmerge && |
| 383 | cp file3.conflict file3 && |
| 384 | test_must_fail git rerere --no-no-rerere-autoupdate 2>err && |
Jiang Xin | 9a00138 | 2012-08-27 13:36:55 +0800 | [diff] [blame] | 385 | test_i18ngrep [Uu]sage err && |
Jonathan Nieder | 672d1b7 | 2010-08-05 06:28:37 -0500 | [diff] [blame] | 386 | test_must_fail git update-index --refresh |
| 387 | ' |
| 388 | |
| 389 | test_expect_success 'rerere -h' ' |
| 390 | test_must_fail git rerere -h >help && |
Jiang Xin | 9a00138 | 2012-08-27 13:36:55 +0800 | [diff] [blame] | 391 | test_i18ngrep [Uu]sage help |
Johannes Schindelin | ad8e72c | 2006-12-21 10:21:28 +0100 | [diff] [blame] | 392 | ' |
| 393 | |
| 394 | test_done |