Message ID | 20200716121940.21041-1-chriscool@tuxfamily.org (mailing list archive) |
---|---|
Headers | show |
Series | Add support for %(contents:size) in ref-filter | expand |
Christian Couder <christian.couder@gmail.com> writes: > 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 > } Ah, I almost forgot about this topic X-<, but the above reminds me and it does read more clearly, at least to me. Thanks, will replace.