3 test_description
='test tg revert --list --short mode'
9 mtblob
="$(git hash-object --stdin </dev/null)" || die
11 test $hashlen -ge 40 || die
14 awk '{sub(/ +/,""); print length($0)}'
17 test_expect_success
'setup' '
18 tg_test_create_branches <<-EOT &&
37 tg_test_create_tag t/tag &&
38 test_when_finished test_set_prereq SETUP
41 for hastmpdir
in "" 1; do
43 if [ -n "$hastmpdir" ]; then
45 TG_TMPDIR
="$PWD/tgtmpdir" && export TG_TMPDIR || die
48 test_expect_success SETUP
'full length hash only'"${hastmpdir:+ (persistent temp dir)}" '
49 printf "%s\n" "$hashlen" "$hashlen" "$hashlen" "$hashlen" "$hashlen" "$hashlen" >expected &&
50 tg revert --list --no-short t/tag >list &&
51 awklen <list >actual &&
52 test_must_fail test_cmp actual expected &&
53 tg revert --list --hash t/tag >list &&
54 awklen <list >actual &&
55 test_cmp actual expected
58 for len
in 16 17 18 19 20; do
59 test_expect_success SETUP
"length $len hash only${hastmpdir:+ (persistent temp dir)}" '
60 printf "%s\n" '"\"$len\" \"$len\" \"$len\" \"$len\" \"$len\" \"$len\""' >expected &&
61 tg revert --list --hash --short='"\"$len\""' t/tag >list &&
62 awklen <list >actual &&
63 test_cmp actual expected
67 test_expect_success SETUP
'full length rdeps hash only'"${hastmpdir:+ (persistent temp dir)}" '
68 printf "%s\n" "$hashlen" "$hashlen" "$hashlen" "$hashlen" "$hashlen" >expected &&
69 tg revert --list --hash --rdeps t/tag >list &&
70 awklen <list >actual &&
71 test_cmp actual expected
74 for len
in 16 17 18 19 20; do
75 test_expect_success SETUP
"length $len rdeps hash only${hastmpdir:+ (persistent temp dir)}" '
76 printf "%s\n" '"\"$len\" \"$len\" \"$len\" \"$len\" \"$len\""' >expected &&
77 tg revert --list --hash --rdeps --short='"\"$len\""' t/tag >list &&
78 awklen <list >actual &&
79 test_cmp actual expected