]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6300-for-each-ref.sh
completion tests: don't add test cruft to the test repository
[thirdparty/git.git] / t / t6300-for-each-ref.sh
CommitLineData
96b2d4fa
AP
1#!/bin/sh
2#
3# Copyright (c) 2007 Andy Parkins
4#
5
6test_description='for-each-ref test'
7
8. ./test-lib.sh
e2b23972 9. "$TEST_DIRECTORY"/lib-gpg.sh
96b2d4fa 10
db7bae25
JK
11# Mon Jul 3 23:18:43 2006 +0000
12datestamp=1151968723
96b2d4fa
AP
13setdate_and_increment () {
14 GIT_COMMITTER_DATE="$datestamp +0200"
15 datestamp=$(expr "$datestamp" + 1)
16 GIT_AUTHOR_DATE="$datestamp +0200"
17 datestamp=$(expr "$datestamp" + 1)
18 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
19}
20
bc147968 21test_expect_success setup '
96b2d4fa
AP
22 setdate_and_increment &&
23 echo "Using $datestamp" > one &&
24 git add one &&
25 git commit -m "Initial" &&
26 setdate_and_increment &&
bc147968 27 git tag -a -m "Tagging at $datestamp" testtag &&
8cae19d9
JK
28 git update-ref refs/remotes/origin/master master &&
29 git remote add origin nowhere &&
30 git config branch.master.remote origin &&
29bc8850
JK
31 git config branch.master.merge refs/heads/master &&
32 git remote add myfork elsewhere &&
33 git config remote.pushdefault myfork &&
34 git config push.default current
8cae19d9
JK
35'
36
d2bf48d2
JK
37test_atom() {
38 case "$1" in
39 head) ref=refs/heads/master ;;
40 tag) ref=refs/tags/testtag ;;
7140c22c 41 *) ref=$1 ;;
d2bf48d2
JK
42 esac
43 printf '%s\n' "$3" >expected
e2b23972 44 test_expect_${4:-success} $PREREQ "basic atom: $1 $2" "
d2bf48d2 45 git for-each-ref --format='%($2)' $ref >actual &&
e2b23972
MG
46 sanitize_pgp <actual >actual.clean &&
47 test_cmp expected actual.clean
d2bf48d2
JK
48 "
49}
50
51test_atom head refname refs/heads/master
1d094db9 52test_atom head refname:short master
0571979b
JK
53test_atom head refname:strip=1 heads/master
54test_atom head refname:strip=2 master
8cae19d9 55test_atom head upstream refs/remotes/origin/master
1d094db9 56test_atom head upstream:short origin/master
29bc8850 57test_atom head push refs/remotes/myfork/master
1d094db9 58test_atom head push:short myfork/master
d2bf48d2
JK
59test_atom head objecttype commit
60test_atom head objectsize 171
189a5467 61test_atom head objectname $(git rev-parse refs/heads/master)
1d094db9 62test_atom head objectname:short $(git rev-parse --short refs/heads/master)
189a5467 63test_atom head tree $(git rev-parse refs/heads/master^{tree})
d2bf48d2
JK
64test_atom head parent ''
65test_atom head numparent 0
66test_atom head object ''
67test_atom head type ''
b74cf648
JK
68test_atom head '*objectname' ''
69test_atom head '*objecttype' ''
db7bae25 70test_atom head author 'A U Thor <author@example.com> 1151968724 +0200'
d2bf48d2
JK
71test_atom head authorname 'A U Thor'
72test_atom head authoremail '<author@example.com>'
db7bae25
JK
73test_atom head authordate 'Tue Jul 4 01:18:44 2006 +0200'
74test_atom head committer 'C O Mitter <committer@example.com> 1151968723 +0200'
d2bf48d2
JK
75test_atom head committername 'C O Mitter'
76test_atom head committeremail '<committer@example.com>'
db7bae25 77test_atom head committerdate 'Tue Jul 4 01:18:43 2006 +0200'
d2bf48d2
JK
78test_atom head tag ''
79test_atom head tagger ''
80test_atom head taggername ''
81test_atom head taggeremail ''
82test_atom head taggerdate ''
db7bae25
JK
83test_atom head creator 'C O Mitter <committer@example.com> 1151968723 +0200'
84test_atom head creatordate 'Tue Jul 4 01:18:43 2006 +0200'
d2bf48d2 85test_atom head subject 'Initial'
e2b23972 86test_atom head contents:subject 'Initial'
d2bf48d2 87test_atom head body ''
e2b23972
MG
88test_atom head contents:body ''
89test_atom head contents:signature ''
d2bf48d2
JK
90test_atom head contents 'Initial
91'
7a48b832 92test_atom head HEAD '*'
d2bf48d2
JK
93
94test_atom tag refname refs/tags/testtag
1d094db9 95test_atom tag refname:short testtag
8cae19d9 96test_atom tag upstream ''
29bc8850 97test_atom tag push ''
d2bf48d2
JK
98test_atom tag objecttype tag
99test_atom tag objectsize 154
189a5467 100test_atom tag objectname $(git rev-parse refs/tags/testtag)
1d094db9 101test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
d2bf48d2
JK
102test_atom tag tree ''
103test_atom tag parent ''
104test_atom tag numparent ''
189a5467 105test_atom tag object $(git rev-parse refs/tags/testtag^0)
d2bf48d2 106test_atom tag type 'commit'
db7bae25 107test_atom tag '*objectname' 'ea122842f48be4afb2d1fc6a4b96c05885ab7463'
b74cf648 108test_atom tag '*objecttype' 'commit'
d2bf48d2
JK
109test_atom tag author ''
110test_atom tag authorname ''
111test_atom tag authoremail ''
112test_atom tag authordate ''
113test_atom tag committer ''
114test_atom tag committername ''
115test_atom tag committeremail ''
116test_atom tag committerdate ''
117test_atom tag tag 'testtag'
db7bae25 118test_atom tag tagger 'C O Mitter <committer@example.com> 1151968725 +0200'
d2bf48d2
JK
119test_atom tag taggername 'C O Mitter'
120test_atom tag taggeremail '<committer@example.com>'
db7bae25
JK
121test_atom tag taggerdate 'Tue Jul 4 01:18:45 2006 +0200'
122test_atom tag creator 'C O Mitter <committer@example.com> 1151968725 +0200'
123test_atom tag creatordate 'Tue Jul 4 01:18:45 2006 +0200'
124test_atom tag subject 'Tagging at 1151968727'
125test_atom tag contents:subject 'Tagging at 1151968727'
d2bf48d2 126test_atom tag body ''
e2b23972
MG
127test_atom tag contents:body ''
128test_atom tag contents:signature ''
db7bae25 129test_atom tag contents 'Tagging at 1151968727
96b2d4fa 130'
7a48b832 131test_atom tag HEAD ' '
96b2d4fa 132
41ac414e 133test_expect_success 'Check invalid atoms names are errors' '
3604e7c5 134 test_must_fail git for-each-ref --format="%(INVALID)" refs/heads
96b2d4fa
AP
135'
136
0571979b
JK
137test_expect_success 'arguments to :strip must be positive integers' '
138 test_must_fail git for-each-ref --format="%(refname:strip=0)" &&
139 test_must_fail git for-each-ref --format="%(refname:strip=-1)" &&
140 test_must_fail git for-each-ref --format="%(refname:strip=foo)"
141'
142
143test_expect_success 'stripping refnames too far gives an error' '
144 test_must_fail git for-each-ref --format="%(refname:strip=3)"
145'
146
96b2d4fa 147test_expect_success 'Check format specifiers are ignored in naming date atoms' '
3604e7c5
NS
148 git for-each-ref --format="%(authordate)" refs/heads &&
149 git for-each-ref --format="%(authordate:default) %(authordate)" refs/heads &&
150 git for-each-ref --format="%(authordate) %(authordate:default)" refs/heads &&
151 git for-each-ref --format="%(authordate:default) %(authordate:default)" refs/heads
96b2d4fa
AP
152'
153
154test_expect_success 'Check valid format specifiers for date fields' '
3604e7c5
NS
155 git for-each-ref --format="%(authordate:default)" refs/heads &&
156 git for-each-ref --format="%(authordate:relative)" refs/heads &&
157 git for-each-ref --format="%(authordate:short)" refs/heads &&
158 git for-each-ref --format="%(authordate:local)" refs/heads &&
159 git for-each-ref --format="%(authordate:iso8601)" refs/heads &&
160 git for-each-ref --format="%(authordate:rfc2822)" refs/heads
96b2d4fa
AP
161'
162
41ac414e 163test_expect_success 'Check invalid format specifiers are errors' '
3604e7c5 164 test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
96b2d4fa
AP
165'
166
f95cecf4
JK
167test_date () {
168 f=$1 &&
169 committer_date=$2 &&
170 author_date=$3 &&
171 tagger_date=$4 &&
172 cat >expected <<-EOF &&
173 'refs/heads/master' '$committer_date' '$author_date'
174 'refs/tags/testtag' '$tagger_date'
175 EOF
176 (
177 git for-each-ref --shell \
178 --format="%(refname) %(committerdate${f:+:$f}) %(authordate${f:+:$f})" \
179 refs/heads &&
180 git for-each-ref --shell \
181 --format="%(refname) %(taggerdate${f:+:$f})" \
182 refs/tags
183 ) >actual &&
184 test_cmp expected actual
185}
96b2d4fa
AP
186
187test_expect_success 'Check unformatted date fields output' '
f95cecf4 188 test_date "" \
db7bae25
JK
189 "Tue Jul 4 01:18:43 2006 +0200" \
190 "Tue Jul 4 01:18:44 2006 +0200" \
191 "Tue Jul 4 01:18:45 2006 +0200"
96b2d4fa
AP
192'
193
194test_expect_success 'Check format "default" formatted date fields output' '
f95cecf4 195 test_date default \
db7bae25
JK
196 "Tue Jul 4 01:18:43 2006 +0200" \
197 "Tue Jul 4 01:18:44 2006 +0200" \
198 "Tue Jul 4 01:18:45 2006 +0200"
96b2d4fa
AP
199'
200
99264e93
JK
201test_expect_success 'Check format "default-local" date fields output' '
202 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"
96b2d4fa
AP
203'
204
205# Don't know how to do relative check because I can't know when this script
206# is going to be run and can't fake the current time to git, and hence can't
207# provide expected output. Instead, I'll just make sure that "relative"
208# doesn't exit in error
96b2d4fa
AP
209test_expect_success 'Check format "relative" date fields output' '
210 f=relative &&
211 (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
212 git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
213'
214
99264e93
JK
215# We just check that this is the same as "relative" for now.
216test_expect_success 'Check format "relative-local" date fields output' '
217 test_date relative-local \
218 "$(git for-each-ref --format="%(committerdate:relative)" refs/heads)" \
219 "$(git for-each-ref --format="%(authordate:relative)" refs/heads)" \
220 "$(git for-each-ref --format="%(taggerdate:relative)" refs/tags)"
221'
96b2d4fa
AP
222
223test_expect_success 'Check format "short" date fields output' '
db7bae25 224 test_date short 2006-07-04 2006-07-04 2006-07-04
96b2d4fa
AP
225'
226
99264e93
JK
227test_expect_success 'Check format "short-local" date fields output' '
228 test_date short-local 2006-07-03 2006-07-03 2006-07-03
229'
96b2d4fa
AP
230
231test_expect_success 'Check format "local" date fields output' '
f95cecf4 232 test_date local \
db7bae25
JK
233 "Mon Jul 3 23:18:43 2006" \
234 "Mon Jul 3 23:18:44 2006" \
235 "Mon Jul 3 23:18:45 2006"
96b2d4fa
AP
236'
237
96b2d4fa 238test_expect_success 'Check format "iso8601" date fields output' '
f95cecf4 239 test_date iso8601 \
db7bae25
JK
240 "2006-07-04 01:18:43 +0200" \
241 "2006-07-04 01:18:44 +0200" \
242 "2006-07-04 01:18:45 +0200"
96b2d4fa
AP
243'
244
99264e93
JK
245test_expect_success 'Check format "iso8601-local" date fields output' '
246 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"
247'
96b2d4fa
AP
248
249test_expect_success 'Check format "rfc2822" date fields output' '
f95cecf4 250 test_date rfc2822 \
db7bae25
JK
251 "Tue, 4 Jul 2006 01:18:43 +0200" \
252 "Tue, 4 Jul 2006 01:18:44 +0200" \
253 "Tue, 4 Jul 2006 01:18:45 +0200"
96b2d4fa
AP
254'
255
99264e93
JK
256test_expect_success 'Check format "rfc2822-local" date fields output' '
257 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"
258'
259
f3c1ba50 260test_expect_success 'Check format "raw" date fields output' '
db7bae25 261 test_date raw "1151968723 +0200" "1151968724 +0200" "1151968725 +0200"
f3c1ba50
JK
262'
263
99264e93
JK
264test_expect_success 'Check format "raw-local" date fields output' '
265 test_date raw-local "1151968723 +0000" "1151968724 +0000" "1151968725 +0000"
96b2d4fa
AP
266'
267
aa1462cc 268test_expect_success 'Check format of strftime date fields' '
db7bae25 269 echo "my date is 2006-07-04" >expected &&
aa1462cc
JK
270 git for-each-ref \
271 --format="%(authordate:format:my date is %Y-%m-%d)" \
272 refs/heads >actual &&
273 test_cmp expected actual
274'
275
99264e93
JK
276test_expect_success 'Check format of strftime-local date fields' '
277 echo "my date is 2006-07-03" >expected &&
278 git for-each-ref \
279 --format="%(authordate:format-local:my date is %Y-%m-%d)" \
280 refs/heads >actual &&
281 test_cmp expected actual
282'
283
e4f031e3
JK
284test_expect_success 'exercise strftime with odd fields' '
285 echo >expected &&
286 git for-each-ref --format="%(authordate:format:)" refs/heads >actual &&
287 test_cmp expected actual &&
288 long="long format -- $_z40$_z40$_z40$_z40$_z40$_z40$_z40" &&
289 echo $long >expected &&
290 git for-each-ref --format="%(authordate:format:$long)" refs/heads >actual &&
291 test_cmp expected actual
292'
293
c899a57c
LH
294cat >expected <<\EOF
295refs/heads/master
8cae19d9 296refs/remotes/origin/master
c899a57c
LH
297refs/tags/testtag
298EOF
299
300test_expect_success 'Verify ascending sort' '
3604e7c5 301 git for-each-ref --format="%(refname)" --sort=refname >actual &&
3af82863 302 test_cmp expected actual
c899a57c
LH
303'
304
305
306cat >expected <<\EOF
307refs/tags/testtag
8cae19d9 308refs/remotes/origin/master
c899a57c
LH
309refs/heads/master
310EOF
311
312test_expect_success 'Verify descending sort' '
3604e7c5 313 git for-each-ref --format="%(refname)" --sort=-refname >actual &&
3af82863 314 test_cmp expected actual
c899a57c
LH
315'
316
c9ecf4f1
JS
317cat >expected <<\EOF
318'refs/heads/master'
8cae19d9 319'refs/remotes/origin/master'
c9ecf4f1
JS
320'refs/tags/testtag'
321EOF
322
323test_expect_success 'Quoting style: shell' '
324 git for-each-ref --shell --format="%(refname)" >actual &&
3af82863 325 test_cmp expected actual
c9ecf4f1
JS
326'
327
328test_expect_success 'Quoting style: perl' '
329 git for-each-ref --perl --format="%(refname)" >actual &&
3af82863 330 test_cmp expected actual
c9ecf4f1
JS
331'
332
333test_expect_success 'Quoting style: python' '
334 git for-each-ref --python --format="%(refname)" >actual &&
3af82863 335 test_cmp expected actual
c9ecf4f1
JS
336'
337
338cat >expected <<\EOF
339"refs/heads/master"
8cae19d9 340"refs/remotes/origin/master"
c9ecf4f1
JS
341"refs/tags/testtag"
342EOF
343
344test_expect_success 'Quoting style: tcl' '
345 git for-each-ref --tcl --format="%(refname)" >actual &&
3af82863 346 test_cmp expected actual
c9ecf4f1
JS
347'
348
349for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
350 test_expect_success "more than one quoting style: $i" "
351 git for-each-ref $i 2>&1 | (read line &&
352 case \$line in
353 \"error: more than one quoting style\"*) : happy;;
354 *) false
355 esac)
356 "
357done
c899a57c 358
b28061ce
RR
359test_expect_success 'setup for upstream:track[short]' '
360 test_commit two
361'
362
1d094db9
JK
363test_atom head upstream:track '[ahead 1]'
364test_atom head upstream:trackshort '>'
365test_atom head push:track '[ahead 1]'
366test_atom head push:trackshort '>'
b28061ce
RR
367
368test_expect_success 'Check that :track[short] cannot be used with other atoms' '
369 test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null &&
370 test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null
371'
372
b6160d95
RKC
373test_expect_success 'Check that :track[short] works when upstream is invalid' '
374 cat >expected <<-\EOF &&
375
376
377 EOF
378 test_when_finished "git config branch.master.merge refs/heads/master" &&
379 git config branch.master.merge refs/heads/does-not-exist &&
380 git for-each-ref \
381 --format="%(upstream:track)$LF%(upstream:trackshort)" \
382 refs/heads >actual &&
383 test_cmp expected actual
29bc8850
JK
384'
385
7d66f21a
BW
386test_expect_success 'Check for invalid refname format' '
387 test_must_fail git for-each-ref --format="%(refname:INVALID)"
388'
389
fddb74c9
RR
390get_color ()
391{
392 git config --get-color no.such.slot "$1"
393}
394
395cat >expected <<EOF
396$(git rev-parse --short refs/heads/master) $(get_color green)master$(get_color reset)
397$(git rev-parse --short refs/remotes/origin/master) $(get_color green)origin/master$(get_color reset)
398$(git rev-parse --short refs/tags/testtag) $(get_color green)testtag$(get_color reset)
399$(git rev-parse --short refs/tags/two) $(get_color green)two$(get_color reset)
400EOF
401
402test_expect_success 'Check %(color:...) ' '
db64eb65 403 git for-each-ref --format="%(objectname:short) %(color:green)%(refname:short)" >actual &&
fddb74c9
RR
404 test_cmp expected actual
405'
406
7d66f21a
BW
407cat >expected <<\EOF
408heads/master
2bb98169 409tags/master
7d66f21a
BW
410EOF
411
2bb98169
BW
412test_expect_success 'Check ambiguous head and tag refs (strict)' '
413 git config --bool core.warnambiguousrefs true &&
7d66f21a
BW
414 git checkout -b newtag &&
415 echo "Using $datestamp" > one &&
416 git add one &&
417 git commit -m "Branch" &&
418 setdate_and_increment &&
419 git tag -m "Tagging at $datestamp" master &&
420 git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
421 test_cmp expected actual
422'
423
2bb98169
BW
424cat >expected <<\EOF
425heads/master
426master
427EOF
428
429test_expect_success 'Check ambiguous head and tag refs (loose)' '
430 git config --bool core.warnambiguousrefs false &&
431 git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
432 test_cmp expected actual
433'
434
7d66f21a
BW
435cat >expected <<\EOF
436heads/ambiguous
437ambiguous
438EOF
439
2bb98169 440test_expect_success 'Check ambiguous head and tag refs II (loose)' '
7d66f21a
BW
441 git checkout master &&
442 git tag ambiguous testtag^0 &&
443 git branch ambiguous testtag^0 &&
444 git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual &&
445 test_cmp expected actual
446'
447
e276c26b
JH
448test_expect_success 'an unusual tag with an incomplete line' '
449
450 git tag -m "bogo" bogo &&
451 bogo=$(git cat-file tag bogo) &&
452 bogo=$(printf "%s" "$bogo" | git mktag) &&
453 git tag -f bogo "$bogo" &&
454 git for-each-ref --format "%(body)" refs/tags/bogo
455
456'
457
7140c22c
JK
458test_expect_success 'create tag with subject and body content' '
459 cat >>msg <<-\EOF &&
460 the subject line
461
462 first body line
463 second body line
464 EOF
465 git tag -F msg subject-body
466'
467test_atom refs/tags/subject-body subject 'the subject line'
468test_atom refs/tags/subject-body body 'first body line
469second body line
470'
471test_atom refs/tags/subject-body contents 'the subject line
472
473first body line
474second body line
475'
476
7f6e275b
JK
477test_expect_success 'create tag with multiline subject' '
478 cat >msg <<-\EOF &&
479 first subject line
480 second subject line
481
482 first body line
483 second body line
484 EOF
485 git tag -F msg multiline
486'
487test_atom refs/tags/multiline subject 'first subject line second subject line'
e2b23972 488test_atom refs/tags/multiline contents:subject 'first subject line second subject line'
7f6e275b
JK
489test_atom refs/tags/multiline body 'first body line
490second body line
491'
e2b23972
MG
492test_atom refs/tags/multiline contents:body 'first body line
493second body line
494'
495test_atom refs/tags/multiline contents:signature ''
7f6e275b
JK
496test_atom refs/tags/multiline contents 'first subject line
497second subject line
498
499first body line
500second body line
501'
502
e2b23972
MG
503test_expect_success GPG 'create signed tags' '
504 git tag -s -m "" signed-empty &&
505 git tag -s -m "subject line" signed-short &&
506 cat >msg <<-\EOF &&
507 subject line
508
509 body contents
510 EOF
511 git tag -s -F msg signed-long
512'
513
514sig='-----BEGIN PGP SIGNATURE-----
515-----END PGP SIGNATURE-----
516'
517
518PREREQ=GPG
519test_atom refs/tags/signed-empty subject ''
520test_atom refs/tags/signed-empty contents:subject ''
521test_atom refs/tags/signed-empty body "$sig"
522test_atom refs/tags/signed-empty contents:body ''
523test_atom refs/tags/signed-empty contents:signature "$sig"
524test_atom refs/tags/signed-empty contents "$sig"
525
526test_atom refs/tags/signed-short subject 'subject line'
527test_atom refs/tags/signed-short contents:subject 'subject line'
528test_atom refs/tags/signed-short body "$sig"
529test_atom refs/tags/signed-short contents:body ''
530test_atom refs/tags/signed-short contents:signature "$sig"
531test_atom refs/tags/signed-short contents "subject line
532$sig"
533
534test_atom refs/tags/signed-long subject 'subject line'
535test_atom refs/tags/signed-long contents:subject 'subject line'
536test_atom refs/tags/signed-long body "body contents
537$sig"
538test_atom refs/tags/signed-long contents:body 'body contents
539'
540test_atom refs/tags/signed-long contents:signature "$sig"
541test_atom refs/tags/signed-long contents "subject line
542
543body contents
544$sig"
545
189a5467 546cat >expected <<EOF
189a5467 547$(git rev-parse refs/tags/bogo) <committer@example.com> refs/tags/bogo
db7bae25 548$(git rev-parse refs/tags/master) <committer@example.com> refs/tags/master
912072d5
KK
549EOF
550
3b51222c 551test_expect_success 'Verify sort with multiple keys' '
912072d5
KK
552 git for-each-ref --format="%(objectname) %(taggeremail) %(refname)" --sort=objectname --sort=taggeremail \
553 refs/tags/bogo refs/tags/master > actual &&
554 test_cmp expected actual
555'
84679d47
JH
556
557test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
558 test_when_finished "git checkout master" &&
559 git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
560 sed -e "s/^\* / /" actual >expect &&
561 git checkout --orphan HEAD &&
562 git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
563 test_cmp expect actual
564'
565
b1d31c89
JK
566cat >trailers <<EOF
567Reviewed-by: A U Thor <author@example.com>
568Signed-off-by: A U Thor <author@example.com>
569EOF
570
571test_expect_success 'basic atom: head contents:trailers' '
572 echo "Some contents" > two &&
573 git add two &&
574 git commit -F - <<-EOF &&
575 trailers: this commit message has trailers
576
577 Some message contents
578
579 $(cat trailers)
580 EOF
581 git for-each-ref --format="%(contents:trailers)" refs/heads/master >actual &&
582 sanitize_pgp <actual >actual.clean &&
583 # git for-each-ref ends with a blank line
584 cat >expect <<-EOF &&
585 $(cat trailers)
586
587 EOF
588 test_cmp expect actual.clean
589'
590
96b2d4fa 591test_done