t6300: use test_atom for some un-modern tests

Because this script has to test so many formatters, we have the nice "test_atom" helper, but we don't use it consistently. Let's do so. This is shorter, gets rid of some tests that have their "expected" setup outside of a test_expect_success block, and lets us organize the changes better (e.g., putting "refname:short" near "refname"). We also expand the "%(push)" tests a little to match the "%(upstream)" ones. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 24, 2016 at 18:08 UTC 1d094db936331abc42d859269181272a8539c7ae
1 file changed +10 -52
t/t6300-for-each-ref.sh
+10 -52
@@ -49,11 +49,15 @@ test_atom() {
49 }
50
51 test_atom head refname refs/heads/master
52 +test_atom head refname:short master
53 test_atom head upstream refs/remotes/origin/master
54 +test_atom head upstream:short origin/master
55 test_atom head push refs/remotes/myfork/master
56 +test_atom head push:short myfork/master
57 test_atom head objecttype commit
58 test_atom head objectsize 171
59 test_atom head objectname $(git rev-parse refs/heads/master)
60 +test_atom head objectname:short $(git rev-parse --short refs/heads/master)
61 test_atom head tree $(git rev-parse refs/heads/master^{tree})
62 test_atom head parent ''
63 test_atom head numparent 0
@@ -86,11 +90,13 @@ test_atom head contents 'Initial
90 test_atom head HEAD '*'
91
92 test_atom tag refname refs/tags/testtag
93 +test_atom tag refname:short testtag
94 test_atom tag upstream ''
95 test_atom tag push ''
96 test_atom tag objecttype tag
97 test_atom tag objectsize 154
98 test_atom tag objectname $(git rev-parse refs/tags/testtag)
99 +test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
100 test_atom tag tree ''
101 test_atom tag parent ''
102 test_atom tag numparent ''
@@ -338,47 +344,14 @@ for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
344 "
345 done
346
341 -cat >expected <<\EOF
342 -master
343 -testtag
344 -EOF
345 -
346 -test_expect_success 'Check short refname format' '
347 - (git for-each-ref --format="%(refname:short)" refs/heads &&
348 - git for-each-ref --format="%(refname:short)" refs/tags) >actual &&
349 - test_cmp expected actual
350 -'
351 -
352 -cat >expected <<EOF
353 -origin/master
354 -EOF
355 -
356 -test_expect_success 'Check short upstream format' '
357 - git for-each-ref --format="%(upstream:short)" refs/heads >actual &&
358 - test_cmp expected actual
359 -'
360 -
347 test_expect_success 'setup for upstream:track[short]' '
348 test_commit two
349 '
350
365 -cat >expected <<EOF
366 -[ahead 1]
367 -EOF
368 -
369 -test_expect_success 'Check upstream:track format' '
370 - git for-each-ref --format="%(upstream:track)" refs/heads >actual &&
371 - test_cmp expected actual
372 -'
373 -
374 -cat >expected <<EOF
375 ->
376 -EOF
377 -
378 -test_expect_success 'Check upstream:trackshort format' '
379 - git for-each-ref --format="%(upstream:trackshort)" refs/heads >actual &&
380 - test_cmp expected actual
381 -'
351 +test_atom head upstream:track '[ahead 1]'
352 +test_atom head upstream:trackshort '>'
353 +test_atom head push:track '[ahead 1]'
354 +test_atom head push:trackshort '>'
355
356 test_expect_success 'Check that :track[short] cannot be used with other atoms' '
357 test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null &&
@@ -398,21 +371,6 @@ test_expect_success 'Check that :track[short] works when upstream is invalid' '
371 test_cmp expected actual
372 '
373
401 -test_expect_success '%(push) supports tracking specifiers, too' '
402 - echo "[ahead 1]" >expected &&
403 - git for-each-ref --format="%(push:track)" refs/heads >actual &&
404 - test_cmp expected actual
405 -'
406 -
407 -cat >expected <<EOF
408 -$(git rev-parse --short HEAD)
409 -EOF
410 -
411 -test_expect_success 'Check short objectname format' '
412 - git for-each-ref --format="%(objectname:short)" refs/heads >actual &&
413 - test_cmp expected actual
414 -'
415 -
374 test_expect_success 'Check for invalid refname format' '
375 test_must_fail git for-each-ref --format="%(refname:INVALID)"
376 '