3 # Copyright (c) 2007 Andy Parkins
6 test_description
='for-each-ref test'
9 .
"$TEST_DIRECTORY"/lib-gpg.sh
10 .
"$TEST_DIRECTORY"/lib-terminal.sh
12 # Mon Jul 3 23:18:43 2006 +0000
14 setdate_and_increment
() {
15 GIT_COMMITTER_DATE
="$datestamp +0200"
16 datestamp
=$
(expr "$datestamp" + 1)
17 GIT_AUTHOR_DATE
="$datestamp +0200"
18 datestamp
=$
(expr "$datestamp" + 1)
19 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
22 test_expect_success setup
'
23 test_oid_cache <<-EOF &&
27 setdate_and_increment &&
28 echo "Using $datestamp" > one &&
30 git commit -m "Initial" &&
32 setdate_and_increment &&
33 git tag -a -m "Tagging at $datestamp" testtag &&
34 git update-ref refs/remotes/origin/main main &&
35 git remote add origin nowhere &&
36 git config branch.main.remote origin &&
37 git config branch.main.merge refs/heads/main &&
38 git remote add myfork elsewhere &&
39 git config remote.pushdefault myfork &&
40 git config push.default current
45 head) ref
=refs
/heads
/main
;;
46 tag
) ref
=refs
/tags
/testtag
;;
47 sym
) ref
=refs
/heads
/sym
;;
50 printf '%s\n' "$3" >expected
51 test_expect_
${4:-success} $PREREQ "basic atom: $1 $2" "
52 git for-each-ref --format='%($2)' $ref >actual &&
53 sanitize_pgp <actual >actual.clean &&
54 test_cmp expected actual.clean
56 # Automatically test "contents:size" atom after testing "contents"
57 if test "$2" = "contents"
59 # for commit leg, $3 is changed there
60 expect
=$
(printf '%s' "$3" |
wc -c)
61 test_expect_
${4:-success} $PREREQ "basic atom: $1 contents:size" '
62 type=$(git cat-file -t "$ref") &&
65 # We cannot use $3 as it expects sanitize_pgp to run
66 git cat-file tag $ref >out &&
67 expect=$(tail -n +6 out | wc -c) &&
72 : "use the calculated expect" ;;
74 BUG "unknown object type" ;;
76 # Leave $expect unquoted to lose possible leading whitespaces
77 echo $expect >expected &&
78 git for-each-ref --format="%(contents:size)" "$ref" >actual &&
79 test_cmp expected actual
84 hexlen
=$
(test_oid hexsz
)
85 disklen
=$
(test_oid disklen
)
87 test_atom
head refname refs
/heads
/main
88 test_atom
head refname
: refs
/heads
/main
89 test_atom
head refname
:short main
90 test_atom
head refname
:lstrip
=1 heads
/main
91 test_atom
head refname
:lstrip
=2 main
92 test_atom
head refname
:lstrip
=-1 main
93 test_atom
head refname
:lstrip
=-2 heads
/main
94 test_atom
head refname
:rstrip
=1 refs
/heads
95 test_atom
head refname
:rstrip
=2 refs
96 test_atom
head refname
:rstrip
=-1 refs
97 test_atom
head refname
:rstrip
=-2 refs
/heads
98 test_atom
head refname
:strip
=1 heads
/main
99 test_atom
head refname
:strip
=2 main
100 test_atom
head refname
:strip
=-1 main
101 test_atom
head refname
:strip
=-2 heads
/main
102 test_atom
head upstream refs
/remotes
/origin
/main
103 test_atom
head upstream
:short origin
/main
104 test_atom
head upstream
:lstrip
=2 origin
/main
105 test_atom
head upstream
:lstrip
=-2 origin
/main
106 test_atom
head upstream
:rstrip
=2 refs
/remotes
107 test_atom
head upstream
:rstrip
=-2 refs
/remotes
108 test_atom
head upstream
:strip
=2 origin
/main
109 test_atom
head upstream
:strip
=-2 origin
/main
110 test_atom
head push refs
/remotes
/myfork
/main
111 test_atom
head push
:short myfork
/main
112 test_atom
head push
:lstrip
=1 remotes
/myfork
/main
113 test_atom
head push
:lstrip
=-1 main
114 test_atom
head push
:rstrip
=1 refs
/remotes
/myfork
115 test_atom
head push
:rstrip
=-1 refs
116 test_atom
head push
:strip
=1 remotes
/myfork
/main
117 test_atom
head push
:strip
=-1 main
118 test_atom
head objecttype commit
119 test_atom
head objectsize $
((131 + hexlen
))
120 test_atom
head objectsize
:disk
$disklen
121 test_atom
head deltabase
$ZERO_OID
122 test_atom
head objectname $
(git rev-parse refs
/heads
/main
)
123 test_atom
head objectname
:short $
(git rev-parse
--short refs
/heads
/main
)
124 test_atom
head objectname
:short
=1 $
(git rev-parse
--short=1 refs
/heads
/main
)
125 test_atom
head objectname
:short
=10 $
(git rev-parse
--short=10 refs
/heads
/main
)
126 test_atom
head tree $
(git rev-parse refs
/heads
/main^
{tree
})
127 test_atom
head tree
:short $
(git rev-parse
--short refs
/heads
/main^
{tree
})
128 test_atom
head tree
:short
=1 $
(git rev-parse
--short=1 refs
/heads
/main^
{tree
})
129 test_atom
head tree
:short
=10 $
(git rev-parse
--short=10 refs
/heads
/main^
{tree
})
130 test_atom
head parent
''
131 test_atom
head parent
:short
''
132 test_atom
head parent
:short
=1 ''
133 test_atom
head parent
:short
=10 ''
134 test_atom
head numparent
0
135 test_atom
head object
''
136 test_atom
head type ''
137 test_atom
head raw
"$(git cat-file commit refs/heads/main)
139 test_atom
head '*objectname' ''
140 test_atom
head '*objecttype' ''
141 test_atom
head author
'A U Thor <author@example.com> 1151968724 +0200'
142 test_atom
head authorname
'A U Thor'
143 test_atom
head authoremail
'<author@example.com>'
144 test_atom
head authoremail
:trim
'author@example.com'
145 test_atom
head authoremail
:localpart
'author'
146 test_atom
head authordate
'Tue Jul 4 01:18:44 2006 +0200'
147 test_atom
head committer
'C O Mitter <committer@example.com> 1151968723 +0200'
148 test_atom
head committername
'C O Mitter'
149 test_atom
head committeremail
'<committer@example.com>'
150 test_atom
head committeremail
:trim
'committer@example.com'
151 test_atom
head committeremail
:localpart
'committer'
152 test_atom
head committerdate
'Tue Jul 4 01:18:43 2006 +0200'
153 test_atom
head tag
''
154 test_atom
head tagger
''
155 test_atom
head taggername
''
156 test_atom
head taggeremail
''
157 test_atom
head taggeremail
:trim
''
158 test_atom
head taggeremail
:localpart
''
159 test_atom
head taggerdate
''
160 test_atom
head creator
'C O Mitter <committer@example.com> 1151968723 +0200'
161 test_atom
head creatordate
'Tue Jul 4 01:18:43 2006 +0200'
162 test_atom
head subject
'Initial'
163 test_atom
head subject
:sanitize
'Initial'
164 test_atom
head contents
:subject
'Initial'
165 test_atom
head body
''
166 test_atom
head contents
:body
''
167 test_atom
head contents
:signature
''
168 test_atom
head contents
'Initial
170 test_atom
head HEAD
'*'
172 test_atom tag refname refs
/tags
/testtag
173 test_atom tag refname
:short testtag
174 test_atom tag upstream
''
175 test_atom tag push
''
176 test_atom tag objecttype tag
177 test_atom tag objectsize $
((114 + hexlen
))
178 test_atom tag objectsize
:disk
$disklen
179 test_atom tag
'*objectsize:disk' $disklen
180 test_atom tag deltabase
$ZERO_OID
181 test_atom tag
'*deltabase' $ZERO_OID
182 test_atom tag objectname $
(git rev-parse refs
/tags
/testtag
)
183 test_atom tag objectname
:short $
(git rev-parse
--short refs
/tags
/testtag
)
184 test_atom
head objectname
:short
=1 $
(git rev-parse
--short=1 refs
/heads
/main
)
185 test_atom
head objectname
:short
=10 $
(git rev-parse
--short=10 refs
/heads
/main
)
186 test_atom tag tree
''
187 test_atom tag tree
:short
''
188 test_atom tag tree
:short
=1 ''
189 test_atom tag tree
:short
=10 ''
190 test_atom tag parent
''
191 test_atom tag parent
:short
''
192 test_atom tag parent
:short
=1 ''
193 test_atom tag parent
:short
=10 ''
194 test_atom tag numparent
''
195 test_atom tag object $
(git rev-parse refs
/tags
/testtag^
0)
196 test_atom tag
type 'commit'
197 test_atom tag
'*objectname' $
(git rev-parse refs
/tags
/testtag^
{})
198 test_atom tag
'*objecttype' 'commit'
199 test_atom tag author
''
200 test_atom tag authorname
''
201 test_atom tag authoremail
''
202 test_atom tag authoremail
:trim
''
203 test_atom tag authoremail
:localpart
''
204 test_atom tag authordate
''
205 test_atom tag committer
''
206 test_atom tag committername
''
207 test_atom tag committeremail
''
208 test_atom tag committeremail
:trim
''
209 test_atom tag committeremail
:localpart
''
210 test_atom tag committerdate
''
211 test_atom tag tag
'testtag'
212 test_atom tag tagger
'C O Mitter <committer@example.com> 1151968725 +0200'
213 test_atom tag taggername
'C O Mitter'
214 test_atom tag taggeremail
'<committer@example.com>'
215 test_atom tag taggeremail
:trim
'committer@example.com'
216 test_atom tag taggeremail
:localpart
'committer'
217 test_atom tag taggerdate
'Tue Jul 4 01:18:45 2006 +0200'
218 test_atom tag creator
'C O Mitter <committer@example.com> 1151968725 +0200'
219 test_atom tag creatordate
'Tue Jul 4 01:18:45 2006 +0200'
220 test_atom tag subject
'Tagging at 1151968727'
221 test_atom tag subject
:sanitize
'Tagging-at-1151968727'
222 test_atom tag contents
:subject
'Tagging at 1151968727'
223 test_atom tag body
''
224 test_atom tag contents
:body
''
225 test_atom tag contents
:signature
''
226 test_atom tag contents
'Tagging at 1151968727
228 test_atom tag HEAD
' '
230 test_expect_success
'basic atom: refs/tags/testtag *raw' '
231 git cat-file commit refs/tags/testtag^{} >expected &&
232 git for-each-ref --format="%(*raw)" refs/tags/testtag >actual &&
233 sanitize_pgp <expected >expected.clean &&
234 echo >>expected.clean &&
235 sanitize_pgp <actual >actual.clean &&
236 test_cmp expected.clean actual.clean
239 test_expect_success
'Check invalid atoms names are errors' '
240 test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
243 test_expect_success
'Check format specifiers are ignored in naming date atoms' '
244 git for-each-ref --format="%(authordate)" refs/heads &&
245 git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
246 git for-each-ref --format="%(authordate) %(authordate:default)" refs/heads &&
247 git for-each-ref --format="%(authordate:default) %(authordate:default)" refs/heads
250 test_expect_success
'Check valid format specifiers for date fields' '
251 git for-each-ref --format="%(authordate:default)" refs/heads &&
252 git for-each-ref --format="%(authordate:relative)" refs/heads &&
253 git for-each-ref --format="%(authordate:short)" refs/heads &&
254 git for-each-ref --format="%(authordate:local)" refs/heads &&
255 git for-each-ref --format="%(authordate:iso8601)" refs/heads &&
256 git for-each-ref --format="%(authordate:rfc2822)" refs/heads
259 test_expect_success
'Check invalid format specifiers are errors' '
260 test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
263 test_expect_success
'arguments to %(objectname:short=) must be positive integers' '
264 test_must_fail git for-each-ref --format="%(objectname:short=0)" &&
265 test_must_fail git for-each-ref --format="%(objectname:short=-1)" &&
266 test_must_fail git for-each-ref --format="%(objectname:short=foo)"
274 cat >expected
<<-EOF &&
275 'refs/heads/main' '$committer_date' '$author_date'
276 'refs/tags/testtag' '$tagger_date'
279 git for-each-ref
--shell \
280 --format="%(refname) %(committerdate${f:+:$f}) %(authordate${f:+:$f})" \
282 git for-each-ref
--shell \
283 --format="%(refname) %(taggerdate${f:+:$f})" \
286 test_cmp expected actual
289 test_expect_success
'Check unformatted date fields output' '
291 "Tue Jul 4 01:18:43 2006 +0200" \
292 "Tue Jul 4 01:18:44 2006 +0200" \
293 "Tue Jul 4 01:18:45 2006 +0200"
296 test_expect_success
'Check format "default" formatted date fields output' '
298 "Tue Jul 4 01:18:43 2006 +0200" \
299 "Tue Jul 4 01:18:44 2006 +0200" \
300 "Tue Jul 4 01:18:45 2006 +0200"
303 test_expect_success
'Check format "default-local" date fields output' '
304 test_date default-local "Mon Jul 3 23:18:43 2006" "Mon Jul 3 23:18:44 2006" "Mon Jul 3 23:18:45 2006"
307 # Don't know how to do relative check because I can't know when this script
308 # is going to be run and can't fake the current time to git, and hence can't
309 # provide expected output. Instead, I'll just make sure that "relative"
310 # doesn't exit in error
311 test_expect_success
'Check format "relative" date fields output' '
313 (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
314 git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
317 # We just check that this is the same as "relative" for now.
318 test_expect_success
'Check format "relative-local" date fields output' '
319 test_date relative-local \
320 "$(git for-each-ref --format="%(committerdate:relative)" refs/heads)" \
321 "$(git for-each-ref --format="%(authordate:relative)" refs/heads)" \
322 "$(git for-each-ref --format="%(taggerdate:relative)" refs/tags)"
325 test_expect_success
'Check format "short" date fields output' '
326 test_date short 2006-07-04 2006-07-04 2006-07-04
329 test_expect_success
'Check format "short-local" date fields output' '
330 test_date short-local 2006-07-03 2006-07-03 2006-07-03
333 test_expect_success
'Check format "local" date fields output' '
335 "Mon Jul 3 23:18:43 2006" \
336 "Mon Jul 3 23:18:44 2006" \
337 "Mon Jul 3 23:18:45 2006"
340 test_expect_success
'Check format "iso8601" date fields output' '
342 "2006-07-04 01:18:43 +0200" \
343 "2006-07-04 01:18:44 +0200" \
344 "2006-07-04 01:18:45 +0200"
347 test_expect_success
'Check format "iso8601-local" date fields output' '
348 test_date iso8601-local "2006-07-03 23:18:43 +0000" "2006-07-03 23:18:44 +0000" "2006-07-03 23:18:45 +0000"
351 test_expect_success
'Check format "rfc2822" date fields output' '
353 "Tue, 4 Jul 2006 01:18:43 +0200" \
354 "Tue, 4 Jul 2006 01:18:44 +0200" \
355 "Tue, 4 Jul 2006 01:18:45 +0200"
358 test_expect_success
'Check format "rfc2822-local" date fields output' '
359 test_date rfc2822-local "Mon, 3 Jul 2006 23:18:43 +0000" "Mon, 3 Jul 2006 23:18:44 +0000" "Mon, 3 Jul 2006 23:18:45 +0000"
362 test_expect_success
'Check format "raw" date fields output' '
363 test_date raw "1151968723 +0200" "1151968724 +0200" "1151968725 +0200"
366 test_expect_success
'Check format "raw-local" date fields output' '
367 test_date raw-local "1151968723 +0000" "1151968724 +0000" "1151968725 +0000"
370 test_expect_success
'Check format of strftime date fields' '
371 echo "my date is 2006-07-04" >expected &&
373 --format="%(authordate:format:my date is %Y-%m-%d)" \
374 refs/heads >actual &&
375 test_cmp expected actual
378 test_expect_success
'Check format of strftime-local date fields' '
379 echo "my date is 2006-07-03" >expected &&
381 --format="%(authordate:format-local:my date is %Y-%m-%d)" \
382 refs/heads >actual &&
383 test_cmp expected actual
386 test_expect_success
'exercise strftime with odd fields' '
388 git for-each-ref --format="%(authordate:format:)" refs/heads >actual &&
389 test_cmp expected actual &&
390 long="long format -- $ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID" &&
391 echo $long >expected &&
392 git for-each-ref --format="%(authordate:format:$long)" refs/heads >actual &&
393 test_cmp expected actual
398 refs
/remotes
/origin
/main
402 test_expect_success
'Verify ascending sort' '
403 git for-each-ref --format="%(refname)" --sort=refname >actual &&
404 test_cmp expected actual
410 refs
/remotes
/origin
/main
414 test_expect_success
'Verify descending sort' '
415 git for-each-ref --format="%(refname)" --sort=-refname >actual &&
416 test_cmp expected actual
419 test_expect_success
'Give help even with invalid sort atoms' '
420 test_expect_code 129 git for-each-ref --sort=bogus -h >actual 2>&1 &&
421 grep "^usage: git for-each-ref" actual
429 test_expect_success
'exercise patterns with prefixes' '
431 test_when_finished "git tag -d testtag-2" &&
432 git for-each-ref --format="%(refname)" \
433 refs/tags/testtag refs/tags/testtag-2 >actual &&
434 test_cmp expected actual
442 test_expect_success
'exercise glob patterns with prefixes' '
444 test_when_finished "git tag -d testtag-2" &&
445 git for-each-ref --format="%(refname)" \
446 refs/tags/testtag "refs/tags/testtag-*" >actual &&
447 test_cmp expected actual
452 'refs/remotes/origin/main'
456 test_expect_success
'Quoting style: shell' '
457 git for-each-ref --shell --format="%(refname)" >actual &&
458 test_cmp expected actual
461 test_expect_success
'Quoting style: perl' '
462 git for-each-ref --perl --format="%(refname)" >actual &&
463 test_cmp expected actual
466 test_expect_success
'Quoting style: python' '
467 git for-each-ref --python --format="%(refname)" >actual &&
468 test_cmp expected actual
473 "refs/remotes/origin/main"
477 test_expect_success
'Quoting style: tcl' '
478 git for-each-ref --tcl --format="%(refname)" >actual &&
479 test_cmp expected actual
482 for i
in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
483 test_expect_success
"more than one quoting style: $i" "
484 test_must_fail git for-each-ref $i 2>err &&
485 grep '^error: more than one quoting style' err
489 test_expect_success
'setup for upstream:track[short]' '
493 test_atom
head upstream
:track
'[ahead 1]'
494 test_atom
head upstream
:trackshort
'>'
495 test_atom
head upstream
:track
,nobracket
'ahead 1'
496 test_atom
head upstream
:nobracket
,track
'ahead 1'
498 test_expect_success
'setup for push:track[short]' '
500 git update-ref refs/remotes/myfork/main main &&
504 test_atom
head push
:track
'[behind 1]'
505 test_atom
head push
:trackshort
'<'
507 test_expect_success
'Check that :track[short] cannot be used with other atoms' '
508 test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null &&
509 test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null
512 test_expect_success
'Check that :track[short] works when upstream is invalid' '
513 cat >expected <<-\EOF &&
517 test_when_finished "git config branch.main.merge refs/heads/main" &&
518 git config branch.main.merge refs/heads/does-not-exist &&
520 --format="%(upstream:track)$LF%(upstream:trackshort)" \
521 refs/heads >actual &&
522 test_cmp expected actual
525 test_expect_success
'Check for invalid refname format' '
526 test_must_fail git for-each-ref --format="%(refname:INVALID)"
529 test_expect_success
'set up color tests' '
530 cat >expected.color <<-EOF &&
531 $(git rev-parse --short refs/heads/main) <GREEN>main<RESET>
532 $(git rev-parse --short refs/remotes/myfork/main) <GREEN>myfork/main<RESET>
533 $(git rev-parse --short refs/remotes/origin/main) <GREEN>origin/main<RESET>
534 $(git rev-parse --short refs/tags/testtag) <GREEN>testtag<RESET>
535 $(git rev-parse --short refs/tags/third) <GREEN>third<RESET>
536 $(git rev-parse --short refs/tags/two) <GREEN>two<RESET>
538 sed "s/<[^>]*>//g" <expected.color >expected.bare &&
539 color_format="%(objectname:short) %(color:green)%(refname:short)"
542 test_expect_success TTY
'%(color) shows color with a tty' '
543 test_terminal git for-each-ref --format="$color_format" >actual.raw &&
544 test_decode_color <actual.raw >actual &&
545 test_cmp expected.color actual
548 test_expect_success
'%(color) does not show color without tty' '
549 TERM=vt100 git for-each-ref --format="$color_format" >actual &&
550 test_cmp expected.bare actual
553 test_expect_success
'--color can override tty check' '
554 git for-each-ref --color --format="$color_format" >actual.raw &&
555 test_decode_color <actual.raw >actual &&
556 test_cmp expected.color actual
559 test_expect_success
'color.ui=always does not override tty check' '
560 git -c color.ui=always for-each-ref --format="$color_format" >actual &&
561 test_cmp expected.bare actual
569 test_expect_success
'Check ambiguous head and tag refs (strict)' '
570 git config --bool core.warnambiguousrefs true &&
571 git checkout -b newtag &&
572 echo "Using $datestamp" > one &&
574 git commit -m "Branch" &&
575 setdate_and_increment &&
576 git tag -m "Tagging at $datestamp" main &&
577 git for-each-ref --format "%(refname:short)" refs/heads/main refs/tags/main >actual &&
578 test_cmp expected actual
586 test_expect_success
'Check ambiguous head and tag refs (loose)' '
587 git config --bool core.warnambiguousrefs false &&
588 git for-each-ref --format "%(refname:short)" refs/heads/main refs/tags/main >actual &&
589 test_cmp expected actual
597 test_expect_success
'Check ambiguous head and tag refs II (loose)' '
599 git tag ambiguous testtag^0 &&
600 git branch ambiguous testtag^0 &&
601 git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual &&
602 test_cmp expected actual
605 test_expect_success
'create tag without tagger' '
606 git tag -a -m "Broken tag" taggerless &&
607 git tag -f taggerless $(git cat-file tag taggerless |
608 sed -e "/^tagger /d" |
609 git hash-object --stdin -w -t tag)
612 test_atom refs
/tags
/taggerless
type 'commit'
613 test_atom refs
/tags
/taggerless tag
'taggerless'
614 test_atom refs
/tags
/taggerless tagger
''
615 test_atom refs
/tags
/taggerless taggername
''
616 test_atom refs
/tags
/taggerless taggeremail
''
617 test_atom refs
/tags
/taggerless taggeremail
:trim
''
618 test_atom refs
/tags
/taggerless taggeremail
:localpart
''
619 test_atom refs
/tags
/taggerless taggerdate
''
620 test_atom refs
/tags
/taggerless committer
''
621 test_atom refs
/tags
/taggerless committername
''
622 test_atom refs
/tags
/taggerless committeremail
''
623 test_atom refs
/tags
/taggerless committeremail
:trim
''
624 test_atom refs
/tags
/taggerless committeremail
:localpart
''
625 test_atom refs
/tags
/taggerless committerdate
''
626 test_atom refs
/tags
/taggerless subject
'Broken tag'
628 test_expect_success
'an unusual tag with an incomplete line' '
630 git tag -m "bogo" bogo &&
631 bogo=$(git cat-file tag bogo) &&
632 bogo=$(printf "%s" "$bogo" | git mktag) &&
633 git tag -f bogo "$bogo" &&
634 git for-each-ref --format "%(body)" refs/tags/bogo
638 test_expect_success
'create tag with subject and body content' '
645 git tag -F msg subject-body
647 test_atom refs
/tags
/subject-body subject
'the subject line'
648 test_atom refs
/tags
/subject-body subject
:sanitize
'the-subject-line'
649 test_atom refs
/tags
/subject-body body
'first body line
652 test_atom refs
/tags
/subject-body contents
'the subject line
658 test_expect_success
'create tag with multiline subject' '
666 git tag -F msg multiline
668 test_atom refs
/tags
/multiline subject
'first subject line second subject line'
669 test_atom refs
/tags
/multiline subject
:sanitize
'first-subject-line-second-subject-line'
670 test_atom refs
/tags
/multiline contents
:subject
'first subject line second subject line'
671 test_atom refs
/tags
/multiline body
'first body line
674 test_atom refs
/tags
/multiline contents
:body
'first body line
677 test_atom refs
/tags
/multiline contents
:signature
''
678 test_atom refs
/tags
/multiline contents
'first subject line
685 test_expect_success GPG
'create signed tags' '
686 git tag -s -m "" signed-empty &&
687 git tag -s -m "subject line" signed-short &&
693 git tag -s -F msg signed-long
696 sig
='-----BEGIN PGP SIGNATURE-----
697 -----END PGP SIGNATURE-----
701 test_atom refs
/tags
/signed-empty subject
''
702 test_atom refs
/tags
/signed-empty subject
:sanitize
''
703 test_atom refs
/tags
/signed-empty contents
:subject
''
704 test_atom refs
/tags
/signed-empty body
"$sig"
705 test_atom refs
/tags
/signed-empty contents
:body
''
706 test_atom refs
/tags
/signed-empty contents
:signature
"$sig"
707 test_atom refs
/tags
/signed-empty contents
"$sig"
709 test_expect_success GPG
'basic atom: refs/tags/signed-empty raw' '
710 git cat-file tag refs/tags/signed-empty >expected &&
711 git for-each-ref --format="%(raw)" refs/tags/signed-empty >actual &&
712 sanitize_pgp <expected >expected.clean &&
713 echo >>expected.clean &&
714 sanitize_pgp <actual >actual.clean &&
715 test_cmp expected.clean actual.clean
718 test_atom refs
/tags
/signed-short subject
'subject line'
719 test_atom refs
/tags
/signed-short subject
:sanitize
'subject-line'
720 test_atom refs
/tags
/signed-short contents
:subject
'subject line'
721 test_atom refs
/tags
/signed-short body
"$sig"
722 test_atom refs
/tags
/signed-short contents
:body
''
723 test_atom refs
/tags
/signed-short contents
:signature
"$sig"
724 test_atom refs
/tags
/signed-short contents
"subject line
727 test_expect_success GPG
'basic atom: refs/tags/signed-short raw' '
728 git cat-file tag refs/tags/signed-short >expected &&
729 git for-each-ref --format="%(raw)" refs/tags/signed-short >actual &&
730 sanitize_pgp <expected >expected.clean &&
731 echo >>expected.clean &&
732 sanitize_pgp <actual >actual.clean &&
733 test_cmp expected.clean actual.clean
736 test_atom refs
/tags
/signed-long subject
'subject line'
737 test_atom refs
/tags
/signed-long subject
:sanitize
'subject-line'
738 test_atom refs
/tags
/signed-long contents
:subject
'subject line'
739 test_atom refs
/tags
/signed-long body
"body contents
741 test_atom refs
/tags
/signed-long contents
:body
'body contents
743 test_atom refs
/tags
/signed-long contents
:signature
"$sig"
744 test_atom refs
/tags
/signed-long contents
"subject line
749 test_expect_success GPG
'basic atom: refs/tags/signed-long raw' '
750 git cat-file tag refs/tags/signed-long >expected &&
751 git for-each-ref --format="%(raw)" refs/tags/signed-long >actual &&
752 sanitize_pgp <expected >expected.clean &&
753 echo >>expected.clean &&
754 sanitize_pgp <actual >actual.clean &&
755 test_cmp expected.clean actual.clean
758 test_expect_success
'set up refs pointing to tree and blob' '
759 git update-ref refs/mytrees/first refs/heads/main^{tree} &&
760 git update-ref refs/myblobs/first refs/heads/main:one
763 test_atom refs
/mytrees
/first subject
""
764 test_atom refs
/mytrees
/first contents
:subject
""
765 test_atom refs
/mytrees
/first body
""
766 test_atom refs
/mytrees
/first contents
:body
""
767 test_atom refs
/mytrees
/first contents
:signature
""
768 test_atom refs
/mytrees
/first contents
""
770 test_expect_success
'basic atom: refs/mytrees/first raw' '
771 git cat-file tree refs/mytrees/first >expected &&
773 git for-each-ref --format="%(raw)" refs/mytrees/first >actual &&
774 test_cmp expected actual &&
775 git cat-file -s refs/mytrees/first >expected &&
776 git for-each-ref --format="%(raw:size)" refs/mytrees/first >actual &&
777 test_cmp expected actual
780 test_atom refs
/myblobs
/first subject
""
781 test_atom refs
/myblobs
/first contents
:subject
""
782 test_atom refs
/myblobs
/first body
""
783 test_atom refs
/myblobs
/first contents
:body
""
784 test_atom refs
/myblobs
/first contents
:signature
""
785 test_atom refs
/myblobs
/first contents
""
787 test_expect_success
'basic atom: refs/myblobs/first raw' '
788 git cat-file blob refs/myblobs/first >expected &&
790 git for-each-ref --format="%(raw)" refs/myblobs/first >actual &&
791 test_cmp expected actual &&
792 git cat-file -s refs/myblobs/first >expected &&
793 git for-each-ref --format="%(raw:size)" refs/myblobs/first >actual &&
794 test_cmp expected actual
797 test_expect_success
'set up refs pointing to binary blob' '
798 printf "a\0b\0c" >blob1 &&
799 printf "a\0c\0b" >blob2 &&
800 printf "\0a\0b\0c" >blob3 &&
801 printf "abc" >blob4 &&
802 printf "\0 \0 \0 " >blob5 &&
803 printf "\0 \0a\0 " >blob6 &&
806 obj=$(git hash-object -w blob1) &&
807 git update-ref refs/myblobs/blob1 "$obj" &&
808 obj=$(git hash-object -w blob2) &&
809 git update-ref refs/myblobs/blob2 "$obj" &&
810 obj=$(git hash-object -w blob3) &&
811 git update-ref refs/myblobs/blob3 "$obj" &&
812 obj=$(git hash-object -w blob4) &&
813 git update-ref refs/myblobs/blob4 "$obj" &&
814 obj=$(git hash-object -w blob5) &&
815 git update-ref refs/myblobs/blob5 "$obj" &&
816 obj=$(git hash-object -w blob6) &&
817 git update-ref refs/myblobs/blob6 "$obj" &&
818 obj=$(git hash-object -w blob7) &&
819 git update-ref refs/myblobs/blob7 "$obj" &&
820 obj=$(git hash-object -w blob8) &&
821 git update-ref refs/myblobs/blob8 "$obj"
824 test_expect_success
'Verify sorts with raw' '
825 cat >expected <<-EOF &&
838 git for-each-ref --format="%(refname)" --sort=raw \
839 refs/heads/main refs/myblobs/ refs/mytrees/first >actual &&
840 test_cmp expected actual
843 test_expect_success
'Verify sorts with raw:size' '
844 cat >expected <<-EOF &&
857 git for-each-ref --format="%(refname)" --sort=raw:size \
858 refs/heads/main refs/myblobs/ refs/mytrees/first >actual &&
859 test_cmp expected actual
862 test_expect_success
'validate raw atom with %(if:equals)' '
863 cat >expected <<-EOF &&
877 git for-each-ref --format="%(if:equals=abc)%(raw)%(then)%(refname)%(else)not equals%(end)" \
878 refs/myblobs/ refs/heads/ >actual &&
879 test_cmp expected actual
882 test_expect_success
'validate raw atom with %(if:notequals)' '
883 cat >expected <<-EOF &&
897 git for-each-ref --format="%(if:notequals=abc)%(raw)%(then)%(refname)%(else)equals%(end)" \
898 refs/myblobs/ refs/heads/ >actual &&
899 test_cmp expected actual
902 test_expect_success
'empty raw refs with %(if)' '
903 cat >expected <<-EOF &&
904 refs/myblobs/blob1 not empty
905 refs/myblobs/blob2 not empty
906 refs/myblobs/blob3 not empty
907 refs/myblobs/blob4 not empty
908 refs/myblobs/blob5 not empty
909 refs/myblobs/blob6 not empty
910 refs/myblobs/blob7 empty
911 refs/myblobs/blob8 empty
912 refs/myblobs/first not empty
914 git for-each-ref --format="%(refname) %(if)%(raw)%(then)not empty%(else)empty%(end)" \
915 refs/myblobs/ >actual &&
916 test_cmp expected actual
919 test_expect_success
'%(raw) with --python must fail' '
920 test_must_fail git for-each-ref --format="%(raw)" --python
923 test_expect_success
'%(raw) with --tcl must fail' '
924 test_must_fail git for-each-ref --format="%(raw)" --tcl
927 test_expect_success
'%(raw) with --perl' '
928 git for-each-ref --format="\$name= %(raw);
929 print \"\$name\"" refs/myblobs/blob1 --perl | perl >actual &&
931 git for-each-ref --format="\$name= %(raw);
932 print \"\$name\"" refs/myblobs/blob3 --perl | perl >actual &&
934 git for-each-ref --format="\$name= %(raw);
935 print \"\$name\"" refs/myblobs/blob8 --perl | perl >actual &&
937 git for-each-ref --format="\$name= %(raw);
938 print \"\$name\"" refs/myblobs/first --perl | perl >actual &&
940 git cat-file tree refs/mytrees/first > expected &&
941 git for-each-ref --format="\$name= %(raw);
942 print \"\$name\"" refs/mytrees/first --perl | perl >actual &&
946 test_expect_success
'%(raw) with --shell must fail' '
947 test_must_fail git for-each-ref --format="%(raw)" --shell
950 test_expect_success
'%(raw) with --shell and --sort=raw must fail' '
951 test_must_fail git for-each-ref --format="%(raw)" --sort=raw --shell
954 test_expect_success
'%(raw:size) with --shell' '
955 git for-each-ref --format="%(raw:size)" | sed "s/^/$SQ/;s/$/$SQ/" >expect &&
956 git for-each-ref --format="%(raw:size)" --shell >actual &&
957 test_cmp expect actual
960 test_expect_success
'for-each-ref --format compare with cat-file --batch' '
961 git rev-parse refs/mytrees/first | git cat-file --batch >expected &&
962 git for-each-ref --format="%(objectname) %(objecttype) %(objectsize)
963 %(raw)" refs/mytrees/first >actual &&
964 test_cmp expected actual
967 test_expect_success
'set up multiple-sort tags' '
968 for when in 100000 200000
970 for email in user1 user2
974 GIT_COMMITTER_DATE="@$when +0000" \
975 GIT_COMMITTER_EMAIL="$email@example.com" \
976 git tag -m "tag $ref-$when-$email" \
977 multi-$ref-$when-$email || return 1
983 test_expect_success
'Verify sort with multiple keys' '
984 cat >expected <<-\EOF &&
985 100000 <user1@example.com> refs/tags/multi-ref2-100000-user1
986 100000 <user1@example.com> refs/tags/multi-ref1-100000-user1
987 100000 <user2@example.com> refs/tags/multi-ref2-100000-user2
988 100000 <user2@example.com> refs/tags/multi-ref1-100000-user2
989 200000 <user1@example.com> refs/tags/multi-ref2-200000-user1
990 200000 <user1@example.com> refs/tags/multi-ref1-200000-user1
991 200000 <user2@example.com> refs/tags/multi-ref2-200000-user2
992 200000 <user2@example.com> refs/tags/multi-ref1-200000-user2
995 --format="%(taggerdate:unix) %(taggeremail) %(refname)" \
999 "refs/tags/multi-*" >actual &&
1000 test_cmp expected actual
1003 test_expect_success
'equivalent sorts fall back on refname' '
1004 cat >expected <<-\EOF &&
1005 100000 <user1@example.com> refs/tags/multi-ref1-100000-user1
1006 100000 <user2@example.com> refs/tags/multi-ref1-100000-user2
1007 100000 <user1@example.com> refs/tags/multi-ref2-100000-user1
1008 100000 <user2@example.com> refs/tags/multi-ref2-100000-user2
1009 200000 <user1@example.com> refs/tags/multi-ref1-200000-user1
1010 200000 <user2@example.com> refs/tags/multi-ref1-200000-user2
1011 200000 <user1@example.com> refs/tags/multi-ref2-200000-user1
1012 200000 <user2@example.com> refs/tags/multi-ref2-200000-user2
1015 --format="%(taggerdate:unix) %(taggeremail) %(refname)" \
1017 "refs/tags/multi-*" >actual &&
1018 test_cmp expected actual
1021 test_expect_success
'--no-sort cancels the previous sort keys' '
1022 cat >expected <<-\EOF &&
1023 100000 <user1@example.com> refs/tags/multi-ref1-100000-user1
1024 100000 <user2@example.com> refs/tags/multi-ref1-100000-user2
1025 100000 <user1@example.com> refs/tags/multi-ref2-100000-user1
1026 100000 <user2@example.com> refs/tags/multi-ref2-100000-user2
1027 200000 <user1@example.com> refs/tags/multi-ref1-200000-user1
1028 200000 <user2@example.com> refs/tags/multi-ref1-200000-user2
1029 200000 <user1@example.com> refs/tags/multi-ref2-200000-user1
1030 200000 <user2@example.com> refs/tags/multi-ref2-200000-user2
1033 --format="%(taggerdate:unix) %(taggeremail) %(refname)" \
1035 --sort=taggeremail \
1038 "refs/tags/multi-*" >actual &&
1039 test_cmp expected actual
1042 test_expect_success
'do not dereference NULL upon %(HEAD) on unborn branch' '
1043 test_when_finished "git checkout main" &&
1044 git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
1045 sed -e "s/^\* / /" actual >expect &&
1046 git checkout --orphan orphaned-branch &&
1047 git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
1048 test_cmp expect actual
1052 Reviewed-by: A U Thor <author@example.com>
1053 Signed-off-by: A U Thor <author@example.com>
1054 [ v2 updated patch description ]
1056 <author@example.com>
1060 perl
-0pe 's/\n\s+/ /g'
1063 test_expect_success
'set up trailers for next test' '
1064 echo "Some contents" > two &&
1066 git commit -F - <<-EOF
1067 trailers: this commit message has trailers
1069 Some message contents
1075 test_trailer_option
() {
1078 test_expect_success
"$title" '
1079 git for-each-ref --format="%($option)" refs/heads/main >actual &&
1080 test_cmp expect actual &&
1081 git for-each-ref --format="%(contents:$option)" refs/heads/main >actual &&
1082 test_cmp expect actual
1086 test_trailer_option
'%(trailers:unfold) unfolds trailers' \
1087 'trailers:unfold' <<-EOF
1092 test_trailer_option
'%(trailers:only) shows only "key: value" trailers' \
1093 'trailers:only' <<-EOF
1094 $(grep -v patch.description <trailers)
1098 test_trailer_option
'%(trailers:only=no,only=true) shows only "key: value" trailers' \
1099 'trailers:only=no,only=true' <<-EOF
1100 $(grep -v patch.description <trailers)
1104 test_trailer_option
'%(trailers:only=yes) shows only "key: value" trailers' \
1105 'trailers:only=yes' <<-EOF
1106 $(grep -v patch.description <trailers)
1110 test_trailer_option
'%(trailers:only=no) shows all trailers' \
1111 'trailers:only=no' <<-EOF
1116 test_trailer_option
'%(trailers:only) and %(trailers:unfold) work together' \
1117 'trailers:only,unfold' <<-EOF
1118 $(grep -v patch.description <trailers | unfold)
1122 test_trailer_option
'%(trailers:unfold) and %(trailers:only) work together' \
1123 'trailers:unfold,only' <<-EOF
1124 $(grep -v patch.description <trailers | unfold)
1128 test_trailer_option
'%(trailers:key=foo) shows that trailer' \
1129 'trailers:key=Signed-off-by' <<-EOF
1130 Signed-off-by: A U Thor <author@example.com>
1134 test_trailer_option
'%(trailers:key=foo) is case insensitive' \
1135 'trailers:key=SiGned-oFf-bY' <<-EOF
1136 Signed-off-by: A U Thor <author@example.com>
1140 test_trailer_option
'%(trailers:key=foo:) trailing colon also works' \
1141 'trailers:key=Signed-off-by:' <<-EOF
1142 Signed-off-by: A U Thor <author@example.com>
1146 test_trailer_option
'%(trailers:key=foo) multiple keys' \
1147 'trailers:key=Reviewed-by:,key=Signed-off-by' <<-EOF
1148 Reviewed-by: A U Thor <author@example.com>
1149 Signed-off-by: A U Thor <author@example.com>
1153 test_trailer_option
'%(trailers:key=nonexistent) becomes empty' \
1154 'trailers:key=Shined-off-by:' <<-EOF
1158 test_trailer_option
'%(trailers:key=foo) handles multiple lines even if folded' \
1159 'trailers:key=Acked-by' <<-EOF
1160 $(grep -v patch.description <trailers | grep -v Signed-off-by | grep -v Reviewed-by)
1164 test_trailer_option
'%(trailers:key=foo,unfold) properly unfolds' \
1165 'trailers:key=Signed-Off-by,unfold' <<-EOF
1166 $(unfold <trailers | grep Signed-off-by)
1170 test_trailer_option
'%(trailers:key=foo,only=no) also includes nontrailer lines' \
1171 'trailers:key=Signed-off-by,only=no' <<-EOF
1172 Signed-off-by: A U Thor <author@example.com>
1173 $(grep patch.description <trailers)
1177 test_trailer_option
'%(trailers:key=foo,valueonly) shows only value' \
1178 'trailers:key=Signed-off-by,valueonly' <<-EOF
1179 A U Thor <author@example.com>
1183 test_trailer_option
'%(trailers:separator) changes separator' \
1184 'trailers:separator=%x2C,key=Reviewed-by,key=Signed-off-by:' <<-EOF
1185 Reviewed-by: A U Thor <author@example.com>,Signed-off-by: A U Thor <author@example.com>
1188 test_trailer_option
'%(trailers:key_value_separator) changes key-value separator' \
1189 'trailers:key_value_separator=%x2C,key=Reviewed-by,key=Signed-off-by:' <<-EOF
1190 Reviewed-by,A U Thor <author@example.com>
1191 Signed-off-by,A U Thor <author@example.com>
1195 test_trailer_option
'%(trailers:separator,key_value_separator) changes both separators' \
1196 'trailers:separator=%x2C,key_value_separator=%x2C,key=Reviewed-by,key=Signed-off-by:' <<-EOF
1197 Reviewed-by,A U Thor <author@example.com>,Signed-off-by,A U Thor <author@example.com>
1200 test_failing_trailer_option
() {
1203 test_expect_success
"$title" '
1204 # error message cannot be checked under i18n
1205 test_must_fail git for-each-ref --format="%($option)" refs/heads/main 2>actual &&
1206 test_cmp expect actual &&
1207 test_must_fail git for-each-ref --format="%(contents:$option)" refs/heads/main 2>actual &&
1208 test_cmp expect actual
1212 test_failing_trailer_option
'%(trailers) rejects unknown trailers arguments' \
1213 'trailers:unsupported' <<-\EOF
1214 fatal: unknown %(trailers) argument: unsupported
1217 test_failing_trailer_option '%(trailers:key) without value is error' \
1218 'trailers:key' <<-\
EOF
1219 fatal: expected %(trailers:key=<value>)
1222 test_expect_success 'if arguments, %(contents:trailers) shows error if colon is missing' '
1223 cat >expect <<-EOF &&
1224 fatal: unrecognized %(contents) argument: trailersonly
1226 test_must_fail git for-each-ref --format="%(contents:trailersonly)" 2>actual &&
1227 test_cmp expect actual
1230 test_expect_success 'basic atom: head contents:trailers' '
1231 git for-each-ref --format="%(contents:trailers)" refs/heads/main >actual &&
1232 sanitize_pgp <actual >actual.clean &&
1233 # git for-each-ref ends with a blank line
1234 cat >expect <<-EOF &&
1238 test_cmp expect actual.clean
1241 test_expect_success 'basic atom: rest must fail' '
1242 test_must_fail git for-each-ref --format="%(rest)" refs/heads/main
1245 test_expect_success 'trailer parsing not fooled by --- line' '
1246 git commit --allow-empty -F - <<-\EOF &&
1249 This is the body. The message has a "---" line which would confuse a
1250 message+patch parser. But here we know we have only a commit message,
1261 echo "trailer: right" &&
1264 git for-each-ref --format="%(trailers)" refs/heads/main >actual &&
1265 test_cmp expect actual
1268 test_expect_success 'Add symbolic ref for the following tests' '
1269 git symbolic-ref refs/heads/sym refs/heads/main
1276 test_expect_success 'Verify usage of %(symref) atom' '
1277 git for-each-ref --format="%(symref)" refs/heads/sym >actual &&
1278 test_cmp expected actual
1285 test_expect_success 'Verify usage of %(symref:short) atom' '
1286 git for-each-ref --format="%(symref:short)" refs/heads/sym >actual &&
1287 test_cmp expected actual
1295 test_expect_success 'Verify usage of %(symref:lstrip) atom' '
1296 git for-each-ref --format="%(symref:lstrip=2)" refs/heads/sym > actual &&
1297 git for-each-ref --format="%(symref:lstrip=-2)" refs/heads/sym >> actual &&
1298 test_cmp expected actual &&
1300 git for-each-ref --format="%(symref:strip=2)" refs/heads/sym > actual &&
1301 git for-each-ref --format="%(symref:strip=-2)" refs/heads/sym >> actual &&
1302 test_cmp expected actual
1310 test_expect_success 'Verify usage of %(symref:rstrip) atom' '
1311 git for-each-ref --format="%(symref:rstrip=2)" refs/heads/sym > actual &&
1312 git for-each-ref --format="%(symref:rstrip=-2)" refs/heads/sym >> actual &&
1313 test_cmp expected actual
1316 test_expect_success ':remotename and :remoteref' '
1317 git init remote-tests &&
1320 test_commit initial &&
1321 git branch -M main &&
1322 git remote add from fifth.coffee:blub &&
1323 git config branch.main.remote from &&
1324 git config branch.main.merge refs/heads/stable &&
1325 git remote add to southridge.audio:repo &&
1326 git config remote.to.push "refs/heads/*:refs/heads/pushed/*" &&
1327 git config branch.main.pushRemote to &&
1328 for pair in "%(upstream)=refs/remotes/from/stable" \
1329 "%(upstream:remotename)=from" \
1330 "%(upstream:remoteref)=refs/heads/stable" \
1331 "%(push)=refs/remotes/to/pushed/main" \
1332 "%(push:remotename)=to" \
1333 "%(push:remoteref)=refs/heads/pushed/main"
1335 echo "${pair#*=}" >expect &&
1336 git for-each-ref --format="${pair%=*}" \
1337 refs/heads/main >actual &&
1338 test_cmp expect actual || exit 1
1340 git branch push-simple &&
1341 git config branch.push-simple.pushRemote from &&
1342 actual="$(git for-each-ref \
1343 --format="%(push:remotename),%(push:remoteref)" \
1344 refs/heads/push-simple)" &&
1345 test from, = "$actual"
1349 test_expect_success 'for-each-ref --ignore-case ignores case' '
1350 git for-each-ref --format="%(refname)" refs/heads/MAIN >actual &&
1351 test_must_be_empty actual &&
1353 echo refs/heads/main >expect &&
1354 git for-each-ref --format="%(refname)" --ignore-case \
1355 refs/heads/MAIN >actual &&
1356 test_cmp expect actual
1359 test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' '
1360 # name refs numerically to avoid case-insensitive filesystem conflicts
1362 for email in a A b B
1364 for subject in a A b B
1366 GIT_COMMITTER_EMAIL="$email@example.com" \
1367 git tag -m "tag $subject" icase-$(printf %02d $nr) &&
1372 git for-each-ref --ignore-case \
1373 --format="%(taggeremail) %(subject) %(refname)" \
1376 --sort=taggeremail \
1377 refs/tags/icase-* >actual &&
1378 cat >expect <<-\
EOF &&
1379 <a@example.com> tag a refs/tags/icase-00
1380 <a@example.com> tag A refs/tags/icase-01
1381 <A@example.com> tag a refs/tags/icase-04
1382 <A@example.com> tag A refs/tags/icase-05
1383 <a@example.com> tag b refs/tags/icase-02
1384 <a@example.com> tag B refs/tags/icase-03
1385 <A@example.com> tag b refs/tags/icase-06
1386 <A@example.com> tag B refs/tags/icase-07
1387 <b@example.com> tag a refs/tags/icase-08
1388 <b@example.com> tag A refs/tags/icase-09
1389 <B@example.com> tag a refs/tags/icase-12
1390 <B@example.com> tag A refs/tags/icase-13
1391 <b@example.com> tag b refs/tags/icase-10
1392 <b@example.com> tag B refs/tags/icase-11
1393 <B@example.com> tag b refs/tags/icase-14
1394 <B@example.com> tag B refs/tags/icase-15
1396 test_cmp expect actual
1399 test_expect_success 'for-each-ref reports broken tags' '
1400 git tag -m "good tag" broken-tag-good HEAD &&
1401 git cat-file tag broken-tag-good >good &&
1402 sed s/commit/blob/ <good >bad &&
1403 bad=$(git hash-object -w -t tag bad) &&
1404 git update-ref refs/tags/broken-tag-bad $bad &&
1405 test_must_fail git for-each-ref --format="%(*objectname)" \
1406 refs/tags/broken-tag-*