]>
Commit | Line | Data |
---|---|---|
6de08ae6 SP |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Shawn Pearce | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='Test git update-ref and basic ref logging' |
6de08ae6 SP |
7 | . ./test-lib.sh |
8 | ||
8125a58b | 9 | Z=$ZERO_OID |
c3b0dec5 | 10 | |
b1421a43 CW |
11 | m=refs/heads/master |
12 | n_dir=refs/heads/gu | |
13 | n=$n_dir/fixes | |
14 | outside=refs/foo | |
15 | bare=bare-repo | |
c3b0dec5 | 16 | |
b1421a43 CW |
17 | create_test_commits () |
18 | { | |
19 | prfx="$1" | |
c3b0dec5 LT |
20 | for name in A B C D E F |
21 | do | |
22 | test_tick && | |
23 | T=$(git write-tree) && | |
24 | sha1=$(echo $name | git commit-tree $T) && | |
b1421a43 | 25 | eval $prfx$name=$sha1 |
c3b0dec5 | 26 | done |
b1421a43 | 27 | } |
c3b0dec5 | 28 | |
b1421a43 CW |
29 | test_expect_success setup ' |
30 | create_test_commits "" && | |
31 | mkdir $bare && | |
32 | cd $bare && | |
33 | git init --bare && | |
34 | create_test_commits "bare" && | |
35 | cd - | |
c3b0dec5 LT |
36 | ' |
37 | ||
1cec9c2d KM |
38 | test_expect_success "create $m" ' |
39 | git update-ref $m $A && | |
40 | test $A = $(cat .git/$m) | |
41 | ' | |
42 | test_expect_success "create $m with oldvalue verification" ' | |
43 | git update-ref $m $B $A && | |
44 | test $B = $(cat .git/$m) | |
45 | ' | |
40672a19 KW |
46 | test_expect_success "fail to delete $m with stale ref" ' |
47 | test_must_fail git update-ref -d $m $A && | |
48 | test $B = "$(cat .git/$m)" | |
49 | ' | |
50 | test_expect_success "delete $m" ' | |
2405ed07 | 51 | test_when_finished "rm -f .git/$m" && |
40672a19 | 52 | git update-ref -d $m $B && |
cd81af4b | 53 | test_path_is_missing .git/$m |
40672a19 | 54 | ' |
6de08ae6 | 55 | |
2405ed07 KM |
56 | test_expect_success "delete $m without oldvalue verification" ' |
57 | test_when_finished "rm -f .git/$m" && | |
3fe8dce6 | 58 | git update-ref $m $A && |
2405ed07 | 59 | test $A = $(cat .git/$m) && |
3fe8dce6 | 60 | git update-ref -d $m && |
cd81af4b | 61 | test_path_is_missing .git/$m |
2405ed07 | 62 | ' |
3fe8dce6 | 63 | |
2405ed07 KM |
64 | test_expect_success "fail to create $n" ' |
65 | test_when_finished "rm -f .git/$n_dir" && | |
66 | touch .git/$n_dir && | |
67 | test_must_fail git update-ref $n $A | |
68 | ' | |
818f477c | 69 | |
1cec9c2d KM |
70 | test_expect_success "create $m (by HEAD)" ' |
71 | git update-ref HEAD $A && | |
72 | test $A = $(cat .git/$m) | |
73 | ' | |
74 | test_expect_success "create $m (by HEAD) with oldvalue verification" ' | |
75 | git update-ref HEAD $B $A && | |
76 | test $B = $(cat .git/$m) | |
77 | ' | |
40672a19 KW |
78 | test_expect_success "fail to delete $m (by HEAD) with stale ref" ' |
79 | test_must_fail git update-ref -d HEAD $A && | |
80 | test $B = $(cat .git/$m) | |
81 | ' | |
82 | test_expect_success "delete $m (by HEAD)" ' | |
2405ed07 | 83 | test_when_finished "rm -f .git/$m" && |
40672a19 | 84 | git update-ref -d HEAD $B && |
cd81af4b | 85 | test_path_is_missing .git/$m |
40672a19 | 86 | ' |
6de08ae6 | 87 | |
de922669 | 88 | test_expect_success "deleting current branch adds message to HEAD's log" ' |
2405ed07 | 89 | test_when_finished "rm -f .git/$m" && |
de922669 KM |
90 | git update-ref $m $A && |
91 | git symbolic-ref HEAD $m && | |
92 | git update-ref -m delete-$m -d $m && | |
cd81af4b | 93 | test_path_is_missing .git/$m && |
de922669 KM |
94 | grep "delete-$m$" .git/logs/HEAD |
95 | ' | |
de922669 KM |
96 | |
97 | test_expect_success "deleting by HEAD adds message to HEAD's log" ' | |
2405ed07 | 98 | test_when_finished "rm -f .git/$m" && |
de922669 KM |
99 | git update-ref $m $A && |
100 | git symbolic-ref HEAD $m && | |
101 | git update-ref -m delete-by-head -d HEAD && | |
cd81af4b | 102 | test_path_is_missing .git/$m && |
de922669 KM |
103 | grep "delete-by-head$" .git/logs/HEAD |
104 | ' | |
de922669 | 105 | |
144c76fa DT |
106 | test_expect_success 'update-ref does not create reflogs by default' ' |
107 | test_when_finished "git update-ref -d $outside" && | |
108 | git update-ref $outside $A && | |
109 | git rev-parse $A >expect && | |
110 | git rev-parse $outside >actual && | |
111 | test_cmp expect actual && | |
112 | test_must_fail git reflog exists $outside | |
113 | ' | |
114 | ||
115 | test_expect_success 'update-ref creates reflogs with --create-reflog' ' | |
116 | test_when_finished "git update-ref -d $outside" && | |
117 | git update-ref --create-reflog $outside $A && | |
118 | git rev-parse $A >expect && | |
119 | git rev-parse $outside >actual && | |
120 | test_cmp expect actual && | |
121 | git reflog exists $outside | |
122 | ' | |
123 | ||
b1421a43 CW |
124 | test_expect_success 'creates no reflog in bare repository' ' |
125 | git -C $bare update-ref $m $bareA && | |
126 | git -C $bare rev-parse $bareA >expect && | |
127 | git -C $bare rev-parse $m >actual && | |
128 | test_cmp expect actual && | |
129 | test_must_fail git -C $bare reflog exists $m | |
130 | ' | |
131 | ||
132 | test_expect_success 'core.logAllRefUpdates=true creates reflog in bare repository' ' | |
133 | test_when_finished "git -C $bare config --unset core.logAllRefUpdates && \ | |
134 | rm $bare/logs/$m" && | |
135 | git -C $bare config core.logAllRefUpdates true && | |
136 | git -C $bare update-ref $m $bareB && | |
137 | git -C $bare rev-parse $bareB >expect && | |
138 | git -C $bare rev-parse $m >actual && | |
139 | test_cmp expect actual && | |
140 | git -C $bare reflog exists $m | |
141 | ' | |
142 | ||
341fb286 CW |
143 | test_expect_success 'core.logAllRefUpdates=true does not create reflog by default' ' |
144 | test_config core.logAllRefUpdates true && | |
145 | test_when_finished "git update-ref -d $outside" && | |
146 | git update-ref $outside $A && | |
147 | git rev-parse $A >expect && | |
148 | git rev-parse $outside >actual && | |
149 | test_cmp expect actual && | |
150 | test_must_fail git reflog exists $outside | |
151 | ' | |
152 | ||
153 | test_expect_success 'core.logAllRefUpdates=always creates reflog by default' ' | |
154 | test_config core.logAllRefUpdates always && | |
155 | test_when_finished "git update-ref -d $outside" && | |
156 | git update-ref $outside $A && | |
157 | git rev-parse $A >expect && | |
158 | git rev-parse $outside >actual && | |
159 | test_cmp expect actual && | |
160 | git reflog exists $outside | |
161 | ' | |
162 | ||
163 | test_expect_success 'core.logAllRefUpdates=always creates no reflog for ORIG_HEAD' ' | |
164 | test_config core.logAllRefUpdates always && | |
165 | git update-ref ORIG_HEAD $A && | |
166 | test_must_fail git reflog exists ORIG_HEAD | |
167 | ' | |
168 | ||
169 | test_expect_success '--no-create-reflog overrides core.logAllRefUpdates=always' ' | |
170 | test_config core.logAllRefUpdates true && | |
171 | test_when_finished "git update-ref -d $outside" && | |
172 | git update-ref --no-create-reflog $outside $A && | |
173 | git rev-parse $A >expect && | |
174 | git rev-parse $outside >actual && | |
175 | test_cmp expect actual && | |
176 | test_must_fail git reflog exists $outside | |
177 | ' | |
178 | ||
1cec9c2d KM |
179 | test_expect_success "create $m (by HEAD)" ' |
180 | git update-ref HEAD $A && | |
181 | test $A = $(cat .git/$m) | |
182 | ' | |
183 | test_expect_success 'pack refs' ' | |
184 | git pack-refs --all | |
185 | ' | |
186 | test_expect_success "move $m (by HEAD)" ' | |
187 | git update-ref HEAD $B $A && | |
188 | test $B = $(cat .git/$m) | |
189 | ' | |
b274a714 | 190 | test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" ' |
2405ed07 | 191 | test_when_finished "rm -f .git/$m" && |
75c96e05 JH |
192 | git update-ref -d HEAD $B && |
193 | ! grep "$m" .git/packed-refs && | |
cd81af4b | 194 | test_path_is_missing .git/$m |
75c96e05 | 195 | ' |
75c96e05 | 196 | |
569740bd | 197 | cp -f .git/HEAD .git/HEAD.orig |
1cec9c2d | 198 | test_expect_success 'delete symref without dereference' ' |
2405ed07 | 199 | test_when_finished "cp -f .git/HEAD.orig .git/HEAD" && |
569740bd | 200 | git update-ref --no-deref -d HEAD && |
cd81af4b | 201 | test_path_is_missing .git/HEAD |
569740bd | 202 | ' |
569740bd | 203 | |
1cec9c2d | 204 | test_expect_success 'delete symref without dereference when the referred ref is packed' ' |
2405ed07 | 205 | test_when_finished "cp -f .git/HEAD.orig .git/HEAD" && |
045a476f MV |
206 | echo foo >foo.c && |
207 | git add foo.c && | |
208 | git commit -m foo && | |
209 | git pack-refs --all && | |
210 | git update-ref --no-deref -d HEAD && | |
cd81af4b | 211 | test_path_is_missing .git/HEAD |
045a476f | 212 | ' |
2405ed07 | 213 | |
045a476f MV |
214 | git update-ref -d $m |
215 | ||
62a2d525 JN |
216 | test_expect_success 'update-ref -d is not confused by self-reference' ' |
217 | git symbolic-ref refs/heads/self refs/heads/self && | |
218 | test_when_finished "rm -f .git/refs/heads/self" && | |
219 | test_path_is_file .git/refs/heads/self && | |
220 | test_must_fail git update-ref -d refs/heads/self && | |
221 | test_path_is_file .git/refs/heads/self | |
222 | ' | |
223 | ||
224 | test_expect_success 'update-ref --no-deref -d can delete self-reference' ' | |
225 | git symbolic-ref refs/heads/self refs/heads/self && | |
226 | test_when_finished "rm -f .git/refs/heads/self" && | |
227 | test_path_is_file .git/refs/heads/self && | |
228 | git update-ref --no-deref -d refs/heads/self && | |
229 | test_path_is_missing .git/refs/heads/self | |
230 | ' | |
231 | ||
232 | test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' ' | |
233 | >.git/refs/heads/bad && | |
234 | test_when_finished "rm -f .git/refs/heads/bad" && | |
235 | git symbolic-ref refs/heads/ref-to-bad refs/heads/bad && | |
236 | test_when_finished "rm -f .git/refs/heads/ref-to-bad" && | |
237 | test_path_is_file .git/refs/heads/ref-to-bad && | |
238 | git update-ref --no-deref -d refs/heads/ref-to-bad && | |
239 | test_path_is_missing .git/refs/heads/ref-to-bad | |
240 | ' | |
241 | ||
1cec9c2d | 242 | test_expect_success '(not) create HEAD with old sha1' ' |
d492b31c | 243 | test_must_fail git update-ref HEAD $A $B |
1cec9c2d | 244 | ' |
2405ed07 KM |
245 | test_expect_success "(not) prior created .git/$m" ' |
246 | test_when_finished "rm -f .git/$m" && | |
cd81af4b | 247 | test_path_is_missing .git/$m |
2405ed07 | 248 | ' |
6de08ae6 | 249 | |
1cec9c2d KM |
250 | test_expect_success 'create HEAD' ' |
251 | git update-ref HEAD $A | |
252 | ' | |
253 | test_expect_success '(not) change HEAD with wrong SHA1' ' | |
d492b31c | 254 | test_must_fail git update-ref HEAD $B $Z |
1cec9c2d | 255 | ' |
2405ed07 KM |
256 | test_expect_success "(not) changed .git/$m" ' |
257 | test_when_finished "rm -f .git/$m" && | |
258 | ! test $B = $(cat .git/$m) | |
41ac414e | 259 | ' |
6de08ae6 | 260 | |
d0ab0584 | 261 | rm -f .git/logs/refs/heads/master |
1cec9c2d KM |
262 | test_expect_success "create $m (logged by touch)" ' |
263 | test_config core.logAllRefUpdates false && | |
264 | GIT_COMMITTER_DATE="2005-05-26 23:30" \ | |
265 | git update-ref --create-reflog HEAD $A -m "Initial Creation" && | |
266 | test $A = $(cat .git/$m) | |
267 | ' | |
268 | test_expect_success "update $m (logged by touch)" ' | |
269 | test_config core.logAllRefUpdates false && | |
270 | GIT_COMMITTER_DATE="2005-05-26 23:31" \ | |
271 | git update-ref HEAD $B $A -m "Switch" && | |
272 | test $B = $(cat .git/$m) | |
273 | ' | |
274 | test_expect_success "set $m (logged by touch)" ' | |
275 | test_config core.logAllRefUpdates false && | |
276 | GIT_COMMITTER_DATE="2005-05-26 23:41" \ | |
277 | git update-ref HEAD $A && | |
278 | test $A = $(cat .git/$m) | |
279 | ' | |
280 | ||
281 | test_expect_success 'empty directory removal' ' | |
44639777 MH |
282 | git branch d1/d2/r1 HEAD && |
283 | git branch d1/r2 HEAD && | |
cd81af4b KM |
284 | test_path_is_file .git/refs/heads/d1/d2/r1 && |
285 | test_path_is_file .git/logs/refs/heads/d1/d2/r1 && | |
44639777 | 286 | git branch -d d1/d2/r1 && |
cd81af4b KM |
287 | test_path_is_missing .git/refs/heads/d1/d2 && |
288 | test_path_is_missing .git/logs/refs/heads/d1/d2 && | |
289 | test_path_is_file .git/refs/heads/d1/r2 && | |
290 | test_path_is_file .git/logs/refs/heads/d1/r2 | |
44639777 MH |
291 | ' |
292 | ||
1cec9c2d | 293 | test_expect_success 'symref empty directory removal' ' |
44639777 MH |
294 | git branch e1/e2/r1 HEAD && |
295 | git branch e1/r2 HEAD && | |
296 | git checkout e1/e2/r1 && | |
297 | test_when_finished "git checkout master" && | |
cd81af4b KM |
298 | test_path_is_file .git/refs/heads/e1/e2/r1 && |
299 | test_path_is_file .git/logs/refs/heads/e1/e2/r1 && | |
44639777 | 300 | git update-ref -d HEAD && |
cd81af4b KM |
301 | test_path_is_missing .git/refs/heads/e1/e2 && |
302 | test_path_is_missing .git/logs/refs/heads/e1/e2 && | |
303 | test_path_is_file .git/refs/heads/e1/r2 && | |
304 | test_path_is_file .git/logs/refs/heads/e1/r2 && | |
305 | test_path_is_file .git/logs/HEAD | |
44639777 MH |
306 | ' |
307 | ||
6de08ae6 SP |
308 | cat >expect <<EOF |
309 | $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation | |
310 | $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch | |
311 | $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 | |
312 | EOF | |
2405ed07 KM |
313 | test_expect_success "verifying $m's log (logged by touch)" ' |
314 | test_when_finished "rm -rf .git/$m .git/logs expect" && | |
315 | test_cmp expect .git/logs/$m | |
316 | ' | |
6de08ae6 | 317 | |
1cec9c2d KM |
318 | test_expect_success "create $m (logged by config)" ' |
319 | test_config core.logAllRefUpdates true && | |
320 | GIT_COMMITTER_DATE="2005-05-26 23:32" \ | |
321 | git update-ref HEAD $A -m "Initial Creation" && | |
322 | test $A = $(cat .git/$m) | |
323 | ' | |
324 | test_expect_success "update $m (logged by config)" ' | |
325 | test_config core.logAllRefUpdates true && | |
326 | GIT_COMMITTER_DATE="2005-05-26 23:33" \ | |
327 | git update-ref HEAD'" $B $A "'-m "Switch" && | |
328 | test $B = $(cat .git/$m) | |
329 | ' | |
330 | test_expect_success "set $m (logged by config)" ' | |
331 | test_config core.logAllRefUpdates true && | |
332 | GIT_COMMITTER_DATE="2005-05-26 23:43" \ | |
333 | git update-ref HEAD $A && | |
334 | test $A = $(cat .git/$m) | |
335 | ' | |
6de08ae6 SP |
336 | |
337 | cat >expect <<EOF | |
338 | $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation | |
339 | $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch | |
340 | $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000 | |
341 | EOF | |
1cec9c2d KM |
342 | test_expect_success "verifying $m's log (logged by config)" ' |
343 | test_when_finished "rm -f .git/$m .git/logs/$m expect" && | |
344 | test_cmp expect .git/logs/$m | |
345 | ' | |
6de08ae6 | 346 | |
3ce47211 JS |
347 | test_expect_success 'set up for querying the reflog' ' |
348 | git update-ref $m $D && | |
349 | cat >.git/logs/$m <<-EOF | |
350 | $Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500 | |
351 | $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500 | |
352 | $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500 | |
353 | $F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500 | |
354 | $Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500 | |
355 | EOF | |
356 | ' | |
e5229042 SP |
357 | |
358 | ed="Thu, 26 May 2005 18:32:00 -0500" | |
359 | gd="Thu, 26 May 2005 18:33:00 -0500" | |
360 | ld="Thu, 26 May 2005 18:43:00 -0500" | |
1cec9c2d KM |
361 | test_expect_success 'Query "master@{May 25 2005}" (before history)' ' |
362 | test_when_finished "rm -f o e" && | |
363 | git rev-parse --verify "master@{May 25 2005}" >o 2>e && | |
364 | test $C = $(cat o) && | |
365 | test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)" | |
366 | ' | |
367 | test_expect_success 'Query master@{2005-05-25} (before history)' ' | |
368 | test_when_finished "rm -f o e" && | |
369 | git rev-parse --verify master@{2005-05-25} >o 2>e && | |
370 | test $C = $(cat o) && | |
fc0503b0 | 371 | test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)" |
1cec9c2d KM |
372 | ' |
373 | test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' ' | |
374 | test_when_finished "rm -f o e" && | |
375 | git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && | |
376 | test $C = $(cat o) && | |
377 | test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)" | |
378 | ' | |
379 | test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' ' | |
380 | test_when_finished "rm -f o e" && | |
381 | git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && | |
382 | test $C = $(cat o) && | |
c93a5aae | 383 | test_must_be_empty e |
1cec9c2d KM |
384 | ' |
385 | test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' ' | |
386 | test_when_finished "rm -f o e" && | |
387 | git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e && | |
388 | test $A = $(cat o) && | |
c93a5aae | 389 | test_must_be_empty e |
1cec9c2d KM |
390 | ' |
391 | test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' ' | |
392 | test_when_finished "rm -f o e" && | |
393 | git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && | |
394 | test $B = $(cat o) && | |
661558f0 | 395 | test_i18ngrep -F "warning: log for ref $m has gap after $gd" e |
1cec9c2d KM |
396 | ' |
397 | test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' ' | |
398 | test_when_finished "rm -f o e" && | |
399 | git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && | |
400 | test $Z = $(cat o) && | |
c93a5aae | 401 | test_must_be_empty e |
1cec9c2d KM |
402 | ' |
403 | test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' ' | |
404 | test_when_finished "rm -f o e" && | |
405 | git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && | |
406 | test $E = $(cat o) && | |
c93a5aae | 407 | test_must_be_empty e |
1cec9c2d KM |
408 | ' |
409 | test_expect_success 'Query "master@{2005-05-28}" (past end of history)' ' | |
410 | test_when_finished "rm -f o e" && | |
411 | git rev-parse --verify "master@{2005-05-28}" >o 2>e && | |
412 | test $D = $(cat o) && | |
661558f0 | 413 | test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e |
1cec9c2d | 414 | ' |
cce91a2c SP |
415 | |
416 | rm -f .git/$m .git/logs/$m expect | |
417 | ||
1cec9c2d KM |
418 | test_expect_success 'creating initial files' ' |
419 | test_when_finished rm -f M && | |
420 | echo TEST >F && | |
421 | git add F && | |
422 | GIT_AUTHOR_DATE="2005-05-26 23:30" \ | |
423 | GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a && | |
424 | h_TEST=$(git rev-parse --verify HEAD) && | |
425 | echo The other day this did not work. >M && | |
426 | echo And then Bob told me how to fix it. >>M && | |
427 | echo OTHER >F && | |
428 | GIT_AUTHOR_DATE="2005-05-26 23:41" \ | |
429 | GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a && | |
430 | h_OTHER=$(git rev-parse --verify HEAD) && | |
431 | GIT_AUTHOR_DATE="2005-05-26 23:44" \ | |
432 | GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend && | |
433 | h_FIXED=$(git rev-parse --verify HEAD) && | |
434 | echo Merged initial commit and a later commit. >M && | |
435 | echo $h_TEST >.git/MERGE_HEAD && | |
436 | GIT_AUTHOR_DATE="2005-05-26 23:45" \ | |
437 | GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M && | |
438 | h_MERGED=$(git rev-parse --verify HEAD) | |
439 | ' | |
9c7466fa SP |
440 | |
441 | cat >expect <<EOF | |
a3a733e6 | 442 | $Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add |
9c7466fa | 443 | $h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 commit: The other day this did not work. |
a3a733e6 SP |
444 | $h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 commit (amend): The other day this did not work. |
445 | $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit. | |
9c7466fa | 446 | EOF |
1cec9c2d KM |
447 | test_expect_success 'git commit logged updates' ' |
448 | test_cmp expect .git/logs/$m | |
449 | ' | |
a3a733e6 | 450 | unset h_TEST h_OTHER h_FIXED h_MERGED |
cce91a2c | 451 | |
1cec9c2d KM |
452 | test_expect_success 'git cat-file blob master:F (expect OTHER)' ' |
453 | test OTHER = $(git cat-file blob master:F) | |
454 | ' | |
455 | test_expect_success 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' ' | |
456 | test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F") | |
457 | ' | |
458 | test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' ' | |
459 | test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F") | |
460 | ' | |
cce91a2c | 461 | |
65eb8fc3 MÅ |
462 | # Test adding and deleting pseudorefs |
463 | ||
464 | test_expect_success 'given old value for missing pseudoref, do not create' ' | |
465 | test_must_fail git update-ref PSEUDOREF $A $B 2>err && | |
466 | test_path_is_missing .git/PSEUDOREF && | |
661558f0 | 467 | test_i18ngrep "could not read ref" err |
65eb8fc3 MÅ |
468 | ' |
469 | ||
470 | test_expect_success 'create pseudoref' ' | |
471 | git update-ref PSEUDOREF $A && | |
472 | test $A = $(cat .git/PSEUDOREF) | |
473 | ' | |
474 | ||
475 | test_expect_success 'overwrite pseudoref with no old value given' ' | |
476 | git update-ref PSEUDOREF $B && | |
477 | test $B = $(cat .git/PSEUDOREF) | |
478 | ' | |
479 | ||
480 | test_expect_success 'overwrite pseudoref with correct old value' ' | |
481 | git update-ref PSEUDOREF $C $B && | |
482 | test $C = $(cat .git/PSEUDOREF) | |
483 | ' | |
484 | ||
485 | test_expect_success 'do not overwrite pseudoref with wrong old value' ' | |
486 | test_must_fail git update-ref PSEUDOREF $D $E 2>err && | |
487 | test $C = $(cat .git/PSEUDOREF) && | |
661558f0 | 488 | test_i18ngrep "unexpected object ID" err |
65eb8fc3 MÅ |
489 | ' |
490 | ||
491 | test_expect_success 'delete pseudoref' ' | |
492 | git update-ref -d PSEUDOREF && | |
493 | test_path_is_missing .git/PSEUDOREF | |
494 | ' | |
495 | ||
496 | test_expect_success 'do not delete pseudoref with wrong old value' ' | |
497 | git update-ref PSEUDOREF $A && | |
498 | test_must_fail git update-ref -d PSEUDOREF $B 2>err && | |
499 | test $A = $(cat .git/PSEUDOREF) && | |
661558f0 | 500 | test_i18ngrep "unexpected object ID" err |
65eb8fc3 MÅ |
501 | ' |
502 | ||
503 | test_expect_success 'delete pseudoref with correct old value' ' | |
504 | git update-ref -d PSEUDOREF $A && | |
505 | test_path_is_missing .git/PSEUDOREF | |
506 | ' | |
507 | ||
db0210d4 | 508 | test_expect_success 'create pseudoref with old OID zero' ' |
65eb8fc3 MÅ |
509 | git update-ref PSEUDOREF $A $Z && |
510 | test $A = $(cat .git/PSEUDOREF) | |
511 | ' | |
512 | ||
db0210d4 | 513 | test_expect_success 'do not overwrite pseudoref with old OID zero' ' |
65eb8fc3 MÅ |
514 | test_when_finished git update-ref -d PSEUDOREF && |
515 | test_must_fail git update-ref PSEUDOREF $B $Z 2>err && | |
516 | test $A = $(cat .git/PSEUDOREF) && | |
661558f0 | 517 | test_i18ngrep "already exists" err |
65eb8fc3 MÅ |
518 | ' |
519 | ||
520 | # Test --stdin | |
521 | ||
c6268bc0 BK |
522 | a=refs/heads/a |
523 | b=refs/heads/b | |
524 | c=refs/heads/c | |
525 | E='""' | |
526 | F='%s\0' | |
527 | pws='path with space' | |
528 | ||
529 | test_expect_success 'stdin test setup' ' | |
530 | echo "$pws" >"$pws" && | |
531 | git add -- "$pws" && | |
532 | git commit -m "$pws" | |
533 | ' | |
534 | ||
535 | test_expect_success '-z fails without --stdin' ' | |
536 | test_must_fail git update-ref -z $m $m $m 2>err && | |
1edbaac3 | 537 | test_i18ngrep "usage: git update-ref" err |
c6268bc0 BK |
538 | ' |
539 | ||
540 | test_expect_success 'stdin works with no input' ' | |
541 | >stdin && | |
542 | git update-ref --stdin <stdin && | |
543 | git rev-parse --verify -q $m | |
544 | ' | |
545 | ||
546 | test_expect_success 'stdin fails on empty line' ' | |
547 | echo "" >stdin && | |
548 | test_must_fail git update-ref --stdin <stdin 2>err && | |
549 | grep "fatal: empty command in input" err | |
550 | ' | |
551 | ||
552 | test_expect_success 'stdin fails on only whitespace' ' | |
553 | echo " " >stdin && | |
554 | test_must_fail git update-ref --stdin <stdin 2>err && | |
555 | grep "fatal: whitespace before command: " err | |
556 | ' | |
557 | ||
558 | test_expect_success 'stdin fails on leading whitespace' ' | |
559 | echo " create $a $m" >stdin && | |
560 | test_must_fail git update-ref --stdin <stdin 2>err && | |
561 | grep "fatal: whitespace before command: create $a $m" err | |
562 | ' | |
563 | ||
564 | test_expect_success 'stdin fails on unknown command' ' | |
565 | echo "unknown $a" >stdin && | |
566 | test_must_fail git update-ref --stdin <stdin 2>err && | |
567 | grep "fatal: unknown command: unknown $a" err | |
568 | ' | |
569 | ||
20fcffcc | 570 | test_expect_success 'stdin fails on unbalanced quotes' ' |
c6268bc0 BK |
571 | echo "create $a \"master" >stdin && |
572 | test_must_fail git update-ref --stdin <stdin 2>err && | |
573 | grep "fatal: badly quoted argument: \\\"master" err | |
574 | ' | |
575 | ||
20fcffcc MH |
576 | test_expect_success 'stdin fails on invalid escape' ' |
577 | echo "create $a \"ma\zter\"" >stdin && | |
578 | test_must_fail git update-ref --stdin <stdin 2>err && | |
579 | grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err | |
580 | ' | |
581 | ||
697a4151 | 582 | test_expect_success 'stdin fails on junk after quoted argument' ' |
c6268bc0 BK |
583 | echo "create \"$a\"master" >stdin && |
584 | test_must_fail git update-ref --stdin <stdin 2>err && | |
697a4151 | 585 | grep "fatal: unexpected character after quoted argument: \\\"$a\\\"master" err |
c6268bc0 BK |
586 | ' |
587 | ||
588 | test_expect_success 'stdin fails create with no ref' ' | |
589 | echo "create " >stdin && | |
590 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 591 | grep "fatal: create: missing <ref>" err |
c6268bc0 BK |
592 | ' |
593 | ||
c6268bc0 BK |
594 | test_expect_success 'stdin fails create with no new value' ' |
595 | echo "create $a" >stdin && | |
596 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 597 | grep "fatal: create $a: missing <newvalue>" err |
c6268bc0 BK |
598 | ' |
599 | ||
600 | test_expect_success 'stdin fails create with too many arguments' ' | |
601 | echo "create $a $m $m" >stdin && | |
602 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 603 | grep "fatal: create $a: extra input: $m" err |
c6268bc0 BK |
604 | ' |
605 | ||
606 | test_expect_success 'stdin fails update with no ref' ' | |
607 | echo "update " >stdin && | |
608 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 609 | grep "fatal: update: missing <ref>" err |
c6268bc0 BK |
610 | ' |
611 | ||
c6268bc0 BK |
612 | test_expect_success 'stdin fails update with no new value' ' |
613 | echo "update $a" >stdin && | |
614 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 615 | grep "fatal: update $a: missing <newvalue>" err |
c6268bc0 BK |
616 | ' |
617 | ||
618 | test_expect_success 'stdin fails update with too many arguments' ' | |
619 | echo "update $a $m $m $m" >stdin && | |
620 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 621 | grep "fatal: update $a: extra input: $m" err |
c6268bc0 BK |
622 | ' |
623 | ||
624 | test_expect_success 'stdin fails delete with no ref' ' | |
625 | echo "delete " >stdin && | |
626 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 627 | grep "fatal: delete: missing <ref>" err |
c6268bc0 BK |
628 | ' |
629 | ||
c6268bc0 BK |
630 | test_expect_success 'stdin fails delete with too many arguments' ' |
631 | echo "delete $a $m $m" >stdin && | |
632 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 633 | grep "fatal: delete $a: extra input: $m" err |
c6268bc0 BK |
634 | ' |
635 | ||
636 | test_expect_success 'stdin fails verify with too many arguments' ' | |
637 | echo "verify $a $m $m" >stdin && | |
638 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 639 | grep "fatal: verify $a: extra input: $m" err |
c6268bc0 BK |
640 | ' |
641 | ||
642 | test_expect_success 'stdin fails option with unknown name' ' | |
643 | echo "option unknown" >stdin && | |
644 | test_must_fail git update-ref --stdin <stdin 2>err && | |
645 | grep "fatal: option unknown: unknown" err | |
646 | ' | |
647 | ||
648 | test_expect_success 'stdin fails with duplicate refs' ' | |
649 | cat >stdin <<-EOF && | |
650 | create $a $m | |
651 | create $b $m | |
652 | create $a $m | |
653 | EOF | |
654 | test_must_fail git update-ref --stdin <stdin 2>err && | |
661558f0 | 655 | test_i18ngrep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed" err |
c6268bc0 BK |
656 | ' |
657 | ||
658 | test_expect_success 'stdin create ref works' ' | |
659 | echo "create $a $m" >stdin && | |
660 | git update-ref --stdin <stdin && | |
661 | git rev-parse $m >expect && | |
662 | git rev-parse $a >actual && | |
663 | test_cmp expect actual | |
664 | ' | |
665 | ||
144c76fa DT |
666 | test_expect_success 'stdin does not create reflogs by default' ' |
667 | test_when_finished "git update-ref -d $outside" && | |
668 | echo "create $outside $m" >stdin && | |
669 | git update-ref --stdin <stdin && | |
670 | git rev-parse $m >expect && | |
671 | git rev-parse $outside >actual && | |
672 | test_cmp expect actual && | |
673 | test_must_fail git reflog exists $outside | |
674 | ' | |
675 | ||
676 | test_expect_success 'stdin creates reflogs with --create-reflog' ' | |
341fb286 | 677 | test_when_finished "git update-ref -d $outside" && |
144c76fa DT |
678 | echo "create $outside $m" >stdin && |
679 | git update-ref --create-reflog --stdin <stdin && | |
680 | git rev-parse $m >expect && | |
681 | git rev-parse $outside >actual && | |
682 | test_cmp expect actual && | |
683 | git reflog exists $outside | |
684 | ' | |
685 | ||
20fcffcc MH |
686 | test_expect_success 'stdin succeeds with quoted argument' ' |
687 | git update-ref -d $a && | |
688 | echo "create $a \"$m\"" >stdin && | |
689 | git update-ref --stdin <stdin && | |
690 | git rev-parse $m >expect && | |
691 | git rev-parse $a >actual && | |
692 | test_cmp expect actual | |
693 | ' | |
694 | ||
695 | test_expect_success 'stdin succeeds with escaped character' ' | |
696 | git update-ref -d $a && | |
697 | echo "create $a \"ma\\163ter\"" >stdin && | |
698 | git update-ref --stdin <stdin && | |
699 | git rev-parse $m >expect && | |
700 | git rev-parse $a >actual && | |
701 | test_cmp expect actual | |
702 | ' | |
703 | ||
c6268bc0 BK |
704 | test_expect_success 'stdin update ref creates with zero old value' ' |
705 | echo "update $b $m $Z" >stdin && | |
706 | git update-ref --stdin <stdin && | |
707 | git rev-parse $m >expect && | |
708 | git rev-parse $b >actual && | |
709 | test_cmp expect actual && | |
710 | git update-ref -d $b | |
711 | ' | |
712 | ||
713 | test_expect_success 'stdin update ref creates with empty old value' ' | |
714 | echo "update $b $m $E" >stdin && | |
715 | git update-ref --stdin <stdin && | |
716 | git rev-parse $m >expect && | |
717 | git rev-parse $b >actual && | |
718 | test_cmp expect actual | |
719 | ' | |
720 | ||
721 | test_expect_success 'stdin create ref works with path with space to blob' ' | |
722 | echo "create refs/blobs/pws \"$m:$pws\"" >stdin && | |
723 | git update-ref --stdin <stdin && | |
724 | git rev-parse "$m:$pws" >expect && | |
725 | git rev-parse refs/blobs/pws >actual && | |
726 | test_cmp expect actual && | |
727 | git update-ref -d refs/blobs/pws | |
728 | ' | |
729 | ||
730 | test_expect_success 'stdin update ref fails with wrong old value' ' | |
731 | echo "update $c $m $m~1" >stdin && | |
732 | test_must_fail git update-ref --stdin <stdin 2>err && | |
c2e0a718 | 733 | grep "fatal: cannot lock ref '"'"'$c'"'"'" err && |
c6268bc0 BK |
734 | test_must_fail git rev-parse --verify -q $c |
735 | ' | |
736 | ||
737 | test_expect_success 'stdin update ref fails with bad old value' ' | |
738 | echo "update $c $m does-not-exist" >stdin && | |
739 | test_must_fail git update-ref --stdin <stdin 2>err && | |
9255f059 | 740 | grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err && |
c6268bc0 BK |
741 | test_must_fail git rev-parse --verify -q $c |
742 | ' | |
743 | ||
744 | test_expect_success 'stdin create ref fails with bad new value' ' | |
745 | echo "create $c does-not-exist" >stdin && | |
746 | test_must_fail git update-ref --stdin <stdin 2>err && | |
9255f059 | 747 | grep "fatal: create $c: invalid <newvalue>: does-not-exist" err && |
c6268bc0 BK |
748 | test_must_fail git rev-parse --verify -q $c |
749 | ' | |
750 | ||
751 | test_expect_success 'stdin create ref fails with zero new value' ' | |
752 | echo "create $c " >stdin && | |
753 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 754 | grep "fatal: create $c: zero <newvalue>" err && |
c6268bc0 BK |
755 | test_must_fail git rev-parse --verify -q $c |
756 | ' | |
757 | ||
758 | test_expect_success 'stdin update ref works with right old value' ' | |
759 | echo "update $b $m~1 $m" >stdin && | |
760 | git update-ref --stdin <stdin && | |
761 | git rev-parse $m~1 >expect && | |
762 | git rev-parse $b >actual && | |
763 | test_cmp expect actual | |
764 | ' | |
765 | ||
766 | test_expect_success 'stdin delete ref fails with wrong old value' ' | |
767 | echo "delete $a $m~1" >stdin && | |
768 | test_must_fail git update-ref --stdin <stdin 2>err && | |
c2e0a718 | 769 | grep "fatal: cannot lock ref '"'"'$a'"'"'" err && |
c6268bc0 BK |
770 | git rev-parse $m >expect && |
771 | git rev-parse $a >actual && | |
772 | test_cmp expect actual | |
773 | ' | |
774 | ||
775 | test_expect_success 'stdin delete ref fails with zero old value' ' | |
776 | echo "delete $a " >stdin && | |
777 | test_must_fail git update-ref --stdin <stdin 2>err && | |
f11b09fb | 778 | grep "fatal: delete $a: zero <oldvalue>" err && |
c6268bc0 BK |
779 | git rev-parse $m >expect && |
780 | git rev-parse $a >actual && | |
781 | test_cmp expect actual | |
782 | ' | |
783 | ||
784 | test_expect_success 'stdin update symref works option no-deref' ' | |
785 | git symbolic-ref TESTSYMREF $b && | |
786 | cat >stdin <<-EOF && | |
787 | option no-deref | |
788 | update TESTSYMREF $a $b | |
789 | EOF | |
790 | git update-ref --stdin <stdin && | |
791 | git rev-parse TESTSYMREF >expect && | |
792 | git rev-parse $a >actual && | |
793 | test_cmp expect actual && | |
794 | git rev-parse $m~1 >expect && | |
795 | git rev-parse $b >actual && | |
796 | test_cmp expect actual | |
797 | ' | |
798 | ||
799 | test_expect_success 'stdin delete symref works option no-deref' ' | |
800 | git symbolic-ref TESTSYMREF $b && | |
801 | cat >stdin <<-EOF && | |
802 | option no-deref | |
803 | delete TESTSYMREF $b | |
804 | EOF | |
805 | git update-ref --stdin <stdin && | |
806 | test_must_fail git rev-parse --verify -q TESTSYMREF && | |
807 | git rev-parse $m~1 >expect && | |
808 | git rev-parse $b >actual && | |
809 | test_cmp expect actual | |
810 | ' | |
811 | ||
d345e9fb EN |
812 | test_expect_success 'stdin update symref works flag --no-deref' ' |
813 | git symbolic-ref TESTSYMREFONE $b && | |
814 | git symbolic-ref TESTSYMREFTWO $b && | |
815 | cat >stdin <<-EOF && | |
816 | update TESTSYMREFONE $a $b | |
817 | update TESTSYMREFTWO $a $b | |
818 | EOF | |
819 | git update-ref --no-deref --stdin <stdin && | |
820 | git rev-parse TESTSYMREFONE TESTSYMREFTWO >expect && | |
821 | git rev-parse $a $a >actual && | |
822 | test_cmp expect actual && | |
823 | git rev-parse $m~1 >expect && | |
824 | git rev-parse $b >actual && | |
825 | test_cmp expect actual | |
826 | ' | |
827 | ||
828 | test_expect_success 'stdin delete symref works flag --no-deref' ' | |
829 | git symbolic-ref TESTSYMREFONE $b && | |
830 | git symbolic-ref TESTSYMREFTWO $b && | |
831 | cat >stdin <<-EOF && | |
832 | delete TESTSYMREFONE $b | |
833 | delete TESTSYMREFTWO $b | |
834 | EOF | |
835 | git update-ref --no-deref --stdin <stdin && | |
836 | test_must_fail git rev-parse --verify -q TESTSYMREFONE && | |
837 | test_must_fail git rev-parse --verify -q TESTSYMREFTWO && | |
838 | git rev-parse $m~1 >expect && | |
839 | git rev-parse $b >actual && | |
840 | test_cmp expect actual | |
841 | ' | |
842 | ||
c6268bc0 BK |
843 | test_expect_success 'stdin delete ref works with right old value' ' |
844 | echo "delete $b $m~1" >stdin && | |
845 | git update-ref --stdin <stdin && | |
846 | test_must_fail git rev-parse --verify -q $b | |
847 | ' | |
848 | ||
849 | test_expect_success 'stdin update/create/verify combination works' ' | |
850 | cat >stdin <<-EOF && | |
851 | update $a $m | |
852 | create $b $m | |
853 | verify $c | |
854 | EOF | |
855 | git update-ref --stdin <stdin && | |
856 | git rev-parse $m >expect && | |
857 | git rev-parse $a >actual && | |
858 | test_cmp expect actual && | |
859 | git rev-parse $b >actual && | |
860 | test_cmp expect actual && | |
861 | test_must_fail git rev-parse --verify -q $c | |
862 | ' | |
863 | ||
a46e41fc MH |
864 | test_expect_success 'stdin verify succeeds for correct value' ' |
865 | git rev-parse $m >expect && | |
866 | echo "verify $m $m" >stdin && | |
867 | git update-ref --stdin <stdin && | |
868 | git rev-parse $m >actual && | |
869 | test_cmp expect actual | |
870 | ' | |
871 | ||
872 | test_expect_success 'stdin verify succeeds for missing reference' ' | |
873 | echo "verify refs/heads/missing $Z" >stdin && | |
874 | git update-ref --stdin <stdin && | |
875 | test_must_fail git rev-parse --verify -q refs/heads/missing | |
876 | ' | |
877 | ||
878 | test_expect_success 'stdin verify treats no value as missing' ' | |
879 | echo "verify refs/heads/missing" >stdin && | |
880 | git update-ref --stdin <stdin && | |
881 | test_must_fail git rev-parse --verify -q refs/heads/missing | |
882 | ' | |
883 | ||
884 | test_expect_success 'stdin verify fails for wrong value' ' | |
885 | git rev-parse $m >expect && | |
886 | echo "verify $m $m~1" >stdin && | |
887 | test_must_fail git update-ref --stdin <stdin && | |
888 | git rev-parse $m >actual && | |
889 | test_cmp expect actual | |
890 | ' | |
891 | ||
892 | test_expect_success 'stdin verify fails for mistaken null value' ' | |
893 | git rev-parse $m >expect && | |
894 | echo "verify $m $Z" >stdin && | |
895 | test_must_fail git update-ref --stdin <stdin && | |
896 | git rev-parse $m >actual && | |
897 | test_cmp expect actual | |
898 | ' | |
899 | ||
0e729c7e | 900 | test_expect_success 'stdin verify fails for mistaken empty value' ' |
a46e41fc MH |
901 | M=$(git rev-parse $m) && |
902 | test_when_finished "git update-ref $m $M" && | |
903 | git rev-parse $m >expect && | |
904 | echo "verify $m" >stdin && | |
905 | test_must_fail git update-ref --stdin <stdin && | |
906 | git rev-parse $m >actual && | |
907 | test_cmp expect actual | |
908 | ' | |
909 | ||
c6268bc0 BK |
910 | test_expect_success 'stdin update refs works with identity updates' ' |
911 | cat >stdin <<-EOF && | |
912 | update $a $m $m | |
913 | update $b $m $m | |
914 | update $c $Z $E | |
915 | EOF | |
916 | git update-ref --stdin <stdin && | |
917 | git rev-parse $m >expect && | |
918 | git rev-parse $a >actual && | |
919 | test_cmp expect actual && | |
920 | git rev-parse $b >actual && | |
921 | test_cmp expect actual && | |
922 | test_must_fail git rev-parse --verify -q $c | |
923 | ' | |
924 | ||
925 | test_expect_success 'stdin update refs fails with wrong old value' ' | |
926 | git update-ref $c $m && | |
927 | cat >stdin <<-EOF && | |
928 | update $a $m $m | |
929 | update $b $m $m | |
930 | update $c '' | |
931 | EOF | |
932 | test_must_fail git update-ref --stdin <stdin 2>err && | |
c2e0a718 | 933 | grep "fatal: cannot lock ref '"'"'$c'"'"'" err && |
c6268bc0 BK |
934 | git rev-parse $m >expect && |
935 | git rev-parse $a >actual && | |
936 | test_cmp expect actual && | |
937 | git rev-parse $b >actual && | |
938 | test_cmp expect actual && | |
939 | git rev-parse $c >actual && | |
940 | test_cmp expect actual | |
941 | ' | |
942 | ||
943 | test_expect_success 'stdin delete refs works with packed and loose refs' ' | |
944 | git pack-refs --all && | |
945 | git update-ref $c $m~1 && | |
946 | cat >stdin <<-EOF && | |
947 | delete $a $m | |
948 | update $b $Z $m | |
949 | update $c $E $m~1 | |
950 | EOF | |
951 | git update-ref --stdin <stdin && | |
952 | test_must_fail git rev-parse --verify -q $a && | |
953 | test_must_fail git rev-parse --verify -q $b && | |
954 | test_must_fail git rev-parse --verify -q $c | |
955 | ' | |
956 | ||
957 | test_expect_success 'stdin -z works on empty input' ' | |
958 | >stdin && | |
959 | git update-ref -z --stdin <stdin && | |
960 | git rev-parse --verify -q $m | |
961 | ' | |
962 | ||
963 | test_expect_success 'stdin -z fails on empty line' ' | |
964 | echo "" >stdin && | |
965 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
966 | grep "fatal: whitespace before command: " err | |
967 | ' | |
968 | ||
969 | test_expect_success 'stdin -z fails on empty command' ' | |
970 | printf $F "" >stdin && | |
971 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
972 | grep "fatal: empty command in input" err | |
973 | ' | |
974 | ||
975 | test_expect_success 'stdin -z fails on only whitespace' ' | |
976 | printf $F " " >stdin && | |
977 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
978 | grep "fatal: whitespace before command: " err | |
979 | ' | |
980 | ||
981 | test_expect_success 'stdin -z fails on leading whitespace' ' | |
982 | printf $F " create $a" "$m" >stdin && | |
983 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
984 | grep "fatal: whitespace before command: create $a" err | |
985 | ' | |
986 | ||
987 | test_expect_success 'stdin -z fails on unknown command' ' | |
988 | printf $F "unknown $a" >stdin && | |
989 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
990 | grep "fatal: unknown command: unknown $a" err | |
991 | ' | |
992 | ||
993 | test_expect_success 'stdin -z fails create with no ref' ' | |
994 | printf $F "create " >stdin && | |
995 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
f11b09fb | 996 | grep "fatal: create: missing <ref>" err |
c6268bc0 BK |
997 | ' |
998 | ||
c6268bc0 BK |
999 | test_expect_success 'stdin -z fails create with no new value' ' |
1000 | printf $F "create $a" >stdin && | |
1001 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
726f6916 | 1002 | grep "fatal: create $a: unexpected end of input when reading <newvalue>" err |
c6268bc0 BK |
1003 | ' |
1004 | ||
1005 | test_expect_success 'stdin -z fails create with too many arguments' ' | |
1006 | printf $F "create $a" "$m" "$m" >stdin && | |
1007 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
1008 | grep "fatal: unknown command: $m" err | |
1009 | ' | |
1010 | ||
1011 | test_expect_success 'stdin -z fails update with no ref' ' | |
1012 | printf $F "update " >stdin && | |
1013 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
f11b09fb | 1014 | grep "fatal: update: missing <ref>" err |
c6268bc0 BK |
1015 | ' |
1016 | ||
ff6ee395 MH |
1017 | test_expect_success 'stdin -z fails update with too few args' ' |
1018 | printf $F "update $a" "$m" >stdin && | |
1019 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
726f6916 | 1020 | grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err |
c6268bc0 BK |
1021 | ' |
1022 | ||
1fbd5049 | 1023 | test_expect_success 'stdin -z emits warning with empty new value' ' |
191f241b MH |
1024 | git update-ref $a $m && |
1025 | printf $F "update $a" "" "" >stdin && | |
1fbd5049 MH |
1026 | git update-ref -z --stdin <stdin 2>err && |
1027 | grep "warning: update $a: missing <newvalue>, treating as zero" err && | |
191f241b MH |
1028 | test_must_fail git rev-parse --verify -q $a |
1029 | ' | |
1030 | ||
c6268bc0 BK |
1031 | test_expect_success 'stdin -z fails update with no new value' ' |
1032 | printf $F "update $a" >stdin && | |
1033 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
726f6916 | 1034 | grep "fatal: update $a: unexpected end of input when reading <newvalue>" err |
c6268bc0 BK |
1035 | ' |
1036 | ||
1037 | test_expect_success 'stdin -z fails update with no old value' ' | |
1038 | printf $F "update $a" "$m" >stdin && | |
1039 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
726f6916 | 1040 | grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err |
c6268bc0 BK |
1041 | ' |
1042 | ||
1043 | test_expect_success 'stdin -z fails update with too many arguments' ' | |
1044 | printf $F "update $a" "$m" "$m" "$m" >stdin && | |
1045 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
1046 | grep "fatal: unknown command: $m" err | |
1047 | ' | |
1048 | ||
1049 | test_expect_success 'stdin -z fails delete with no ref' ' | |
1050 | printf $F "delete " >stdin && | |
1051 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
f11b09fb | 1052 | grep "fatal: delete: missing <ref>" err |
c6268bc0 BK |
1053 | ' |
1054 | ||
c6268bc0 BK |
1055 | test_expect_success 'stdin -z fails delete with no old value' ' |
1056 | printf $F "delete $a" >stdin && | |
1057 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
726f6916 | 1058 | grep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err |
c6268bc0 BK |
1059 | ' |
1060 | ||
1061 | test_expect_success 'stdin -z fails delete with too many arguments' ' | |
1062 | printf $F "delete $a" "$m" "$m" >stdin && | |
1063 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
1064 | grep "fatal: unknown command: $m" err | |
1065 | ' | |
1066 | ||
1067 | test_expect_success 'stdin -z fails verify with too many arguments' ' | |
1068 | printf $F "verify $a" "$m" "$m" >stdin && | |
1069 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
1070 | grep "fatal: unknown command: $m" err | |
1071 | ' | |
1072 | ||
1073 | test_expect_success 'stdin -z fails verify with no old value' ' | |
1074 | printf $F "verify $a" >stdin && | |
1075 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
726f6916 | 1076 | grep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err |
c6268bc0 BK |
1077 | ' |
1078 | ||
1079 | test_expect_success 'stdin -z fails option with unknown name' ' | |
1080 | printf $F "option unknown" >stdin && | |
1081 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
1082 | grep "fatal: option unknown: unknown" err | |
1083 | ' | |
1084 | ||
1085 | test_expect_success 'stdin -z fails with duplicate refs' ' | |
1086 | printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin && | |
1087 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
661558f0 | 1088 | test_i18ngrep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed" err |
c6268bc0 BK |
1089 | ' |
1090 | ||
1091 | test_expect_success 'stdin -z create ref works' ' | |
1092 | printf $F "create $a" "$m" >stdin && | |
1093 | git update-ref -z --stdin <stdin && | |
1094 | git rev-parse $m >expect && | |
1095 | git rev-parse $a >actual && | |
1096 | test_cmp expect actual | |
1097 | ' | |
1098 | ||
1099 | test_expect_success 'stdin -z update ref creates with zero old value' ' | |
1100 | printf $F "update $b" "$m" "$Z" >stdin && | |
1101 | git update-ref -z --stdin <stdin && | |
1102 | git rev-parse $m >expect && | |
1103 | git rev-parse $b >actual && | |
1104 | test_cmp expect actual && | |
1105 | git update-ref -d $b | |
1106 | ' | |
1107 | ||
1108 | test_expect_success 'stdin -z update ref creates with empty old value' ' | |
1109 | printf $F "update $b" "$m" "" >stdin && | |
1110 | git update-ref -z --stdin <stdin && | |
1111 | git rev-parse $m >expect && | |
1112 | git rev-parse $b >actual && | |
1113 | test_cmp expect actual | |
1114 | ' | |
1115 | ||
1116 | test_expect_success 'stdin -z create ref works with path with space to blob' ' | |
1117 | printf $F "create refs/blobs/pws" "$m:$pws" >stdin && | |
1118 | git update-ref -z --stdin <stdin && | |
1119 | git rev-parse "$m:$pws" >expect && | |
1120 | git rev-parse refs/blobs/pws >actual && | |
1121 | test_cmp expect actual && | |
1122 | git update-ref -d refs/blobs/pws | |
1123 | ' | |
1124 | ||
1125 | test_expect_success 'stdin -z update ref fails with wrong old value' ' | |
1126 | printf $F "update $c" "$m" "$m~1" >stdin && | |
1127 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
c2e0a718 | 1128 | grep "fatal: cannot lock ref '"'"'$c'"'"'" err && |
c6268bc0 BK |
1129 | test_must_fail git rev-parse --verify -q $c |
1130 | ' | |
1131 | ||
1132 | test_expect_success 'stdin -z update ref fails with bad old value' ' | |
1133 | printf $F "update $c" "$m" "does-not-exist" >stdin && | |
1134 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
9255f059 | 1135 | grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err && |
c6268bc0 BK |
1136 | test_must_fail git rev-parse --verify -q $c |
1137 | ' | |
1138 | ||
b9d56b5d AG |
1139 | test_expect_success 'stdin -z create ref fails when ref exists' ' |
1140 | git update-ref $c $m && | |
1141 | git rev-parse "$c" >expect && | |
1142 | printf $F "create $c" "$m~1" >stdin && | |
1143 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
c2e0a718 | 1144 | grep "fatal: cannot lock ref '"'"'$c'"'"'" err && |
b9d56b5d AG |
1145 | git rev-parse "$c" >actual && |
1146 | test_cmp expect actual | |
1147 | ' | |
1148 | ||
c6268bc0 | 1149 | test_expect_success 'stdin -z create ref fails with bad new value' ' |
b9d56b5d | 1150 | git update-ref -d "$c" && |
c6268bc0 BK |
1151 | printf $F "create $c" "does-not-exist" >stdin && |
1152 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
9255f059 | 1153 | grep "fatal: create $c: invalid <newvalue>: does-not-exist" err && |
c6268bc0 BK |
1154 | test_must_fail git rev-parse --verify -q $c |
1155 | ' | |
1156 | ||
3afcc463 | 1157 | test_expect_success 'stdin -z create ref fails with empty new value' ' |
c6268bc0 BK |
1158 | printf $F "create $c" "" >stdin && |
1159 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
f11b09fb | 1160 | grep "fatal: create $c: missing <newvalue>" err && |
c6268bc0 BK |
1161 | test_must_fail git rev-parse --verify -q $c |
1162 | ' | |
1163 | ||
1164 | test_expect_success 'stdin -z update ref works with right old value' ' | |
1165 | printf $F "update $b" "$m~1" "$m" >stdin && | |
1166 | git update-ref -z --stdin <stdin && | |
1167 | git rev-parse $m~1 >expect && | |
1168 | git rev-parse $b >actual && | |
1169 | test_cmp expect actual | |
1170 | ' | |
1171 | ||
1172 | test_expect_success 'stdin -z delete ref fails with wrong old value' ' | |
1173 | printf $F "delete $a" "$m~1" >stdin && | |
1174 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
c2e0a718 | 1175 | grep "fatal: cannot lock ref '"'"'$a'"'"'" err && |
c6268bc0 BK |
1176 | git rev-parse $m >expect && |
1177 | git rev-parse $a >actual && | |
1178 | test_cmp expect actual | |
1179 | ' | |
1180 | ||
1181 | test_expect_success 'stdin -z delete ref fails with zero old value' ' | |
1182 | printf $F "delete $a" "$Z" >stdin && | |
1183 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
f11b09fb | 1184 | grep "fatal: delete $a: zero <oldvalue>" err && |
c6268bc0 BK |
1185 | git rev-parse $m >expect && |
1186 | git rev-parse $a >actual && | |
1187 | test_cmp expect actual | |
1188 | ' | |
1189 | ||
1190 | test_expect_success 'stdin -z update symref works option no-deref' ' | |
1191 | git symbolic-ref TESTSYMREF $b && | |
1192 | printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin && | |
1193 | git update-ref -z --stdin <stdin && | |
1194 | git rev-parse TESTSYMREF >expect && | |
1195 | git rev-parse $a >actual && | |
1196 | test_cmp expect actual && | |
1197 | git rev-parse $m~1 >expect && | |
1198 | git rev-parse $b >actual && | |
1199 | test_cmp expect actual | |
1200 | ' | |
1201 | ||
1202 | test_expect_success 'stdin -z delete symref works option no-deref' ' | |
1203 | git symbolic-ref TESTSYMREF $b && | |
1204 | printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin && | |
1205 | git update-ref -z --stdin <stdin && | |
1206 | test_must_fail git rev-parse --verify -q TESTSYMREF && | |
1207 | git rev-parse $m~1 >expect && | |
1208 | git rev-parse $b >actual && | |
1209 | test_cmp expect actual | |
1210 | ' | |
1211 | ||
1212 | test_expect_success 'stdin -z delete ref works with right old value' ' | |
1213 | printf $F "delete $b" "$m~1" >stdin && | |
1214 | git update-ref -z --stdin <stdin && | |
1215 | test_must_fail git rev-parse --verify -q $b | |
1216 | ' | |
1217 | ||
1218 | test_expect_success 'stdin -z update/create/verify combination works' ' | |
1219 | printf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin && | |
1220 | git update-ref -z --stdin <stdin && | |
1221 | git rev-parse $m >expect && | |
1222 | git rev-parse $a >actual && | |
1223 | test_cmp expect actual && | |
1224 | git rev-parse $b >actual && | |
1225 | test_cmp expect actual && | |
1226 | test_must_fail git rev-parse --verify -q $c | |
1227 | ' | |
1228 | ||
a46e41fc MH |
1229 | test_expect_success 'stdin -z verify succeeds for correct value' ' |
1230 | git rev-parse $m >expect && | |
1231 | printf $F "verify $m" "$m" >stdin && | |
1232 | git update-ref -z --stdin <stdin && | |
1233 | git rev-parse $m >actual && | |
1234 | test_cmp expect actual | |
1235 | ' | |
1236 | ||
1237 | test_expect_success 'stdin -z verify succeeds for missing reference' ' | |
1238 | printf $F "verify refs/heads/missing" "$Z" >stdin && | |
1239 | git update-ref -z --stdin <stdin && | |
1240 | test_must_fail git rev-parse --verify -q refs/heads/missing | |
1241 | ' | |
1242 | ||
1243 | test_expect_success 'stdin -z verify treats no value as missing' ' | |
1244 | printf $F "verify refs/heads/missing" "" >stdin && | |
1245 | git update-ref -z --stdin <stdin && | |
1246 | test_must_fail git rev-parse --verify -q refs/heads/missing | |
1247 | ' | |
1248 | ||
1249 | test_expect_success 'stdin -z verify fails for wrong value' ' | |
1250 | git rev-parse $m >expect && | |
1251 | printf $F "verify $m" "$m~1" >stdin && | |
1252 | test_must_fail git update-ref -z --stdin <stdin && | |
1253 | git rev-parse $m >actual && | |
1254 | test_cmp expect actual | |
1255 | ' | |
1256 | ||
1257 | test_expect_success 'stdin -z verify fails for mistaken null value' ' | |
1258 | git rev-parse $m >expect && | |
1259 | printf $F "verify $m" "$Z" >stdin && | |
1260 | test_must_fail git update-ref -z --stdin <stdin && | |
1261 | git rev-parse $m >actual && | |
1262 | test_cmp expect actual | |
1263 | ' | |
1264 | ||
0e729c7e | 1265 | test_expect_success 'stdin -z verify fails for mistaken empty value' ' |
a46e41fc MH |
1266 | M=$(git rev-parse $m) && |
1267 | test_when_finished "git update-ref $m $M" && | |
1268 | git rev-parse $m >expect && | |
1269 | printf $F "verify $m" "" >stdin && | |
1270 | test_must_fail git update-ref -z --stdin <stdin && | |
1271 | git rev-parse $m >actual && | |
1272 | test_cmp expect actual | |
1273 | ' | |
1274 | ||
c6268bc0 BK |
1275 | test_expect_success 'stdin -z update refs works with identity updates' ' |
1276 | printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin && | |
1277 | git update-ref -z --stdin <stdin && | |
1278 | git rev-parse $m >expect && | |
1279 | git rev-parse $a >actual && | |
1280 | test_cmp expect actual && | |
1281 | git rev-parse $b >actual && | |
1282 | test_cmp expect actual && | |
1283 | test_must_fail git rev-parse --verify -q $c | |
1284 | ' | |
1285 | ||
1286 | test_expect_success 'stdin -z update refs fails with wrong old value' ' | |
1287 | git update-ref $c $m && | |
c1329110 | 1288 | printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin && |
c6268bc0 | 1289 | test_must_fail git update-ref -z --stdin <stdin 2>err && |
c2e0a718 | 1290 | grep "fatal: cannot lock ref '"'"'$c'"'"'" err && |
c6268bc0 BK |
1291 | git rev-parse $m >expect && |
1292 | git rev-parse $a >actual && | |
1293 | test_cmp expect actual && | |
1294 | git rev-parse $b >actual && | |
1295 | test_cmp expect actual && | |
1296 | git rev-parse $c >actual && | |
1297 | test_cmp expect actual | |
1298 | ' | |
1299 | ||
1300 | test_expect_success 'stdin -z delete refs works with packed and loose refs' ' | |
1301 | git pack-refs --all && | |
1302 | git update-ref $c $m~1 && | |
1303 | printf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin && | |
1304 | git update-ref -z --stdin <stdin && | |
1305 | test_must_fail git rev-parse --verify -q $a && | |
1306 | test_must_fail git rev-parse --verify -q $b && | |
1307 | test_must_fail git rev-parse --verify -q $c | |
1308 | ' | |
1309 | ||
92b1551b MH |
1310 | test_expect_success 'fails with duplicate HEAD update' ' |
1311 | git branch target1 $A && | |
1312 | git checkout target1 && | |
1313 | cat >stdin <<-EOF && | |
1314 | update refs/heads/target1 $C | |
1315 | option no-deref | |
1316 | update HEAD $B | |
1317 | EOF | |
1318 | test_must_fail git update-ref --stdin <stdin 2>err && | |
661558f0 | 1319 | test_i18ngrep "fatal: multiple updates for '\''HEAD'\'' (including one via its referent .refs/heads/target1.) are not allowed" err && |
92b1551b MH |
1320 | echo "refs/heads/target1" >expect && |
1321 | git symbolic-ref HEAD >actual && | |
1322 | test_cmp expect actual && | |
1323 | echo "$A" >expect && | |
1324 | git rev-parse refs/heads/target1 >actual && | |
1325 | test_cmp expect actual | |
1326 | ' | |
1327 | ||
1328 | test_expect_success 'fails with duplicate ref update via symref' ' | |
1329 | git branch target2 $A && | |
1330 | git symbolic-ref refs/heads/symref2 refs/heads/target2 && | |
1331 | cat >stdin <<-EOF && | |
1332 | update refs/heads/target2 $C | |
1333 | update refs/heads/symref2 $B | |
1334 | EOF | |
1335 | test_must_fail git update-ref --stdin <stdin 2>err && | |
661558f0 | 1336 | test_i18ngrep "fatal: multiple updates for '\''refs/heads/target2'\'' (including one via symref .refs/heads/symref2.) are not allowed" err && |
92b1551b MH |
1337 | echo "refs/heads/target2" >expect && |
1338 | git symbolic-ref refs/heads/symref2 >actual && | |
1339 | test_cmp expect actual && | |
1340 | echo "$A" >expect && | |
1341 | git rev-parse refs/heads/target2 >actual && | |
1342 | test_cmp expect actual | |
1343 | ' | |
1344 | ||
d415ad02 SB |
1345 | run_with_limited_open_files () { |
1346 | (ulimit -n 32 && "$@") | |
1347 | } | |
1348 | ||
21dac1de RJ |
1349 | test_lazy_prereq ULIMIT_FILE_DESCRIPTORS ' |
1350 | test_have_prereq !MINGW,!CYGWIN && | |
1351 | run_with_limited_open_files true | |
1352 | ' | |
d415ad02 | 1353 | |
cf018ee0 | 1354 | test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' ' |
d415ad02 SB |
1355 | ( |
1356 | for i in $(test_seq 33) | |
1357 | do | |
1358 | echo "create refs/heads/$i HEAD" | |
1359 | done >large_input && | |
1360 | run_with_limited_open_files git update-ref --stdin <large_input && | |
1361 | git rev-parse --verify -q refs/heads/33 | |
1362 | ) | |
1363 | ' | |
1364 | ||
cf018ee0 | 1365 | test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' ' |
d415ad02 SB |
1366 | ( |
1367 | for i in $(test_seq 33) | |
1368 | do | |
1369 | echo "delete refs/heads/$i HEAD" | |
1370 | done >large_input && | |
1371 | run_with_limited_open_files git update-ref --stdin <large_input && | |
1372 | test_must_fail git rev-parse --verify -q refs/heads/33 | |
1373 | ) | |
1374 | ' | |
1375 | ||
ce414b33 DT |
1376 | test_expect_success 'handle per-worktree refs in refs/bisect' ' |
1377 | git commit --allow-empty -m "initial commit" && | |
1378 | git worktree add -b branch worktree && | |
1379 | ( | |
1380 | cd worktree && | |
1381 | git commit --allow-empty -m "test commit" && | |
1382 | git for-each-ref >for-each-ref.out && | |
1383 | ! grep refs/bisect for-each-ref.out && | |
1384 | git update-ref refs/bisect/something HEAD && | |
1385 | git rev-parse refs/bisect/something >../worktree-head && | |
1386 | git for-each-ref | grep refs/bisect/something | |
1387 | ) && | |
1388 | test_path_is_missing .git/refs/bisect && | |
1389 | test_must_fail git rev-parse refs/bisect/something && | |
1390 | git update-ref refs/bisect/something HEAD && | |
1391 | git rev-parse refs/bisect/something >main-head && | |
1392 | ! test_cmp main-head worktree-head | |
1393 | ' | |
1394 | ||
6de08ae6 | 1395 | test_done |