Skip to content

Commit 3de9da8

Browse files
committed
Merge branch 'dd/t6300-wo-gpg-fix' into maint
Test fix. * dd/t6300-wo-gpg-fix: t6300: check for cat-file exit status code t6300: don't run cat-file on non-existent object
2 parents d4d9698 + 1549577 commit 3de9da8

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

t/t6300-for-each-ref.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,25 @@ test_atom() {
5959
# Automatically test "contents:size" atom after testing "contents"
6060
if test "$2" = "contents"
6161
then
62-
case $(git cat-file -t "$ref") in
63-
tag)
64-
# We cannot use $3 as it expects sanitize_pgp to run
65-
expect=$(git cat-file tag $ref | tail -n +6 | wc -c) ;;
66-
tree | blob)
67-
expect='' ;;
68-
commit)
69-
expect=$(printf '%s' "$3" | wc -c) ;;
70-
esac
71-
# Leave $expect unquoted to lose possible leading whitespaces
72-
echo $expect >expected
62+
# for commit leg, $3 is changed there
63+
expect=$(printf '%s' "$3" | wc -c)
7364
test_expect_${4:-success} $PREREQ "basic atom: $1 contents:size" '
65+
type=$(git cat-file -t "$ref") &&
66+
case $type in
67+
tag)
68+
# We cannot use $3 as it expects sanitize_pgp to run
69+
git cat-file tag $ref >out &&
70+
expect=$(tail -n +6 out | wc -c) &&
71+
rm -f out ;;
72+
tree | blob)
73+
expect="" ;;
74+
commit)
75+
: "use the calculated expect" ;;
76+
*)
77+
BUG "unknown object type" ;;
78+
esac &&
79+
# Leave $expect unquoted to lose possible leading whitespaces
80+
echo $expect >expected &&
7481
git for-each-ref --format="%(contents:size)" "$ref" >actual &&
7582
test_cmp expected actual
7683
'

0 commit comments

Comments
 (0)