Merge branch 'jk/doc-submodule-markup-fix'
[alt-git.git] / t / t1400-update-ref.sh
blobb0ffc0b5731dd746ed170604784287d3e48e9c30
1 #!/bin/sh
3 # Copyright (c) 2006 Shawn Pearce
6 test_description='Test git update-ref and basic ref logging'
7 . ./test-lib.sh
9 Z=$_z40
11 m=refs/heads/master
12 n_dir=refs/heads/gu
13 n=$n_dir/fixes
14 outside=refs/foo
15 bare=bare-repo
17 create_test_commits ()
19 prfx="$1"
20 for name in A B C D E F
22 test_tick &&
23 T=$(git write-tree) &&
24 sha1=$(echo $name | git commit-tree $T) &&
25 eval $prfx$name=$sha1
26 done
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 -
38 test_expect_success \
39 "create $m" \
40 "git update-ref $m $A &&
41 test $A"' = $(cat .git/'"$m"')'
42 test_expect_success \
43 "create $m" \
44 "git update-ref $m $B $A &&
45 test $B"' = $(cat .git/'"$m"')'
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)"
50 test_expect_success "delete $m" '
51 git update-ref -d $m $B &&
52 ! test -f .git/$m
54 rm -f .git/$m
56 test_expect_success "delete $m without oldvalue verification" "
57 git update-ref $m $A &&
58 test $A = \$(cat .git/$m) &&
59 git update-ref -d $m &&
60 ! test -f .git/$m
62 rm -f .git/$m
64 test_expect_success \
65 "fail to create $n" \
66 "touch .git/$n_dir &&
67 test_must_fail git update-ref $n $A >out 2>err"
68 rm -f .git/$n_dir out err
70 test_expect_success \
71 "create $m (by HEAD)" \
72 "git update-ref HEAD $A &&
73 test $A"' = $(cat .git/'"$m"')'
74 test_expect_success \
75 "create $m (by HEAD)" \
76 "git update-ref HEAD $B $A &&
77 test $B"' = $(cat .git/'"$m"')'
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)
82 test_expect_success "delete $m (by HEAD)" '
83 git update-ref -d HEAD $B &&
84 ! test -f .git/$m
86 rm -f .git/$m
88 test_expect_success 'update-ref does not create reflogs by default' '
89 test_when_finished "git update-ref -d $outside" &&
90 git update-ref $outside $A &&
91 git rev-parse $A >expect &&
92 git rev-parse $outside >actual &&
93 test_cmp expect actual &&
94 test_must_fail git reflog exists $outside
97 test_expect_success 'update-ref creates reflogs with --create-reflog' '
98 test_when_finished "git update-ref -d $outside" &&
99 git update-ref --create-reflog $outside $A &&
100 git rev-parse $A >expect &&
101 git rev-parse $outside >actual &&
102 test_cmp expect actual &&
103 git reflog exists $outside
106 test_expect_success 'creates no reflog in bare repository' '
107 git -C $bare update-ref $m $bareA &&
108 git -C $bare rev-parse $bareA >expect &&
109 git -C $bare rev-parse $m >actual &&
110 test_cmp expect actual &&
111 test_must_fail git -C $bare reflog exists $m
114 test_expect_success 'core.logAllRefUpdates=true creates reflog in bare repository' '
115 test_when_finished "git -C $bare config --unset core.logAllRefUpdates && \
116 rm $bare/logs/$m" &&
117 git -C $bare config core.logAllRefUpdates true &&
118 git -C $bare update-ref $m $bareB &&
119 git -C $bare rev-parse $bareB >expect &&
120 git -C $bare rev-parse $m >actual &&
121 test_cmp expect actual &&
122 git -C $bare reflog exists $m
125 test_expect_success 'core.logAllRefUpdates=true does not create reflog by default' '
126 test_config core.logAllRefUpdates true &&
127 test_when_finished "git update-ref -d $outside" &&
128 git update-ref $outside $A &&
129 git rev-parse $A >expect &&
130 git rev-parse $outside >actual &&
131 test_cmp expect actual &&
132 test_must_fail git reflog exists $outside
135 test_expect_success 'core.logAllRefUpdates=always creates reflog by default' '
136 test_config core.logAllRefUpdates always &&
137 test_when_finished "git update-ref -d $outside" &&
138 git update-ref $outside $A &&
139 git rev-parse $A >expect &&
140 git rev-parse $outside >actual &&
141 test_cmp expect actual &&
142 git reflog exists $outside
145 test_expect_success 'core.logAllRefUpdates=always creates no reflog for ORIG_HEAD' '
146 test_config core.logAllRefUpdates always &&
147 git update-ref ORIG_HEAD $A &&
148 test_must_fail git reflog exists ORIG_HEAD
151 test_expect_success '--no-create-reflog overrides core.logAllRefUpdates=always' '
152 test_config core.logAllRefUpdates true &&
153 test_when_finished "git update-ref -d $outside" &&
154 git update-ref --no-create-reflog $outside $A &&
155 git rev-parse $A >expect &&
156 git rev-parse $outside >actual &&
157 test_cmp expect actual &&
158 test_must_fail git reflog exists $outside
161 test_expect_success \
162 "create $m (by HEAD)" \
163 "git update-ref HEAD $A &&
164 test $A"' = $(cat .git/'"$m"')'
165 test_expect_success \
166 "pack refs" \
167 "git pack-refs --all"
168 test_expect_success \
169 "move $m (by HEAD)" \
170 "git update-ref HEAD $B $A &&
171 test $B"' = $(cat .git/'"$m"')'
172 test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" '
173 git update-ref -d HEAD $B &&
174 ! grep "$m" .git/packed-refs &&
175 ! test -f .git/$m
177 rm -f .git/$m
179 cp -f .git/HEAD .git/HEAD.orig
180 test_expect_success "delete symref without dereference" '
181 git update-ref --no-deref -d HEAD &&
182 ! test -f .git/HEAD
184 cp -f .git/HEAD.orig .git/HEAD
186 test_expect_success "delete symref without dereference when the referred ref is packed" '
187 echo foo >foo.c &&
188 git add foo.c &&
189 git commit -m foo &&
190 git pack-refs --all &&
191 git update-ref --no-deref -d HEAD &&
192 ! test -f .git/HEAD
194 cp -f .git/HEAD.orig .git/HEAD
195 git update-ref -d $m
197 test_expect_success 'update-ref -d is not confused by self-reference' '
198 git symbolic-ref refs/heads/self refs/heads/self &&
199 test_when_finished "rm -f .git/refs/heads/self" &&
200 test_path_is_file .git/refs/heads/self &&
201 test_must_fail git update-ref -d refs/heads/self &&
202 test_path_is_file .git/refs/heads/self
205 test_expect_success 'update-ref --no-deref -d can delete self-reference' '
206 git symbolic-ref refs/heads/self refs/heads/self &&
207 test_when_finished "rm -f .git/refs/heads/self" &&
208 test_path_is_file .git/refs/heads/self &&
209 git update-ref --no-deref -d refs/heads/self &&
210 test_path_is_missing .git/refs/heads/self
213 test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' '
214 >.git/refs/heads/bad &&
215 test_when_finished "rm -f .git/refs/heads/bad" &&
216 git symbolic-ref refs/heads/ref-to-bad refs/heads/bad &&
217 test_when_finished "rm -f .git/refs/heads/ref-to-bad" &&
218 test_path_is_file .git/refs/heads/ref-to-bad &&
219 git update-ref --no-deref -d refs/heads/ref-to-bad &&
220 test_path_is_missing .git/refs/heads/ref-to-bad
223 test_expect_success '(not) create HEAD with old sha1' "
224 test_must_fail git update-ref HEAD $A $B
226 test_expect_success "(not) prior created .git/$m" "
227 ! test -f .git/$m
229 rm -f .git/$m
231 test_expect_success \
232 "create HEAD" \
233 "git update-ref HEAD $A"
234 test_expect_success '(not) change HEAD with wrong SHA1' "
235 test_must_fail git update-ref HEAD $B $Z
237 test_expect_success "(not) changed .git/$m" "
238 ! test $B"' = $(cat .git/'"$m"')
240 rm -f .git/$m
242 rm -f .git/logs/refs/heads/master
243 test_expect_success \
244 "create $m (logged by touch)" \
245 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
246 git update-ref --create-reflog HEAD '"$A"' -m "Initial Creation" &&
247 test '"$A"' = $(cat .git/'"$m"')'
248 test_expect_success \
249 "update $m (logged by touch)" \
250 'GIT_COMMITTER_DATE="2005-05-26 23:31" \
251 git update-ref HEAD'" $B $A "'-m "Switch" &&
252 test '"$B"' = $(cat .git/'"$m"')'
253 test_expect_success \
254 "set $m (logged by touch)" \
255 'GIT_COMMITTER_DATE="2005-05-26 23:41" \
256 git update-ref HEAD'" $A &&
257 test $A"' = $(cat .git/'"$m"')'
259 cat >expect <<EOF
260 $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
261 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
262 $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
264 test_expect_success \
265 "verifying $m's log" \
266 "test_cmp expect .git/logs/$m"
267 rm -rf .git/$m .git/logs expect
269 test_expect_success \
270 'enable core.logAllRefUpdates' \
271 'git config core.logAllRefUpdates true &&
272 test true = $(git config --bool --get core.logAllRefUpdates)'
274 test_expect_success \
275 "create $m (logged by config)" \
276 'GIT_COMMITTER_DATE="2005-05-26 23:32" \
277 git update-ref HEAD'" $A "'-m "Initial Creation" &&
278 test '"$A"' = $(cat .git/'"$m"')'
279 test_expect_success \
280 "update $m (logged by config)" \
281 'GIT_COMMITTER_DATE="2005-05-26 23:33" \
282 git update-ref HEAD'" $B $A "'-m "Switch" &&
283 test '"$B"' = $(cat .git/'"$m"')'
284 test_expect_success \
285 "set $m (logged by config)" \
286 'GIT_COMMITTER_DATE="2005-05-26 23:43" \
287 git update-ref HEAD '"$A &&
288 test $A"' = $(cat .git/'"$m"')'
290 cat >expect <<EOF
291 $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation
292 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
293 $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
295 test_expect_success \
296 "verifying $m's log" \
297 'test_cmp expect .git/logs/$m'
298 rm -f .git/$m .git/logs/$m expect
300 git update-ref $m $D
301 cat >.git/logs/$m <<EOF
302 0000000000000000000000000000000000000000 $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
303 $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
304 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
305 $F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
306 $Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
309 ed="Thu, 26 May 2005 18:32:00 -0500"
310 gd="Thu, 26 May 2005 18:33:00 -0500"
311 ld="Thu, 26 May 2005 18:43:00 -0500"
312 test_expect_success \
313 'Query "master@{May 25 2005}" (before history)' \
314 'rm -f o e &&
315 git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
316 test '"$C"' = $(cat o) &&
317 test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
318 test_expect_success \
319 "Query master@{2005-05-25} (before history)" \
320 'rm -f o e &&
321 git rev-parse --verify master@{2005-05-25} >o 2>e &&
322 test '"$C"' = $(cat o) &&
323 echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
324 test_expect_success \
325 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
326 'rm -f o e &&
327 git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
328 test '"$C"' = $(cat o) &&
329 test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
330 test_expect_success \
331 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
332 'rm -f o e &&
333 git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
334 test '"$C"' = $(cat o) &&
335 test "" = "$(cat e)"'
336 test_expect_success \
337 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
338 'rm -f o e &&
339 git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
340 test '"$A"' = $(cat o) &&
341 test "" = "$(cat e)"'
342 test_expect_success \
343 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
344 'rm -f o e &&
345 git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
346 test '"$B"' = $(cat o) &&
347 test "warning: Log for ref '"$m has gap after $gd"'." = "$(cat e)"'
348 test_expect_success \
349 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
350 'rm -f o e &&
351 git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
352 test '"$Z"' = $(cat o) &&
353 test "" = "$(cat e)"'
354 test_expect_success \
355 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
356 'rm -f o e &&
357 git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
358 test '"$E"' = $(cat o) &&
359 test "" = "$(cat e)"'
360 test_expect_success \
361 'Query "master@{2005-05-28}" (past end of history)' \
362 'rm -f o e &&
363 git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
364 test '"$D"' = $(cat o) &&
365 test "warning: Log for ref '"$m unexpectedly ended on $ld"'." = "$(cat e)"'
368 rm -f .git/$m .git/logs/$m expect
370 test_expect_success \
371 'creating initial files' \
372 'echo TEST >F &&
373 git add F &&
374 GIT_AUTHOR_DATE="2005-05-26 23:30" \
375 GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
376 h_TEST=$(git rev-parse --verify HEAD) &&
377 echo The other day this did not work. >M &&
378 echo And then Bob told me how to fix it. >>M &&
379 echo OTHER >F &&
380 GIT_AUTHOR_DATE="2005-05-26 23:41" \
381 GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a &&
382 h_OTHER=$(git rev-parse --verify HEAD) &&
383 GIT_AUTHOR_DATE="2005-05-26 23:44" \
384 GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend &&
385 h_FIXED=$(git rev-parse --verify HEAD) &&
386 echo Merged initial commit and a later commit. >M &&
387 echo $h_TEST >.git/MERGE_HEAD &&
388 GIT_AUTHOR_DATE="2005-05-26 23:45" \
389 GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
390 h_MERGED=$(git rev-parse --verify HEAD) &&
391 rm -f M'
393 cat >expect <<EOF
394 $Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add
395 $h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 commit: The other day this did not work.
396 $h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 commit (amend): The other day this did not work.
397 $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit.
399 test_expect_success \
400 'git commit logged updates' \
401 "test_cmp expect .git/logs/$m"
402 unset h_TEST h_OTHER h_FIXED h_MERGED
404 test_expect_success \
405 'git cat-file blob master:F (expect OTHER)' \
406 'test OTHER = $(git cat-file blob master:F)'
407 test_expect_success \
408 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
409 'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")'
410 test_expect_success \
411 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
412 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'
414 a=refs/heads/a
415 b=refs/heads/b
416 c=refs/heads/c
417 E='""'
418 F='%s\0'
419 pws='path with space'
421 test_expect_success 'stdin test setup' '
422 echo "$pws" >"$pws" &&
423 git add -- "$pws" &&
424 git commit -m "$pws"
427 test_expect_success '-z fails without --stdin' '
428 test_must_fail git update-ref -z $m $m $m 2>err &&
429 test_i18ngrep "usage: git update-ref" err
432 test_expect_success 'stdin works with no input' '
433 >stdin &&
434 git update-ref --stdin <stdin &&
435 git rev-parse --verify -q $m
438 test_expect_success 'stdin fails on empty line' '
439 echo "" >stdin &&
440 test_must_fail git update-ref --stdin <stdin 2>err &&
441 grep "fatal: empty command in input" err
444 test_expect_success 'stdin fails on only whitespace' '
445 echo " " >stdin &&
446 test_must_fail git update-ref --stdin <stdin 2>err &&
447 grep "fatal: whitespace before command: " err
450 test_expect_success 'stdin fails on leading whitespace' '
451 echo " create $a $m" >stdin &&
452 test_must_fail git update-ref --stdin <stdin 2>err &&
453 grep "fatal: whitespace before command: create $a $m" err
456 test_expect_success 'stdin fails on unknown command' '
457 echo "unknown $a" >stdin &&
458 test_must_fail git update-ref --stdin <stdin 2>err &&
459 grep "fatal: unknown command: unknown $a" err
462 test_expect_success 'stdin fails on unbalanced quotes' '
463 echo "create $a \"master" >stdin &&
464 test_must_fail git update-ref --stdin <stdin 2>err &&
465 grep "fatal: badly quoted argument: \\\"master" err
468 test_expect_success 'stdin fails on invalid escape' '
469 echo "create $a \"ma\zter\"" >stdin &&
470 test_must_fail git update-ref --stdin <stdin 2>err &&
471 grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err
474 test_expect_success 'stdin fails on junk after quoted argument' '
475 echo "create \"$a\"master" >stdin &&
476 test_must_fail git update-ref --stdin <stdin 2>err &&
477 grep "fatal: unexpected character after quoted argument: \\\"$a\\\"master" err
480 test_expect_success 'stdin fails create with no ref' '
481 echo "create " >stdin &&
482 test_must_fail git update-ref --stdin <stdin 2>err &&
483 grep "fatal: create: missing <ref>" err
486 test_expect_success 'stdin fails create with no new value' '
487 echo "create $a" >stdin &&
488 test_must_fail git update-ref --stdin <stdin 2>err &&
489 grep "fatal: create $a: missing <newvalue>" err
492 test_expect_success 'stdin fails create with too many arguments' '
493 echo "create $a $m $m" >stdin &&
494 test_must_fail git update-ref --stdin <stdin 2>err &&
495 grep "fatal: create $a: extra input: $m" err
498 test_expect_success 'stdin fails update with no ref' '
499 echo "update " >stdin &&
500 test_must_fail git update-ref --stdin <stdin 2>err &&
501 grep "fatal: update: missing <ref>" err
504 test_expect_success 'stdin fails update with no new value' '
505 echo "update $a" >stdin &&
506 test_must_fail git update-ref --stdin <stdin 2>err &&
507 grep "fatal: update $a: missing <newvalue>" err
510 test_expect_success 'stdin fails update with too many arguments' '
511 echo "update $a $m $m $m" >stdin &&
512 test_must_fail git update-ref --stdin <stdin 2>err &&
513 grep "fatal: update $a: extra input: $m" err
516 test_expect_success 'stdin fails delete with no ref' '
517 echo "delete " >stdin &&
518 test_must_fail git update-ref --stdin <stdin 2>err &&
519 grep "fatal: delete: missing <ref>" err
522 test_expect_success 'stdin fails delete with too many arguments' '
523 echo "delete $a $m $m" >stdin &&
524 test_must_fail git update-ref --stdin <stdin 2>err &&
525 grep "fatal: delete $a: extra input: $m" err
528 test_expect_success 'stdin fails verify with too many arguments' '
529 echo "verify $a $m $m" >stdin &&
530 test_must_fail git update-ref --stdin <stdin 2>err &&
531 grep "fatal: verify $a: extra input: $m" err
534 test_expect_success 'stdin fails option with unknown name' '
535 echo "option unknown" >stdin &&
536 test_must_fail git update-ref --stdin <stdin 2>err &&
537 grep "fatal: option unknown: unknown" err
540 test_expect_success 'stdin fails with duplicate refs' '
541 cat >stdin <<-EOF &&
542 create $a $m
543 create $b $m
544 create $a $m
546 test_must_fail git update-ref --stdin <stdin 2>err &&
547 grep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed." err
550 test_expect_success 'stdin create ref works' '
551 echo "create $a $m" >stdin &&
552 git update-ref --stdin <stdin &&
553 git rev-parse $m >expect &&
554 git rev-parse $a >actual &&
555 test_cmp expect actual
558 test_expect_success 'stdin does not create reflogs by default' '
559 test_when_finished "git update-ref -d $outside" &&
560 echo "create $outside $m" >stdin &&
561 git update-ref --stdin <stdin &&
562 git rev-parse $m >expect &&
563 git rev-parse $outside >actual &&
564 test_cmp expect actual &&
565 test_must_fail git reflog exists $outside
568 test_expect_success 'stdin creates reflogs with --create-reflog' '
569 test_when_finished "git update-ref -d $outside" &&
570 echo "create $outside $m" >stdin &&
571 git update-ref --create-reflog --stdin <stdin &&
572 git rev-parse $m >expect &&
573 git rev-parse $outside >actual &&
574 test_cmp expect actual &&
575 git reflog exists $outside
578 test_expect_success 'stdin succeeds with quoted argument' '
579 git update-ref -d $a &&
580 echo "create $a \"$m\"" >stdin &&
581 git update-ref --stdin <stdin &&
582 git rev-parse $m >expect &&
583 git rev-parse $a >actual &&
584 test_cmp expect actual
587 test_expect_success 'stdin succeeds with escaped character' '
588 git update-ref -d $a &&
589 echo "create $a \"ma\\163ter\"" >stdin &&
590 git update-ref --stdin <stdin &&
591 git rev-parse $m >expect &&
592 git rev-parse $a >actual &&
593 test_cmp expect actual
596 test_expect_success 'stdin update ref creates with zero old value' '
597 echo "update $b $m $Z" >stdin &&
598 git update-ref --stdin <stdin &&
599 git rev-parse $m >expect &&
600 git rev-parse $b >actual &&
601 test_cmp expect actual &&
602 git update-ref -d $b
605 test_expect_success 'stdin update ref creates with empty old value' '
606 echo "update $b $m $E" >stdin &&
607 git update-ref --stdin <stdin &&
608 git rev-parse $m >expect &&
609 git rev-parse $b >actual &&
610 test_cmp expect actual
613 test_expect_success 'stdin create ref works with path with space to blob' '
614 echo "create refs/blobs/pws \"$m:$pws\"" >stdin &&
615 git update-ref --stdin <stdin &&
616 git rev-parse "$m:$pws" >expect &&
617 git rev-parse refs/blobs/pws >actual &&
618 test_cmp expect actual &&
619 git update-ref -d refs/blobs/pws
622 test_expect_success 'stdin update ref fails with wrong old value' '
623 echo "update $c $m $m~1" >stdin &&
624 test_must_fail git update-ref --stdin <stdin 2>err &&
625 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
626 test_must_fail git rev-parse --verify -q $c
629 test_expect_success 'stdin update ref fails with bad old value' '
630 echo "update $c $m does-not-exist" >stdin &&
631 test_must_fail git update-ref --stdin <stdin 2>err &&
632 grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
633 test_must_fail git rev-parse --verify -q $c
636 test_expect_success 'stdin create ref fails with bad new value' '
637 echo "create $c does-not-exist" >stdin &&
638 test_must_fail git update-ref --stdin <stdin 2>err &&
639 grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
640 test_must_fail git rev-parse --verify -q $c
643 test_expect_success 'stdin create ref fails with zero new value' '
644 echo "create $c " >stdin &&
645 test_must_fail git update-ref --stdin <stdin 2>err &&
646 grep "fatal: create $c: zero <newvalue>" err &&
647 test_must_fail git rev-parse --verify -q $c
650 test_expect_success 'stdin update ref works with right old value' '
651 echo "update $b $m~1 $m" >stdin &&
652 git update-ref --stdin <stdin &&
653 git rev-parse $m~1 >expect &&
654 git rev-parse $b >actual &&
655 test_cmp expect actual
658 test_expect_success 'stdin delete ref fails with wrong old value' '
659 echo "delete $a $m~1" >stdin &&
660 test_must_fail git update-ref --stdin <stdin 2>err &&
661 grep "fatal: cannot lock ref '"'"'$a'"'"'" err &&
662 git rev-parse $m >expect &&
663 git rev-parse $a >actual &&
664 test_cmp expect actual
667 test_expect_success 'stdin delete ref fails with zero old value' '
668 echo "delete $a " >stdin &&
669 test_must_fail git update-ref --stdin <stdin 2>err &&
670 grep "fatal: delete $a: zero <oldvalue>" err &&
671 git rev-parse $m >expect &&
672 git rev-parse $a >actual &&
673 test_cmp expect actual
676 test_expect_success 'stdin update symref works option no-deref' '
677 git symbolic-ref TESTSYMREF $b &&
678 cat >stdin <<-EOF &&
679 option no-deref
680 update TESTSYMREF $a $b
682 git update-ref --stdin <stdin &&
683 git rev-parse TESTSYMREF >expect &&
684 git rev-parse $a >actual &&
685 test_cmp expect actual &&
686 git rev-parse $m~1 >expect &&
687 git rev-parse $b >actual &&
688 test_cmp expect actual
691 test_expect_success 'stdin delete symref works option no-deref' '
692 git symbolic-ref TESTSYMREF $b &&
693 cat >stdin <<-EOF &&
694 option no-deref
695 delete TESTSYMREF $b
697 git update-ref --stdin <stdin &&
698 test_must_fail git rev-parse --verify -q TESTSYMREF &&
699 git rev-parse $m~1 >expect &&
700 git rev-parse $b >actual &&
701 test_cmp expect actual
704 test_expect_success 'stdin delete ref works with right old value' '
705 echo "delete $b $m~1" >stdin &&
706 git update-ref --stdin <stdin &&
707 test_must_fail git rev-parse --verify -q $b
710 test_expect_success 'stdin update/create/verify combination works' '
711 cat >stdin <<-EOF &&
712 update $a $m
713 create $b $m
714 verify $c
716 git update-ref --stdin <stdin &&
717 git rev-parse $m >expect &&
718 git rev-parse $a >actual &&
719 test_cmp expect actual &&
720 git rev-parse $b >actual &&
721 test_cmp expect actual &&
722 test_must_fail git rev-parse --verify -q $c
725 test_expect_success 'stdin verify succeeds for correct value' '
726 git rev-parse $m >expect &&
727 echo "verify $m $m" >stdin &&
728 git update-ref --stdin <stdin &&
729 git rev-parse $m >actual &&
730 test_cmp expect actual
733 test_expect_success 'stdin verify succeeds for missing reference' '
734 echo "verify refs/heads/missing $Z" >stdin &&
735 git update-ref --stdin <stdin &&
736 test_must_fail git rev-parse --verify -q refs/heads/missing
739 test_expect_success 'stdin verify treats no value as missing' '
740 echo "verify refs/heads/missing" >stdin &&
741 git update-ref --stdin <stdin &&
742 test_must_fail git rev-parse --verify -q refs/heads/missing
745 test_expect_success 'stdin verify fails for wrong value' '
746 git rev-parse $m >expect &&
747 echo "verify $m $m~1" >stdin &&
748 test_must_fail git update-ref --stdin <stdin &&
749 git rev-parse $m >actual &&
750 test_cmp expect actual
753 test_expect_success 'stdin verify fails for mistaken null value' '
754 git rev-parse $m >expect &&
755 echo "verify $m $Z" >stdin &&
756 test_must_fail git update-ref --stdin <stdin &&
757 git rev-parse $m >actual &&
758 test_cmp expect actual
761 test_expect_success 'stdin verify fails for mistaken empty value' '
762 M=$(git rev-parse $m) &&
763 test_when_finished "git update-ref $m $M" &&
764 git rev-parse $m >expect &&
765 echo "verify $m" >stdin &&
766 test_must_fail git update-ref --stdin <stdin &&
767 git rev-parse $m >actual &&
768 test_cmp expect actual
771 test_expect_success 'stdin update refs works with identity updates' '
772 cat >stdin <<-EOF &&
773 update $a $m $m
774 update $b $m $m
775 update $c $Z $E
777 git update-ref --stdin <stdin &&
778 git rev-parse $m >expect &&
779 git rev-parse $a >actual &&
780 test_cmp expect actual &&
781 git rev-parse $b >actual &&
782 test_cmp expect actual &&
783 test_must_fail git rev-parse --verify -q $c
786 test_expect_success 'stdin update refs fails with wrong old value' '
787 git update-ref $c $m &&
788 cat >stdin <<-EOF &&
789 update $a $m $m
790 update $b $m $m
791 update $c ''
793 test_must_fail git update-ref --stdin <stdin 2>err &&
794 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
795 git rev-parse $m >expect &&
796 git rev-parse $a >actual &&
797 test_cmp expect actual &&
798 git rev-parse $b >actual &&
799 test_cmp expect actual &&
800 git rev-parse $c >actual &&
801 test_cmp expect actual
804 test_expect_success 'stdin delete refs works with packed and loose refs' '
805 git pack-refs --all &&
806 git update-ref $c $m~1 &&
807 cat >stdin <<-EOF &&
808 delete $a $m
809 update $b $Z $m
810 update $c $E $m~1
812 git update-ref --stdin <stdin &&
813 test_must_fail git rev-parse --verify -q $a &&
814 test_must_fail git rev-parse --verify -q $b &&
815 test_must_fail git rev-parse --verify -q $c
818 test_expect_success 'stdin -z works on empty input' '
819 >stdin &&
820 git update-ref -z --stdin <stdin &&
821 git rev-parse --verify -q $m
824 test_expect_success 'stdin -z fails on empty line' '
825 echo "" >stdin &&
826 test_must_fail git update-ref -z --stdin <stdin 2>err &&
827 grep "fatal: whitespace before command: " err
830 test_expect_success 'stdin -z fails on empty command' '
831 printf $F "" >stdin &&
832 test_must_fail git update-ref -z --stdin <stdin 2>err &&
833 grep "fatal: empty command in input" err
836 test_expect_success 'stdin -z fails on only whitespace' '
837 printf $F " " >stdin &&
838 test_must_fail git update-ref -z --stdin <stdin 2>err &&
839 grep "fatal: whitespace before command: " err
842 test_expect_success 'stdin -z fails on leading whitespace' '
843 printf $F " create $a" "$m" >stdin &&
844 test_must_fail git update-ref -z --stdin <stdin 2>err &&
845 grep "fatal: whitespace before command: create $a" err
848 test_expect_success 'stdin -z fails on unknown command' '
849 printf $F "unknown $a" >stdin &&
850 test_must_fail git update-ref -z --stdin <stdin 2>err &&
851 grep "fatal: unknown command: unknown $a" err
854 test_expect_success 'stdin -z fails create with no ref' '
855 printf $F "create " >stdin &&
856 test_must_fail git update-ref -z --stdin <stdin 2>err &&
857 grep "fatal: create: missing <ref>" err
860 test_expect_success 'stdin -z fails create with no new value' '
861 printf $F "create $a" >stdin &&
862 test_must_fail git update-ref -z --stdin <stdin 2>err &&
863 grep "fatal: create $a: unexpected end of input when reading <newvalue>" err
866 test_expect_success 'stdin -z fails create with too many arguments' '
867 printf $F "create $a" "$m" "$m" >stdin &&
868 test_must_fail git update-ref -z --stdin <stdin 2>err &&
869 grep "fatal: unknown command: $m" err
872 test_expect_success 'stdin -z fails update with no ref' '
873 printf $F "update " >stdin &&
874 test_must_fail git update-ref -z --stdin <stdin 2>err &&
875 grep "fatal: update: missing <ref>" err
878 test_expect_success 'stdin -z fails update with too few args' '
879 printf $F "update $a" "$m" >stdin &&
880 test_must_fail git update-ref -z --stdin <stdin 2>err &&
881 grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
884 test_expect_success 'stdin -z emits warning with empty new value' '
885 git update-ref $a $m &&
886 printf $F "update $a" "" "" >stdin &&
887 git update-ref -z --stdin <stdin 2>err &&
888 grep "warning: update $a: missing <newvalue>, treating as zero" err &&
889 test_must_fail git rev-parse --verify -q $a
892 test_expect_success 'stdin -z fails update with no new value' '
893 printf $F "update $a" >stdin &&
894 test_must_fail git update-ref -z --stdin <stdin 2>err &&
895 grep "fatal: update $a: unexpected end of input when reading <newvalue>" err
898 test_expect_success 'stdin -z fails update with no old value' '
899 printf $F "update $a" "$m" >stdin &&
900 test_must_fail git update-ref -z --stdin <stdin 2>err &&
901 grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
904 test_expect_success 'stdin -z fails update with too many arguments' '
905 printf $F "update $a" "$m" "$m" "$m" >stdin &&
906 test_must_fail git update-ref -z --stdin <stdin 2>err &&
907 grep "fatal: unknown command: $m" err
910 test_expect_success 'stdin -z fails delete with no ref' '
911 printf $F "delete " >stdin &&
912 test_must_fail git update-ref -z --stdin <stdin 2>err &&
913 grep "fatal: delete: missing <ref>" err
916 test_expect_success 'stdin -z fails delete with no old value' '
917 printf $F "delete $a" >stdin &&
918 test_must_fail git update-ref -z --stdin <stdin 2>err &&
919 grep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err
922 test_expect_success 'stdin -z fails delete with too many arguments' '
923 printf $F "delete $a" "$m" "$m" >stdin &&
924 test_must_fail git update-ref -z --stdin <stdin 2>err &&
925 grep "fatal: unknown command: $m" err
928 test_expect_success 'stdin -z fails verify with too many arguments' '
929 printf $F "verify $a" "$m" "$m" >stdin &&
930 test_must_fail git update-ref -z --stdin <stdin 2>err &&
931 grep "fatal: unknown command: $m" err
934 test_expect_success 'stdin -z fails verify with no old value' '
935 printf $F "verify $a" >stdin &&
936 test_must_fail git update-ref -z --stdin <stdin 2>err &&
937 grep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err
940 test_expect_success 'stdin -z fails option with unknown name' '
941 printf $F "option unknown" >stdin &&
942 test_must_fail git update-ref -z --stdin <stdin 2>err &&
943 grep "fatal: option unknown: unknown" err
946 test_expect_success 'stdin -z fails with duplicate refs' '
947 printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin &&
948 test_must_fail git update-ref -z --stdin <stdin 2>err &&
949 grep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed." err
952 test_expect_success 'stdin -z create ref works' '
953 printf $F "create $a" "$m" >stdin &&
954 git update-ref -z --stdin <stdin &&
955 git rev-parse $m >expect &&
956 git rev-parse $a >actual &&
957 test_cmp expect actual
960 test_expect_success 'stdin -z update ref creates with zero old value' '
961 printf $F "update $b" "$m" "$Z" >stdin &&
962 git update-ref -z --stdin <stdin &&
963 git rev-parse $m >expect &&
964 git rev-parse $b >actual &&
965 test_cmp expect actual &&
966 git update-ref -d $b
969 test_expect_success 'stdin -z update ref creates with empty old value' '
970 printf $F "update $b" "$m" "" >stdin &&
971 git update-ref -z --stdin <stdin &&
972 git rev-parse $m >expect &&
973 git rev-parse $b >actual &&
974 test_cmp expect actual
977 test_expect_success 'stdin -z create ref works with path with space to blob' '
978 printf $F "create refs/blobs/pws" "$m:$pws" >stdin &&
979 git update-ref -z --stdin <stdin &&
980 git rev-parse "$m:$pws" >expect &&
981 git rev-parse refs/blobs/pws >actual &&
982 test_cmp expect actual &&
983 git update-ref -d refs/blobs/pws
986 test_expect_success 'stdin -z update ref fails with wrong old value' '
987 printf $F "update $c" "$m" "$m~1" >stdin &&
988 test_must_fail git update-ref -z --stdin <stdin 2>err &&
989 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
990 test_must_fail git rev-parse --verify -q $c
993 test_expect_success 'stdin -z update ref fails with bad old value' '
994 printf $F "update $c" "$m" "does-not-exist" >stdin &&
995 test_must_fail git update-ref -z --stdin <stdin 2>err &&
996 grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
997 test_must_fail git rev-parse --verify -q $c
1000 test_expect_success 'stdin -z create ref fails when ref exists' '
1001 git update-ref $c $m &&
1002 git rev-parse "$c" >expect &&
1003 printf $F "create $c" "$m~1" >stdin &&
1004 test_must_fail git update-ref -z --stdin <stdin 2>err &&
1005 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
1006 git rev-parse "$c" >actual &&
1007 test_cmp expect actual
1010 test_expect_success 'stdin -z create ref fails with bad new value' '
1011 git update-ref -d "$c" &&
1012 printf $F "create $c" "does-not-exist" >stdin &&
1013 test_must_fail git update-ref -z --stdin <stdin 2>err &&
1014 grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
1015 test_must_fail git rev-parse --verify -q $c
1018 test_expect_success 'stdin -z create ref fails with empty new value' '
1019 printf $F "create $c" "" >stdin &&
1020 test_must_fail git update-ref -z --stdin <stdin 2>err &&
1021 grep "fatal: create $c: missing <newvalue>" err &&
1022 test_must_fail git rev-parse --verify -q $c
1025 test_expect_success 'stdin -z update ref works with right old value' '
1026 printf $F "update $b" "$m~1" "$m" >stdin &&
1027 git update-ref -z --stdin <stdin &&
1028 git rev-parse $m~1 >expect &&
1029 git rev-parse $b >actual &&
1030 test_cmp expect actual
1033 test_expect_success 'stdin -z delete ref fails with wrong old value' '
1034 printf $F "delete $a" "$m~1" >stdin &&
1035 test_must_fail git update-ref -z --stdin <stdin 2>err &&
1036 grep "fatal: cannot lock ref '"'"'$a'"'"'" err &&
1037 git rev-parse $m >expect &&
1038 git rev-parse $a >actual &&
1039 test_cmp expect actual
1042 test_expect_success 'stdin -z delete ref fails with zero old value' '
1043 printf $F "delete $a" "$Z" >stdin &&
1044 test_must_fail git update-ref -z --stdin <stdin 2>err &&
1045 grep "fatal: delete $a: zero <oldvalue>" err &&
1046 git rev-parse $m >expect &&
1047 git rev-parse $a >actual &&
1048 test_cmp expect actual
1051 test_expect_success 'stdin -z update symref works option no-deref' '
1052 git symbolic-ref TESTSYMREF $b &&
1053 printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin &&
1054 git update-ref -z --stdin <stdin &&
1055 git rev-parse TESTSYMREF >expect &&
1056 git rev-parse $a >actual &&
1057 test_cmp expect actual &&
1058 git rev-parse $m~1 >expect &&
1059 git rev-parse $b >actual &&
1060 test_cmp expect actual
1063 test_expect_success 'stdin -z delete symref works option no-deref' '
1064 git symbolic-ref TESTSYMREF $b &&
1065 printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin &&
1066 git update-ref -z --stdin <stdin &&
1067 test_must_fail git rev-parse --verify -q TESTSYMREF &&
1068 git rev-parse $m~1 >expect &&
1069 git rev-parse $b >actual &&
1070 test_cmp expect actual
1073 test_expect_success 'stdin -z delete ref works with right old value' '
1074 printf $F "delete $b" "$m~1" >stdin &&
1075 git update-ref -z --stdin <stdin &&
1076 test_must_fail git rev-parse --verify -q $b
1079 test_expect_success 'stdin -z update/create/verify combination works' '
1080 printf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin &&
1081 git update-ref -z --stdin <stdin &&
1082 git rev-parse $m >expect &&
1083 git rev-parse $a >actual &&
1084 test_cmp expect actual &&
1085 git rev-parse $b >actual &&
1086 test_cmp expect actual &&
1087 test_must_fail git rev-parse --verify -q $c
1090 test_expect_success 'stdin -z verify succeeds for correct value' '
1091 git rev-parse $m >expect &&
1092 printf $F "verify $m" "$m" >stdin &&
1093 git update-ref -z --stdin <stdin &&
1094 git rev-parse $m >actual &&
1095 test_cmp expect actual
1098 test_expect_success 'stdin -z verify succeeds for missing reference' '
1099 printf $F "verify refs/heads/missing" "$Z" >stdin &&
1100 git update-ref -z --stdin <stdin &&
1101 test_must_fail git rev-parse --verify -q refs/heads/missing
1104 test_expect_success 'stdin -z verify treats no value as missing' '
1105 printf $F "verify refs/heads/missing" "" >stdin &&
1106 git update-ref -z --stdin <stdin &&
1107 test_must_fail git rev-parse --verify -q refs/heads/missing
1110 test_expect_success 'stdin -z verify fails for wrong value' '
1111 git rev-parse $m >expect &&
1112 printf $F "verify $m" "$m~1" >stdin &&
1113 test_must_fail git update-ref -z --stdin <stdin &&
1114 git rev-parse $m >actual &&
1115 test_cmp expect actual
1118 test_expect_success 'stdin -z verify fails for mistaken null value' '
1119 git rev-parse $m >expect &&
1120 printf $F "verify $m" "$Z" >stdin &&
1121 test_must_fail git update-ref -z --stdin <stdin &&
1122 git rev-parse $m >actual &&
1123 test_cmp expect actual
1126 test_expect_success 'stdin -z verify fails for mistaken empty value' '
1127 M=$(git rev-parse $m) &&
1128 test_when_finished "git update-ref $m $M" &&
1129 git rev-parse $m >expect &&
1130 printf $F "verify $m" "" >stdin &&
1131 test_must_fail git update-ref -z --stdin <stdin &&
1132 git rev-parse $m >actual &&
1133 test_cmp expect actual
1136 test_expect_success 'stdin -z update refs works with identity updates' '
1137 printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin &&
1138 git update-ref -z --stdin <stdin &&
1139 git rev-parse $m >expect &&
1140 git rev-parse $a >actual &&
1141 test_cmp expect actual &&
1142 git rev-parse $b >actual &&
1143 test_cmp expect actual &&
1144 test_must_fail git rev-parse --verify -q $c
1147 test_expect_success 'stdin -z update refs fails with wrong old value' '
1148 git update-ref $c $m &&
1149 printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin &&
1150 test_must_fail git update-ref -z --stdin <stdin 2>err &&
1151 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
1152 git rev-parse $m >expect &&
1153 git rev-parse $a >actual &&
1154 test_cmp expect actual &&
1155 git rev-parse $b >actual &&
1156 test_cmp expect actual &&
1157 git rev-parse $c >actual &&
1158 test_cmp expect actual
1161 test_expect_success 'stdin -z delete refs works with packed and loose refs' '
1162 git pack-refs --all &&
1163 git update-ref $c $m~1 &&
1164 printf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin &&
1165 git update-ref -z --stdin <stdin &&
1166 test_must_fail git rev-parse --verify -q $a &&
1167 test_must_fail git rev-parse --verify -q $b &&
1168 test_must_fail git rev-parse --verify -q $c
1171 test_expect_success 'fails with duplicate HEAD update' '
1172 git branch target1 $A &&
1173 git checkout target1 &&
1174 cat >stdin <<-EOF &&
1175 update refs/heads/target1 $C
1176 option no-deref
1177 update HEAD $B
1179 test_must_fail git update-ref --stdin <stdin 2>err &&
1180 grep "fatal: multiple updates for '\''HEAD'\'' (including one via its referent .refs/heads/target1.) are not allowed" err &&
1181 echo "refs/heads/target1" >expect &&
1182 git symbolic-ref HEAD >actual &&
1183 test_cmp expect actual &&
1184 echo "$A" >expect &&
1185 git rev-parse refs/heads/target1 >actual &&
1186 test_cmp expect actual
1189 test_expect_success 'fails with duplicate ref update via symref' '
1190 git branch target2 $A &&
1191 git symbolic-ref refs/heads/symref2 refs/heads/target2 &&
1192 cat >stdin <<-EOF &&
1193 update refs/heads/target2 $C
1194 update refs/heads/symref2 $B
1196 test_must_fail git update-ref --stdin <stdin 2>err &&
1197 grep "fatal: multiple updates for '\''refs/heads/target2'\'' (including one via symref .refs/heads/symref2.) are not allowed" err &&
1198 echo "refs/heads/target2" >expect &&
1199 git symbolic-ref refs/heads/symref2 >actual &&
1200 test_cmp expect actual &&
1201 echo "$A" >expect &&
1202 git rev-parse refs/heads/target2 >actual &&
1203 test_cmp expect actual
1206 run_with_limited_open_files () {
1207 (ulimit -n 32 && "$@")
1210 test_lazy_prereq ULIMIT_FILE_DESCRIPTORS 'run_with_limited_open_files true'
1212 test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
1214 for i in $(test_seq 33)
1216 echo "create refs/heads/$i HEAD"
1217 done >large_input &&
1218 run_with_limited_open_files git update-ref --stdin <large_input &&
1219 git rev-parse --verify -q refs/heads/33
1223 test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
1225 for i in $(test_seq 33)
1227 echo "delete refs/heads/$i HEAD"
1228 done >large_input &&
1229 run_with_limited_open_files git update-ref --stdin <large_input &&
1230 test_must_fail git rev-parse --verify -q refs/heads/33
1234 test_expect_success 'handle per-worktree refs in refs/bisect' '
1235 git commit --allow-empty -m "initial commit" &&
1236 git worktree add -b branch worktree &&
1238 cd worktree &&
1239 git commit --allow-empty -m "test commit" &&
1240 git for-each-ref >for-each-ref.out &&
1241 ! grep refs/bisect for-each-ref.out &&
1242 git update-ref refs/bisect/something HEAD &&
1243 git rev-parse refs/bisect/something >../worktree-head &&
1244 git for-each-ref | grep refs/bisect/something
1245 ) &&
1246 test_path_is_missing .git/refs/bisect &&
1247 test_must_fail git rev-parse refs/bisect/something &&
1248 git update-ref refs/bisect/something HEAD &&
1249 git rev-parse refs/bisect/something >main-head &&
1250 ! test_cmp main-head worktree-head
1253 test_done