refs: add REF_FORCE_CREATE_REFLOG flag
[git/git.git] / t / t1400-update-ref.sh
CommitLineData
6de08ae6
SP
1#!/bin/sh
2#
3# Copyright (c) 2006 Shawn Pearce
4#
5
5be60078 6test_description='Test git update-ref and basic ref logging'
6de08ae6
SP
7. ./test-lib.sh
8
3749fde5 9Z=$_z40
c3b0dec5
LT
10
11test_expect_success setup '
12
13 for name in A B C D E F
14 do
15 test_tick &&
16 T=$(git write-tree) &&
17 sha1=$(echo $name | git commit-tree $T) &&
18 eval $name=$sha1
19 done
20
21'
22
6de08ae6 23m=refs/heads/master
818f477c
SP
24n_dir=refs/heads/gu
25n=$n_dir/fixes
6de08ae6
SP
26
27test_expect_success \
28 "create $m" \
5be60078 29 "git update-ref $m $A &&
8aac4b45 30 test $A"' = $(cat .git/'"$m"')'
6de08ae6
SP
31test_expect_success \
32 "create $m" \
5be60078 33 "git update-ref $m $B $A &&
8aac4b45 34 test $B"' = $(cat .git/'"$m"')'
40672a19
KW
35test_expect_success "fail to delete $m with stale ref" '
36 test_must_fail git update-ref -d $m $A &&
37 test $B = "$(cat .git/$m)"
38'
39test_expect_success "delete $m" '
40 git update-ref -d $m $B &&
41 ! test -f .git/$m
42'
6de08ae6
SP
43rm -f .git/$m
44
3fe8dce6
KW
45test_expect_success "delete $m without oldvalue verification" "
46 git update-ref $m $A &&
47 test $A = \$(cat .git/$m) &&
48 git update-ref -d $m &&
49 ! test -f .git/$m
50"
51rm -f .git/$m
52
818f477c
SP
53test_expect_success \
54 "fail to create $n" \
598f0877
JN
55 "touch .git/$n_dir &&
56 test_must_fail git update-ref $n $A >out 2>err"
818f477c
SP
57rm -f .git/$n_dir out err
58
6de08ae6
SP
59test_expect_success \
60 "create $m (by HEAD)" \
5be60078 61 "git update-ref HEAD $A &&
8aac4b45 62 test $A"' = $(cat .git/'"$m"')'
6de08ae6
SP
63test_expect_success \
64 "create $m (by HEAD)" \
5be60078 65 "git update-ref HEAD $B $A &&
8aac4b45 66 test $B"' = $(cat .git/'"$m"')'
40672a19
KW
67test_expect_success "fail to delete $m (by HEAD) with stale ref" '
68 test_must_fail git update-ref -d HEAD $A &&
69 test $B = $(cat .git/$m)
70'
71test_expect_success "delete $m (by HEAD)" '
72 git update-ref -d HEAD $B &&
73 ! test -f .git/$m
74'
6de08ae6
SP
75rm -f .git/$m
76
75c96e05
JH
77test_expect_success \
78 "create $m (by HEAD)" \
79 "git update-ref HEAD $A &&
80 test $A"' = $(cat .git/'"$m"')'
81test_expect_success \
82 "pack refs" \
83 "git pack-refs --all"
84test_expect_success \
85 "move $m (by HEAD)" \
86 "git update-ref HEAD $B $A &&
87 test $B"' = $(cat .git/'"$m"')'
b274a714 88test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" '
75c96e05
JH
89 git update-ref -d HEAD $B &&
90 ! grep "$m" .git/packed-refs &&
91 ! test -f .git/$m
92'
93rm -f .git/$m
94
569740bd
MV
95cp -f .git/HEAD .git/HEAD.orig
96test_expect_success "delete symref without dereference" '
97 git update-ref --no-deref -d HEAD &&
98 ! test -f .git/HEAD
99'
100cp -f .git/HEAD.orig .git/HEAD
101
045a476f
MV
102test_expect_success "delete symref without dereference when the referred ref is packed" '
103 echo foo >foo.c &&
104 git add foo.c &&
105 git commit -m foo &&
106 git pack-refs --all &&
107 git update-ref --no-deref -d HEAD &&
108 ! test -f .git/HEAD
109'
110cp -f .git/HEAD.orig .git/HEAD
111git update-ref -d $m
112
62a2d525
JN
113test_expect_success 'update-ref -d is not confused by self-reference' '
114 git symbolic-ref refs/heads/self refs/heads/self &&
115 test_when_finished "rm -f .git/refs/heads/self" &&
116 test_path_is_file .git/refs/heads/self &&
117 test_must_fail git update-ref -d refs/heads/self &&
118 test_path_is_file .git/refs/heads/self
119'
120
121test_expect_success 'update-ref --no-deref -d can delete self-reference' '
122 git symbolic-ref refs/heads/self refs/heads/self &&
123 test_when_finished "rm -f .git/refs/heads/self" &&
124 test_path_is_file .git/refs/heads/self &&
125 git update-ref --no-deref -d refs/heads/self &&
126 test_path_is_missing .git/refs/heads/self
127'
128
129test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' '
130 >.git/refs/heads/bad &&
131 test_when_finished "rm -f .git/refs/heads/bad" &&
132 git symbolic-ref refs/heads/ref-to-bad refs/heads/bad &&
133 test_when_finished "rm -f .git/refs/heads/ref-to-bad" &&
134 test_path_is_file .git/refs/heads/ref-to-bad &&
135 git update-ref --no-deref -d refs/heads/ref-to-bad &&
136 test_path_is_missing .git/refs/heads/ref-to-bad
137'
138
41ac414e 139test_expect_success '(not) create HEAD with old sha1' "
d492b31c 140 test_must_fail git update-ref HEAD $A $B
41ac414e
JH
141"
142test_expect_success "(not) prior created .git/$m" "
143 ! test -f .git/$m
144"
6de08ae6
SP
145rm -f .git/$m
146
147test_expect_success \
148 "create HEAD" \
5be60078 149 "git update-ref HEAD $A"
41ac414e 150test_expect_success '(not) change HEAD with wrong SHA1' "
d492b31c 151 test_must_fail git update-ref HEAD $B $Z
41ac414e
JH
152"
153test_expect_success "(not) changed .git/$m" "
154 ! test $B"' = $(cat .git/'"$m"')
155'
6de08ae6
SP
156rm -f .git/$m
157
0bee5918
SP
158: a repository with working tree always has reflog these days...
159: >.git/logs/refs/heads/master
6de08ae6
SP
160test_expect_success \
161 "create $m (logged by touch)" \
162 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
5be60078 163 git update-ref HEAD '"$A"' -m "Initial Creation" &&
8aac4b45 164 test '"$A"' = $(cat .git/'"$m"')'
6de08ae6
SP
165test_expect_success \
166 "update $m (logged by touch)" \
167 'GIT_COMMITTER_DATE="2005-05-26 23:31" \
5be60078 168 git update-ref HEAD'" $B $A "'-m "Switch" &&
8aac4b45 169 test '"$B"' = $(cat .git/'"$m"')'
6de08ae6
SP
170test_expect_success \
171 "set $m (logged by touch)" \
172 'GIT_COMMITTER_DATE="2005-05-26 23:41" \
5be60078 173 git update-ref HEAD'" $A &&
8aac4b45 174 test $A"' = $(cat .git/'"$m"')'
6de08ae6
SP
175
176cat >expect <<EOF
177$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
178$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
179$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
180EOF
181test_expect_success \
182 "verifying $m's log" \
188c3827 183 "test_cmp expect .git/logs/$m"
6de08ae6
SP
184rm -rf .git/$m .git/logs expect
185
186test_expect_success \
187 'enable core.logAllRefUpdates' \
5be60078
JH
188 'git config core.logAllRefUpdates true &&
189 test true = $(git config --bool --get core.logAllRefUpdates)'
6de08ae6
SP
190
191test_expect_success \
192 "create $m (logged by config)" \
193 'GIT_COMMITTER_DATE="2005-05-26 23:32" \
5be60078 194 git update-ref HEAD'" $A "'-m "Initial Creation" &&
8aac4b45 195 test '"$A"' = $(cat .git/'"$m"')'
6de08ae6
SP
196test_expect_success \
197 "update $m (logged by config)" \
198 'GIT_COMMITTER_DATE="2005-05-26 23:33" \
5be60078 199 git update-ref HEAD'" $B $A "'-m "Switch" &&
8aac4b45 200 test '"$B"' = $(cat .git/'"$m"')'
6de08ae6
SP
201test_expect_success \
202 "set $m (logged by config)" \
203 'GIT_COMMITTER_DATE="2005-05-26 23:43" \
5be60078 204 git update-ref HEAD '"$A &&
8aac4b45 205 test $A"' = $(cat .git/'"$m"')'
6de08ae6
SP
206
207cat >expect <<EOF
208$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation
209$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
210$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
211EOF
212test_expect_success \
213 "verifying $m's log" \
188c3827 214 'test_cmp expect .git/logs/$m'
6de08ae6
SP
215rm -f .git/$m .git/logs/$m expect
216
5be60078 217git update-ref $m $D
e5229042 218cat >.git/logs/$m <<EOF
d1a4489a
JK
2190000000000000000000000000000000000000000 $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
220$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
e5229042
SP
221$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
222$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
223$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
224EOF
225
226ed="Thu, 26 May 2005 18:32:00 -0500"
227gd="Thu, 26 May 2005 18:33:00 -0500"
228ld="Thu, 26 May 2005 18:43:00 -0500"
229test_expect_success \
cce91a2c 230 'Query "master@{May 25 2005}" (before history)' \
2dec68cf 231 'rm -f o e &&
5be60078 232 git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
8aac4b45 233 test '"$C"' = $(cat o) &&
16d7cc90 234 test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
e5229042 235test_expect_success \
cce91a2c 236 "Query master@{2005-05-25} (before history)" \
2dec68cf 237 'rm -f o e &&
5be60078 238 git rev-parse --verify master@{2005-05-25} >o 2>e &&
8aac4b45 239 test '"$C"' = $(cat o) &&
16d7cc90 240 echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
e5229042 241test_expect_success \
cce91a2c 242 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
2dec68cf 243 'rm -f o e &&
5be60078 244 git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
8aac4b45 245 test '"$C"' = $(cat o) &&
16d7cc90 246 test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
e5229042 247test_expect_success \
cce91a2c 248 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
2dec68cf 249 'rm -f o e &&
5be60078 250 git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
d1a4489a
JK
251 test '"$C"' = $(cat o) &&
252 test "" = "$(cat e)"'
253test_expect_success \
254 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
2dec68cf 255 'rm -f o e &&
d1a4489a 256 git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
8aac4b45 257 test '"$A"' = $(cat o) &&
e5229042
SP
258 test "" = "$(cat e)"'
259test_expect_success \
cce91a2c 260 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
2dec68cf 261 'rm -f o e &&
5be60078 262 git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
8aac4b45 263 test '"$B"' = $(cat o) &&
4207ed28 264 test "warning: Log for ref '"$m has gap after $gd"'." = "$(cat e)"'
e5229042 265test_expect_success \
cce91a2c 266 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
2dec68cf 267 'rm -f o e &&
5be60078 268 git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
8aac4b45 269 test '"$Z"' = $(cat o) &&
e5229042
SP
270 test "" = "$(cat e)"'
271test_expect_success \
cce91a2c 272 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
2dec68cf 273 'rm -f o e &&
5be60078 274 git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
8aac4b45 275 test '"$E"' = $(cat o) &&
e5229042
SP
276 test "" = "$(cat e)"'
277test_expect_success \
cce91a2c 278 'Query "master@{2005-05-28}" (past end of history)' \
2dec68cf 279 'rm -f o e &&
5be60078 280 git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
8aac4b45 281 test '"$D"' = $(cat o) &&
4207ed28 282 test "warning: Log for ref '"$m unexpectedly ended on $ld"'." = "$(cat e)"'
e5229042 283
cce91a2c
SP
284
285rm -f .git/$m .git/logs/$m expect
286
287test_expect_success \
288 'creating initial files' \
9c7466fa 289 'echo TEST >F &&
5be60078 290 git add F &&
9c7466fa 291 GIT_AUTHOR_DATE="2005-05-26 23:30" \
0cb0e143 292 GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
2dec68cf 293 h_TEST=$(git rev-parse --verify HEAD) &&
9c7466fa
SP
294 echo The other day this did not work. >M &&
295 echo And then Bob told me how to fix it. >>M &&
296 echo OTHER >F &&
297 GIT_AUTHOR_DATE="2005-05-26 23:41" \
0cb0e143 298 GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a &&
5be60078 299 h_OTHER=$(git rev-parse --verify HEAD) &&
a3a733e6 300 GIT_AUTHOR_DATE="2005-05-26 23:44" \
0cb0e143 301 GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend &&
5be60078 302 h_FIXED=$(git rev-parse --verify HEAD) &&
a3a733e6
SP
303 echo Merged initial commit and a later commit. >M &&
304 echo $h_TEST >.git/MERGE_HEAD &&
305 GIT_AUTHOR_DATE="2005-05-26 23:45" \
0cb0e143 306 GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
d9c8344b 307 h_MERGED=$(git rev-parse --verify HEAD) &&
9c7466fa
SP
308 rm -f M'
309
310cat >expect <<EOF
a3a733e6 311$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add
9c7466fa 312$h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 commit: The other day this did not work.
a3a733e6
SP
313$h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 commit (amend): The other day this did not work.
314$h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit.
9c7466fa
SP
315EOF
316test_expect_success \
0cb0e143 317 'git commit logged updates' \
188c3827 318 "test_cmp expect .git/logs/$m"
a3a733e6 319unset h_TEST h_OTHER h_FIXED h_MERGED
cce91a2c
SP
320
321test_expect_success \
5be60078
JH
322 'git cat-file blob master:F (expect OTHER)' \
323 'test OTHER = $(git cat-file blob master:F)'
cce91a2c 324test_expect_success \
5be60078
JH
325 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
326 'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")'
cce91a2c 327test_expect_success \
5be60078
JH
328 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
329 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'
cce91a2c 330
c6268bc0
BK
331a=refs/heads/a
332b=refs/heads/b
333c=refs/heads/c
334E='""'
335F='%s\0'
336pws='path with space'
337
338test_expect_success 'stdin test setup' '
339 echo "$pws" >"$pws" &&
340 git add -- "$pws" &&
341 git commit -m "$pws"
342'
343
344test_expect_success '-z fails without --stdin' '
345 test_must_fail git update-ref -z $m $m $m 2>err &&
346 grep "usage: git update-ref" err
347'
348
349test_expect_success 'stdin works with no input' '
350 >stdin &&
351 git update-ref --stdin <stdin &&
352 git rev-parse --verify -q $m
353'
354
355test_expect_success 'stdin fails on empty line' '
356 echo "" >stdin &&
357 test_must_fail git update-ref --stdin <stdin 2>err &&
358 grep "fatal: empty command in input" err
359'
360
361test_expect_success 'stdin fails on only whitespace' '
362 echo " " >stdin &&
363 test_must_fail git update-ref --stdin <stdin 2>err &&
364 grep "fatal: whitespace before command: " err
365'
366
367test_expect_success 'stdin fails on leading whitespace' '
368 echo " create $a $m" >stdin &&
369 test_must_fail git update-ref --stdin <stdin 2>err &&
370 grep "fatal: whitespace before command: create $a $m" err
371'
372
373test_expect_success 'stdin fails on unknown command' '
374 echo "unknown $a" >stdin &&
375 test_must_fail git update-ref --stdin <stdin 2>err &&
376 grep "fatal: unknown command: unknown $a" err
377'
378
20fcffcc 379test_expect_success 'stdin fails on unbalanced quotes' '
c6268bc0
BK
380 echo "create $a \"master" >stdin &&
381 test_must_fail git update-ref --stdin <stdin 2>err &&
382 grep "fatal: badly quoted argument: \\\"master" err
383'
384
20fcffcc
MH
385test_expect_success 'stdin fails on invalid escape' '
386 echo "create $a \"ma\zter\"" >stdin &&
387 test_must_fail git update-ref --stdin <stdin 2>err &&
388 grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err
389'
390
697a4151 391test_expect_success 'stdin fails on junk after quoted argument' '
c6268bc0
BK
392 echo "create \"$a\"master" >stdin &&
393 test_must_fail git update-ref --stdin <stdin 2>err &&
697a4151 394 grep "fatal: unexpected character after quoted argument: \\\"$a\\\"master" err
c6268bc0
BK
395'
396
397test_expect_success 'stdin fails create with no ref' '
398 echo "create " >stdin &&
399 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 400 grep "fatal: create: missing <ref>" err
c6268bc0
BK
401'
402
c6268bc0
BK
403test_expect_success 'stdin fails create with no new value' '
404 echo "create $a" >stdin &&
405 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 406 grep "fatal: create $a: missing <newvalue>" err
c6268bc0
BK
407'
408
409test_expect_success 'stdin fails create with too many arguments' '
410 echo "create $a $m $m" >stdin &&
411 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 412 grep "fatal: create $a: extra input: $m" err
c6268bc0
BK
413'
414
415test_expect_success 'stdin fails update with no ref' '
416 echo "update " >stdin &&
417 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 418 grep "fatal: update: missing <ref>" err
c6268bc0
BK
419'
420
c6268bc0
BK
421test_expect_success 'stdin fails update with no new value' '
422 echo "update $a" >stdin &&
423 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 424 grep "fatal: update $a: missing <newvalue>" err
c6268bc0
BK
425'
426
427test_expect_success 'stdin fails update with too many arguments' '
428 echo "update $a $m $m $m" >stdin &&
429 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 430 grep "fatal: update $a: extra input: $m" err
c6268bc0
BK
431'
432
433test_expect_success 'stdin fails delete with no ref' '
434 echo "delete " >stdin &&
435 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 436 grep "fatal: delete: missing <ref>" err
c6268bc0
BK
437'
438
c6268bc0
BK
439test_expect_success 'stdin fails delete with too many arguments' '
440 echo "delete $a $m $m" >stdin &&
441 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 442 grep "fatal: delete $a: extra input: $m" err
c6268bc0
BK
443'
444
445test_expect_success 'stdin fails verify with too many arguments' '
446 echo "verify $a $m $m" >stdin &&
447 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 448 grep "fatal: verify $a: extra input: $m" err
c6268bc0
BK
449'
450
451test_expect_success 'stdin fails option with unknown name' '
452 echo "option unknown" >stdin &&
453 test_must_fail git update-ref --stdin <stdin 2>err &&
454 grep "fatal: option unknown: unknown" err
455'
456
457test_expect_success 'stdin fails with duplicate refs' '
458 cat >stdin <<-EOF &&
459 create $a $m
460 create $b $m
461 create $a $m
462 EOF
463 test_must_fail git update-ref --stdin <stdin 2>err &&
464 grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err
465'
466
467test_expect_success 'stdin create ref works' '
468 echo "create $a $m" >stdin &&
469 git update-ref --stdin <stdin &&
470 git rev-parse $m >expect &&
471 git rev-parse $a >actual &&
472 test_cmp expect actual
473'
474
20fcffcc
MH
475test_expect_success 'stdin succeeds with quoted argument' '
476 git update-ref -d $a &&
477 echo "create $a \"$m\"" >stdin &&
478 git update-ref --stdin <stdin &&
479 git rev-parse $m >expect &&
480 git rev-parse $a >actual &&
481 test_cmp expect actual
482'
483
484test_expect_success 'stdin succeeds with escaped character' '
485 git update-ref -d $a &&
486 echo "create $a \"ma\\163ter\"" >stdin &&
487 git update-ref --stdin <stdin &&
488 git rev-parse $m >expect &&
489 git rev-parse $a >actual &&
490 test_cmp expect actual
491'
492
c6268bc0
BK
493test_expect_success 'stdin update ref creates with zero old value' '
494 echo "update $b $m $Z" >stdin &&
495 git update-ref --stdin <stdin &&
496 git rev-parse $m >expect &&
497 git rev-parse $b >actual &&
498 test_cmp expect actual &&
499 git update-ref -d $b
500'
501
502test_expect_success 'stdin update ref creates with empty old value' '
503 echo "update $b $m $E" >stdin &&
504 git update-ref --stdin <stdin &&
505 git rev-parse $m >expect &&
506 git rev-parse $b >actual &&
507 test_cmp expect actual
508'
509
510test_expect_success 'stdin create ref works with path with space to blob' '
511 echo "create refs/blobs/pws \"$m:$pws\"" >stdin &&
512 git update-ref --stdin <stdin &&
513 git rev-parse "$m:$pws" >expect &&
514 git rev-parse refs/blobs/pws >actual &&
515 test_cmp expect actual &&
516 git update-ref -d refs/blobs/pws
517'
518
519test_expect_success 'stdin update ref fails with wrong old value' '
520 echo "update $c $m $m~1" >stdin &&
521 test_must_fail git update-ref --stdin <stdin 2>err &&
c2e0a718 522 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
c6268bc0
BK
523 test_must_fail git rev-parse --verify -q $c
524'
525
526test_expect_success 'stdin update ref fails with bad old value' '
527 echo "update $c $m does-not-exist" >stdin &&
528 test_must_fail git update-ref --stdin <stdin 2>err &&
9255f059 529 grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
c6268bc0
BK
530 test_must_fail git rev-parse --verify -q $c
531'
532
533test_expect_success 'stdin create ref fails with bad new value' '
534 echo "create $c does-not-exist" >stdin &&
535 test_must_fail git update-ref --stdin <stdin 2>err &&
9255f059 536 grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
c6268bc0
BK
537 test_must_fail git rev-parse --verify -q $c
538'
539
540test_expect_success 'stdin create ref fails with zero new value' '
541 echo "create $c " >stdin &&
542 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 543 grep "fatal: create $c: zero <newvalue>" err &&
c6268bc0
BK
544 test_must_fail git rev-parse --verify -q $c
545'
546
547test_expect_success 'stdin update ref works with right old value' '
548 echo "update $b $m~1 $m" >stdin &&
549 git update-ref --stdin <stdin &&
550 git rev-parse $m~1 >expect &&
551 git rev-parse $b >actual &&
552 test_cmp expect actual
553'
554
555test_expect_success 'stdin delete ref fails with wrong old value' '
556 echo "delete $a $m~1" >stdin &&
557 test_must_fail git update-ref --stdin <stdin 2>err &&
c2e0a718 558 grep "fatal: cannot lock ref '"'"'$a'"'"'" err &&
c6268bc0
BK
559 git rev-parse $m >expect &&
560 git rev-parse $a >actual &&
561 test_cmp expect actual
562'
563
564test_expect_success 'stdin delete ref fails with zero old value' '
565 echo "delete $a " >stdin &&
566 test_must_fail git update-ref --stdin <stdin 2>err &&
f11b09fb 567 grep "fatal: delete $a: zero <oldvalue>" err &&
c6268bc0
BK
568 git rev-parse $m >expect &&
569 git rev-parse $a >actual &&
570 test_cmp expect actual
571'
572
573test_expect_success 'stdin update symref works option no-deref' '
574 git symbolic-ref TESTSYMREF $b &&
575 cat >stdin <<-EOF &&
576 option no-deref
577 update TESTSYMREF $a $b
578 EOF
579 git update-ref --stdin <stdin &&
580 git rev-parse TESTSYMREF >expect &&
581 git rev-parse $a >actual &&
582 test_cmp expect actual &&
583 git rev-parse $m~1 >expect &&
584 git rev-parse $b >actual &&
585 test_cmp expect actual
586'
587
588test_expect_success 'stdin delete symref works option no-deref' '
589 git symbolic-ref TESTSYMREF $b &&
590 cat >stdin <<-EOF &&
591 option no-deref
592 delete TESTSYMREF $b
593 EOF
594 git update-ref --stdin <stdin &&
595 test_must_fail git rev-parse --verify -q TESTSYMREF &&
596 git rev-parse $m~1 >expect &&
597 git rev-parse $b >actual &&
598 test_cmp expect actual
599'
600
601test_expect_success 'stdin delete ref works with right old value' '
602 echo "delete $b $m~1" >stdin &&
603 git update-ref --stdin <stdin &&
604 test_must_fail git rev-parse --verify -q $b
605'
606
607test_expect_success 'stdin update/create/verify combination works' '
608 cat >stdin <<-EOF &&
609 update $a $m
610 create $b $m
611 verify $c
612 EOF
613 git update-ref --stdin <stdin &&
614 git rev-parse $m >expect &&
615 git rev-parse $a >actual &&
616 test_cmp expect actual &&
617 git rev-parse $b >actual &&
618 test_cmp expect actual &&
619 test_must_fail git rev-parse --verify -q $c
620'
621
a46e41fc
MH
622test_expect_success 'stdin verify succeeds for correct value' '
623 git rev-parse $m >expect &&
624 echo "verify $m $m" >stdin &&
625 git update-ref --stdin <stdin &&
626 git rev-parse $m >actual &&
627 test_cmp expect actual
628'
629
630test_expect_success 'stdin verify succeeds for missing reference' '
631 echo "verify refs/heads/missing $Z" >stdin &&
632 git update-ref --stdin <stdin &&
633 test_must_fail git rev-parse --verify -q refs/heads/missing
634'
635
636test_expect_success 'stdin verify treats no value as missing' '
637 echo "verify refs/heads/missing" >stdin &&
638 git update-ref --stdin <stdin &&
639 test_must_fail git rev-parse --verify -q refs/heads/missing
640'
641
642test_expect_success 'stdin verify fails for wrong value' '
643 git rev-parse $m >expect &&
644 echo "verify $m $m~1" >stdin &&
645 test_must_fail git update-ref --stdin <stdin &&
646 git rev-parse $m >actual &&
647 test_cmp expect actual
648'
649
650test_expect_success 'stdin verify fails for mistaken null value' '
651 git rev-parse $m >expect &&
652 echo "verify $m $Z" >stdin &&
653 test_must_fail git update-ref --stdin <stdin &&
654 git rev-parse $m >actual &&
655 test_cmp expect actual
656'
657
0e729c7e 658test_expect_success 'stdin verify fails for mistaken empty value' '
a46e41fc
MH
659 M=$(git rev-parse $m) &&
660 test_when_finished "git update-ref $m $M" &&
661 git rev-parse $m >expect &&
662 echo "verify $m" >stdin &&
663 test_must_fail git update-ref --stdin <stdin &&
664 git rev-parse $m >actual &&
665 test_cmp expect actual
666'
667
c6268bc0
BK
668test_expect_success 'stdin update refs works with identity updates' '
669 cat >stdin <<-EOF &&
670 update $a $m $m
671 update $b $m $m
672 update $c $Z $E
673 EOF
674 git update-ref --stdin <stdin &&
675 git rev-parse $m >expect &&
676 git rev-parse $a >actual &&
677 test_cmp expect actual &&
678 git rev-parse $b >actual &&
679 test_cmp expect actual &&
680 test_must_fail git rev-parse --verify -q $c
681'
682
683test_expect_success 'stdin update refs fails with wrong old value' '
684 git update-ref $c $m &&
685 cat >stdin <<-EOF &&
686 update $a $m $m
687 update $b $m $m
688 update $c ''
689 EOF
690 test_must_fail git update-ref --stdin <stdin 2>err &&
c2e0a718 691 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
c6268bc0
BK
692 git rev-parse $m >expect &&
693 git rev-parse $a >actual &&
694 test_cmp expect actual &&
695 git rev-parse $b >actual &&
696 test_cmp expect actual &&
697 git rev-parse $c >actual &&
698 test_cmp expect actual
699'
700
701test_expect_success 'stdin delete refs works with packed and loose refs' '
702 git pack-refs --all &&
703 git update-ref $c $m~1 &&
704 cat >stdin <<-EOF &&
705 delete $a $m
706 update $b $Z $m
707 update $c $E $m~1
708 EOF
709 git update-ref --stdin <stdin &&
710 test_must_fail git rev-parse --verify -q $a &&
711 test_must_fail git rev-parse --verify -q $b &&
712 test_must_fail git rev-parse --verify -q $c
713'
714
715test_expect_success 'stdin -z works on empty input' '
716 >stdin &&
717 git update-ref -z --stdin <stdin &&
718 git rev-parse --verify -q $m
719'
720
721test_expect_success 'stdin -z fails on empty line' '
722 echo "" >stdin &&
723 test_must_fail git update-ref -z --stdin <stdin 2>err &&
724 grep "fatal: whitespace before command: " err
725'
726
727test_expect_success 'stdin -z fails on empty command' '
728 printf $F "" >stdin &&
729 test_must_fail git update-ref -z --stdin <stdin 2>err &&
730 grep "fatal: empty command in input" err
731'
732
733test_expect_success 'stdin -z fails on only whitespace' '
734 printf $F " " >stdin &&
735 test_must_fail git update-ref -z --stdin <stdin 2>err &&
736 grep "fatal: whitespace before command: " err
737'
738
739test_expect_success 'stdin -z fails on leading whitespace' '
740 printf $F " create $a" "$m" >stdin &&
741 test_must_fail git update-ref -z --stdin <stdin 2>err &&
742 grep "fatal: whitespace before command: create $a" err
743'
744
745test_expect_success 'stdin -z fails on unknown command' '
746 printf $F "unknown $a" >stdin &&
747 test_must_fail git update-ref -z --stdin <stdin 2>err &&
748 grep "fatal: unknown command: unknown $a" err
749'
750
751test_expect_success 'stdin -z fails create with no ref' '
752 printf $F "create " >stdin &&
753 test_must_fail git update-ref -z --stdin <stdin 2>err &&
f11b09fb 754 grep "fatal: create: missing <ref>" err
c6268bc0
BK
755'
756
c6268bc0
BK
757test_expect_success 'stdin -z fails create with no new value' '
758 printf $F "create $a" >stdin &&
759 test_must_fail git update-ref -z --stdin <stdin 2>err &&
726f6916 760 grep "fatal: create $a: unexpected end of input when reading <newvalue>" err
c6268bc0
BK
761'
762
763test_expect_success 'stdin -z fails create with too many arguments' '
764 printf $F "create $a" "$m" "$m" >stdin &&
765 test_must_fail git update-ref -z --stdin <stdin 2>err &&
766 grep "fatal: unknown command: $m" err
767'
768
769test_expect_success 'stdin -z fails update with no ref' '
770 printf $F "update " >stdin &&
771 test_must_fail git update-ref -z --stdin <stdin 2>err &&
f11b09fb 772 grep "fatal: update: missing <ref>" err
c6268bc0
BK
773'
774
ff6ee395
MH
775test_expect_success 'stdin -z fails update with too few args' '
776 printf $F "update $a" "$m" >stdin &&
777 test_must_fail git update-ref -z --stdin <stdin 2>err &&
726f6916 778 grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
c6268bc0
BK
779'
780
1fbd5049 781test_expect_success 'stdin -z emits warning with empty new value' '
191f241b
MH
782 git update-ref $a $m &&
783 printf $F "update $a" "" "" >stdin &&
1fbd5049
MH
784 git update-ref -z --stdin <stdin 2>err &&
785 grep "warning: update $a: missing <newvalue>, treating as zero" err &&
191f241b
MH
786 test_must_fail git rev-parse --verify -q $a
787'
788
c6268bc0
BK
789test_expect_success 'stdin -z fails update with no new value' '
790 printf $F "update $a" >stdin &&
791 test_must_fail git update-ref -z --stdin <stdin 2>err &&
726f6916 792 grep "fatal: update $a: unexpected end of input when reading <newvalue>" err
c6268bc0
BK
793'
794
795test_expect_success 'stdin -z fails update with no old value' '
796 printf $F "update $a" "$m" >stdin &&
797 test_must_fail git update-ref -z --stdin <stdin 2>err &&
726f6916 798 grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
c6268bc0
BK
799'
800
801test_expect_success 'stdin -z fails update with too many arguments' '
802 printf $F "update $a" "$m" "$m" "$m" >stdin &&
803 test_must_fail git update-ref -z --stdin <stdin 2>err &&
804 grep "fatal: unknown command: $m" err
805'
806
807test_expect_success 'stdin -z fails delete with no ref' '
808 printf $F "delete " >stdin &&
809 test_must_fail git update-ref -z --stdin <stdin 2>err &&
f11b09fb 810 grep "fatal: delete: missing <ref>" err
c6268bc0
BK
811'
812
c6268bc0
BK
813test_expect_success 'stdin -z fails delete with no old value' '
814 printf $F "delete $a" >stdin &&
815 test_must_fail git update-ref -z --stdin <stdin 2>err &&
726f6916 816 grep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err
c6268bc0
BK
817'
818
819test_expect_success 'stdin -z fails delete with too many arguments' '
820 printf $F "delete $a" "$m" "$m" >stdin &&
821 test_must_fail git update-ref -z --stdin <stdin 2>err &&
822 grep "fatal: unknown command: $m" err
823'
824
825test_expect_success 'stdin -z fails verify with too many arguments' '
826 printf $F "verify $a" "$m" "$m" >stdin &&
827 test_must_fail git update-ref -z --stdin <stdin 2>err &&
828 grep "fatal: unknown command: $m" err
829'
830
831test_expect_success 'stdin -z fails verify with no old value' '
832 printf $F "verify $a" >stdin &&
833 test_must_fail git update-ref -z --stdin <stdin 2>err &&
726f6916 834 grep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err
c6268bc0
BK
835'
836
837test_expect_success 'stdin -z fails option with unknown name' '
838 printf $F "option unknown" >stdin &&
839 test_must_fail git update-ref -z --stdin <stdin 2>err &&
840 grep "fatal: option unknown: unknown" err
841'
842
843test_expect_success 'stdin -z fails with duplicate refs' '
844 printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin &&
845 test_must_fail git update-ref -z --stdin <stdin 2>err &&
846 grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err
847'
848
849test_expect_success 'stdin -z create ref works' '
850 printf $F "create $a" "$m" >stdin &&
851 git update-ref -z --stdin <stdin &&
852 git rev-parse $m >expect &&
853 git rev-parse $a >actual &&
854 test_cmp expect actual
855'
856
857test_expect_success 'stdin -z update ref creates with zero old value' '
858 printf $F "update $b" "$m" "$Z" >stdin &&
859 git update-ref -z --stdin <stdin &&
860 git rev-parse $m >expect &&
861 git rev-parse $b >actual &&
862 test_cmp expect actual &&
863 git update-ref -d $b
864'
865
866test_expect_success 'stdin -z update ref creates with empty old value' '
867 printf $F "update $b" "$m" "" >stdin &&
868 git update-ref -z --stdin <stdin &&
869 git rev-parse $m >expect &&
870 git rev-parse $b >actual &&
871 test_cmp expect actual
872'
873
874test_expect_success 'stdin -z create ref works with path with space to blob' '
875 printf $F "create refs/blobs/pws" "$m:$pws" >stdin &&
876 git update-ref -z --stdin <stdin &&
877 git rev-parse "$m:$pws" >expect &&
878 git rev-parse refs/blobs/pws >actual &&
879 test_cmp expect actual &&
880 git update-ref -d refs/blobs/pws
881'
882
883test_expect_success 'stdin -z update ref fails with wrong old value' '
884 printf $F "update $c" "$m" "$m~1" >stdin &&
885 test_must_fail git update-ref -z --stdin <stdin 2>err &&
c2e0a718 886 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
c6268bc0
BK
887 test_must_fail git rev-parse --verify -q $c
888'
889
890test_expect_success 'stdin -z update ref fails with bad old value' '
891 printf $F "update $c" "$m" "does-not-exist" >stdin &&
892 test_must_fail git update-ref -z --stdin <stdin 2>err &&
9255f059 893 grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
c6268bc0
BK
894 test_must_fail git rev-parse --verify -q $c
895'
896
b9d56b5d
AG
897test_expect_success 'stdin -z create ref fails when ref exists' '
898 git update-ref $c $m &&
899 git rev-parse "$c" >expect &&
900 printf $F "create $c" "$m~1" >stdin &&
901 test_must_fail git update-ref -z --stdin <stdin 2>err &&
c2e0a718 902 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
b9d56b5d
AG
903 git rev-parse "$c" >actual &&
904 test_cmp expect actual
905'
906
c6268bc0 907test_expect_success 'stdin -z create ref fails with bad new value' '
b9d56b5d 908 git update-ref -d "$c" &&
c6268bc0
BK
909 printf $F "create $c" "does-not-exist" >stdin &&
910 test_must_fail git update-ref -z --stdin <stdin 2>err &&
9255f059 911 grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
c6268bc0
BK
912 test_must_fail git rev-parse --verify -q $c
913'
914
3afcc463 915test_expect_success 'stdin -z create ref fails with empty new value' '
c6268bc0
BK
916 printf $F "create $c" "" >stdin &&
917 test_must_fail git update-ref -z --stdin <stdin 2>err &&
f11b09fb 918 grep "fatal: create $c: missing <newvalue>" err &&
c6268bc0
BK
919 test_must_fail git rev-parse --verify -q $c
920'
921
922test_expect_success 'stdin -z update ref works with right old value' '
923 printf $F "update $b" "$m~1" "$m" >stdin &&
924 git update-ref -z --stdin <stdin &&
925 git rev-parse $m~1 >expect &&
926 git rev-parse $b >actual &&
927 test_cmp expect actual
928'
929
930test_expect_success 'stdin -z delete ref fails with wrong old value' '
931 printf $F "delete $a" "$m~1" >stdin &&
932 test_must_fail git update-ref -z --stdin <stdin 2>err &&
c2e0a718 933 grep "fatal: cannot lock ref '"'"'$a'"'"'" err &&
c6268bc0
BK
934 git rev-parse $m >expect &&
935 git rev-parse $a >actual &&
936 test_cmp expect actual
937'
938
939test_expect_success 'stdin -z delete ref fails with zero old value' '
940 printf $F "delete $a" "$Z" >stdin &&
941 test_must_fail git update-ref -z --stdin <stdin 2>err &&
f11b09fb 942 grep "fatal: delete $a: zero <oldvalue>" err &&
c6268bc0
BK
943 git rev-parse $m >expect &&
944 git rev-parse $a >actual &&
945 test_cmp expect actual
946'
947
948test_expect_success 'stdin -z update symref works option no-deref' '
949 git symbolic-ref TESTSYMREF $b &&
950 printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin &&
951 git update-ref -z --stdin <stdin &&
952 git rev-parse TESTSYMREF >expect &&
953 git rev-parse $a >actual &&
954 test_cmp expect actual &&
955 git rev-parse $m~1 >expect &&
956 git rev-parse $b >actual &&
957 test_cmp expect actual
958'
959
960test_expect_success 'stdin -z delete symref works option no-deref' '
961 git symbolic-ref TESTSYMREF $b &&
962 printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin &&
963 git update-ref -z --stdin <stdin &&
964 test_must_fail git rev-parse --verify -q TESTSYMREF &&
965 git rev-parse $m~1 >expect &&
966 git rev-parse $b >actual &&
967 test_cmp expect actual
968'
969
970test_expect_success 'stdin -z delete ref works with right old value' '
971 printf $F "delete $b" "$m~1" >stdin &&
972 git update-ref -z --stdin <stdin &&
973 test_must_fail git rev-parse --verify -q $b
974'
975
976test_expect_success 'stdin -z update/create/verify combination works' '
977 printf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin &&
978 git update-ref -z --stdin <stdin &&
979 git rev-parse $m >expect &&
980 git rev-parse $a >actual &&
981 test_cmp expect actual &&
982 git rev-parse $b >actual &&
983 test_cmp expect actual &&
984 test_must_fail git rev-parse --verify -q $c
985'
986
a46e41fc
MH
987test_expect_success 'stdin -z verify succeeds for correct value' '
988 git rev-parse $m >expect &&
989 printf $F "verify $m" "$m" >stdin &&
990 git update-ref -z --stdin <stdin &&
991 git rev-parse $m >actual &&
992 test_cmp expect actual
993'
994
995test_expect_success 'stdin -z verify succeeds for missing reference' '
996 printf $F "verify refs/heads/missing" "$Z" >stdin &&
997 git update-ref -z --stdin <stdin &&
998 test_must_fail git rev-parse --verify -q refs/heads/missing
999'
1000
1001test_expect_success 'stdin -z verify treats no value as missing' '
1002 printf $F "verify refs/heads/missing" "" >stdin &&
1003 git update-ref -z --stdin <stdin &&
1004 test_must_fail git rev-parse --verify -q refs/heads/missing
1005'
1006
1007test_expect_success 'stdin -z verify fails for wrong value' '
1008 git rev-parse $m >expect &&
1009 printf $F "verify $m" "$m~1" >stdin &&
1010 test_must_fail git update-ref -z --stdin <stdin &&
1011 git rev-parse $m >actual &&
1012 test_cmp expect actual
1013'
1014
1015test_expect_success 'stdin -z verify fails for mistaken null value' '
1016 git rev-parse $m >expect &&
1017 printf $F "verify $m" "$Z" >stdin &&
1018 test_must_fail git update-ref -z --stdin <stdin &&
1019 git rev-parse $m >actual &&
1020 test_cmp expect actual
1021'
1022
0e729c7e 1023test_expect_success 'stdin -z verify fails for mistaken empty value' '
a46e41fc
MH
1024 M=$(git rev-parse $m) &&
1025 test_when_finished "git update-ref $m $M" &&
1026 git rev-parse $m >expect &&
1027 printf $F "verify $m" "" >stdin &&
1028 test_must_fail git update-ref -z --stdin <stdin &&
1029 git rev-parse $m >actual &&
1030 test_cmp expect actual
1031'
1032
c6268bc0
BK
1033test_expect_success 'stdin -z update refs works with identity updates' '
1034 printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin &&
1035 git update-ref -z --stdin <stdin &&
1036 git rev-parse $m >expect &&
1037 git rev-parse $a >actual &&
1038 test_cmp expect actual &&
1039 git rev-parse $b >actual &&
1040 test_cmp expect actual &&
1041 test_must_fail git rev-parse --verify -q $c
1042'
1043
1044test_expect_success 'stdin -z update refs fails with wrong old value' '
1045 git update-ref $c $m &&
c1329110 1046 printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin &&
c6268bc0 1047 test_must_fail git update-ref -z --stdin <stdin 2>err &&
c2e0a718 1048 grep "fatal: cannot lock ref '"'"'$c'"'"'" err &&
c6268bc0
BK
1049 git rev-parse $m >expect &&
1050 git rev-parse $a >actual &&
1051 test_cmp expect actual &&
1052 git rev-parse $b >actual &&
1053 test_cmp expect actual &&
1054 git rev-parse $c >actual &&
1055 test_cmp expect actual
1056'
1057
1058test_expect_success 'stdin -z delete refs works with packed and loose refs' '
1059 git pack-refs --all &&
1060 git update-ref $c $m~1 &&
1061 printf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin &&
1062 git update-ref -z --stdin <stdin &&
1063 test_must_fail git rev-parse --verify -q $a &&
1064 test_must_fail git rev-parse --verify -q $b &&
1065 test_must_fail git rev-parse --verify -q $c
1066'
1067
d415ad02
SB
1068run_with_limited_open_files () {
1069 (ulimit -n 32 && "$@")
1070}
1071
1072test_lazy_prereq ULIMIT_FILE_DESCRIPTORS 'run_with_limited_open_files true'
1073
cf018ee0 1074test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
d415ad02
SB
1075(
1076 for i in $(test_seq 33)
1077 do
1078 echo "create refs/heads/$i HEAD"
1079 done >large_input &&
1080 run_with_limited_open_files git update-ref --stdin <large_input &&
1081 git rev-parse --verify -q refs/heads/33
1082)
1083'
1084
cf018ee0 1085test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
d415ad02
SB
1086(
1087 for i in $(test_seq 33)
1088 do
1089 echo "delete refs/heads/$i HEAD"
1090 done >large_input &&
1091 run_with_limited_open_files git update-ref --stdin <large_input &&
1092 test_must_fail git rev-parse --verify -q refs/heads/33
1093)
1094'
1095
6de08ae6 1096test_done