summaryrefslogtreecommitdiff
path: root/t/t6300-for-each-ref.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t6300-for-each-ref.sh')
-rwxr-xr-xt/t6300-for-each-ref.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index da59fadc5d..a83579fbdf 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -52,6 +52,25 @@ test_atom() {
sanitize_pgp <actual >actual.clean &&
test_cmp expected actual.clean
"
+ # Automatically test "contents:size" atom after testing "contents"
+ if test "$2" = "contents"
+ then
+ case $(git cat-file -t "$ref") in
+ tag)
+ # We cannot use $3 as it expects sanitize_pgp to run
+ expect=$(git cat-file tag $ref | tail -n +6 | wc -c) ;;
+ tree | blob)
+ expect='' ;;
+ commit)
+ expect=$(printf '%s' "$3" | wc -c) ;;
+ esac
+ # Leave $expect unquoted to lose possible leading whitespaces
+ echo $expect >expected
+ test_expect_${4:-success} $PREREQ "basic atom: $1 contents:size" '
+ git for-each-ref --format="%(contents:size)" "$ref" >actual &&
+ test_cmp expected actual
+ '
+ fi
}
hexlen=$(test_oid hexsz)
@@ -650,6 +669,25 @@ test_atom refs/tags/signed-long contents "subject line
body contents
$sig"
+test_expect_success 'set up refs pointing to tree and blob' '
+ git update-ref refs/mytrees/first refs/heads/master^{tree} &&
+ git update-ref refs/myblobs/first refs/heads/master:one
+'
+
+test_atom refs/mytrees/first subject ""
+test_atom refs/mytrees/first contents:subject ""
+test_atom refs/mytrees/first body ""
+test_atom refs/mytrees/first contents:body ""
+test_atom refs/mytrees/first contents:signature ""
+test_atom refs/mytrees/first contents ""
+
+test_atom refs/myblobs/first subject ""
+test_atom refs/myblobs/first contents:subject ""
+test_atom refs/myblobs/first body ""
+test_atom refs/myblobs/first contents:body ""
+test_atom refs/myblobs/first contents:signature ""
+test_atom refs/myblobs/first contents ""
+
test_expect_success 'set up multiple-sort tags' '
for when in 100000 200000
do