This is version 5 of a small patch series to teach ref-filter about %(contents:size). This patch series is based on master at 4a0fcf9f76 (The seventh batch, 2020-07-06). Previous versions and related discussions are there: V1: https://lore.kernel.org/git/20200701132308.16691-1-chriscool@xxxxxxxxxxxxx/ V2: https://lore.kernel.org/git/20200702140845.24945-1-chriscool@xxxxxxxxxxxxx/ V3: https://lore.kernel.org/git/20200707174049.21714-1-chriscool@xxxxxxxxxxxxx/ V4: https://lore.kernel.org/git/20200710164739.6616-1-chriscool@xxxxxxxxxxxxx/ Thanks to Junio and Peff for their reviews of this series! The changes compared to V4 are the following: - Modified test_atom() in patch 3/3 to as suggested by Junio. The range diff is: 1: f750832fc7 = 1: f750832fc7 Documentation: clarify %(contents:XXXX) doc 2: 51c72e09d2 = 2: 51c72e09d2 t6300: test refs pointing to tree and blob 3: c2ed3e228b ! 3: cf6a60036e ref-filter: add support for %(contents:size) @@ t/t6300-for-each-ref.sh: test_atom() { + # Automatically test "contents:size" atom after testing "contents" + if test "$2" = "contents" + then -+ case "$1" in -+ refs/tags/signed-*) ++ 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) ;; -+ refs/mytrees/* | refs/myblobs/*) ++ 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 $2:size" " -+ git for-each-ref --format='%($2:size)' $ref >actual && -+ test_cmp expected actual -+ " ++ test_expect_${4:-sucess} $PREREQ "basic atom: $1 contents:size" ' ++ git for-each-ref --format="%(contents:size)" "$ref" >actual && ++ test_cmp expect actual ++ ' + fi } Christian Couder (3): Documentation: clarify %(contents:XXXX) doc t6300: test refs pointing to tree and blob ref-filter: add support for %(contents:size) Documentation/git-for-each-ref.txt | 27 ++++++++++++++++----- ref-filter.c | 7 +++++- t/t6300-for-each-ref.sh | 38 ++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 7 deletions(-) -- 2.27.0.227.g757ac19d14.dirty