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