From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH v2 2/2] ref-filter: add support for %(contents:size)
Date: Mon, 06 Jul 2020 14:44:17 -0700 [thread overview]
Message-ID: <xmqq5zb09v4e.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200702140845.24945-3-chriscool@tuxfamily.org> (Christian Couder's message of "Thu, 2 Jul 2020 16:08:45 +0200")
Christian Couder <christian.couder@gmail.com> writes:
> It's useful and efficient to be able to get the size of the
> contents directly without having to pipe through `wc -c`.
>
> Also the result of the following:
>
> `git for-each-ref --format='%(contents)' | wc -c`
>
> is off by one as `git for-each-ref` appends a newline character
> after the contents, which can be seen by comparing its ouput
> with the output from `git cat-file`.
So that's off by number of refs that are shown?
> +contents:size::
> + The size in bytes of the complete message.
> +
Complete as opposed to what?
What happens when the object referred to by the ref is not a commit
or a tag?
I am fine if it just is silently ignored (which is consistent with
already existing behaviour of other requests that do not make sense
for the given type) if the thing is a blob or a tree, but we'd need
to cover the case with a test or two. It seems you only expect this
with a tag object and do not have any test that checks for other
types of objects?
Thanks.
> +# We cannot use test_atom to check contents:size of signed tags due to sanitize_pgp
> +test_tag_contents_size_pgp () {
> + ref="$1"
> + test_expect_success $PREREQ "basic atom: $ref contents:size" "
> + git cat-file tag $ref | tail -n +6 | wc -c >expected &&
> + git for-each-ref --format='%(contents:size)' $ref >actual &&
> + test_cmp expected actual
> + "
> +}
> +
> PREREQ=GPG
> test_atom refs/tags/signed-empty subject ''
> test_atom refs/tags/signed-empty contents:subject ''
> @@ -629,6 +643,7 @@ test_atom refs/tags/signed-empty body "$sig"
> test_atom refs/tags/signed-empty contents:body ''
> test_atom refs/tags/signed-empty contents:signature "$sig"
> test_atom refs/tags/signed-empty contents "$sig"
> +test_tag_contents_size_pgp refs/tags/signed-empty
>
> test_atom refs/tags/signed-short subject 'subject line'
> test_atom refs/tags/signed-short contents:subject 'subject line'
> @@ -637,6 +652,7 @@ test_atom refs/tags/signed-short contents:body ''
> test_atom refs/tags/signed-short contents:signature "$sig"
> test_atom refs/tags/signed-short contents "subject line
> $sig"
> +test_tag_contents_size_pgp refs/tags/signed-short
>
> test_atom refs/tags/signed-long subject 'subject line'
> test_atom refs/tags/signed-long contents:subject 'subject line'
> @@ -649,6 +665,7 @@ test_atom refs/tags/signed-long contents "subject line
>
> body contents
> $sig"
> +test_tag_contents_size_pgp refs/tags/signed-long
>
> test_expect_success 'set up multiple-sort tags' '
> for when in 100000 200000
next prev parent reply other threads:[~2020-07-06 21:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 14:08 [PATCH v2 0/2] Add support for %(contents:size) in ref-filter Christian Couder
2020-07-02 14:08 ` [PATCH v2 1/2] Documentation: clarify %(contents:XXXX) doc Christian Couder
2020-07-06 21:34 ` Junio C Hamano
2020-07-02 14:08 ` [PATCH v2 2/2] ref-filter: add support for %(contents:size) Christian Couder
2020-07-06 21:44 ` Junio C Hamano [this message]
2020-07-07 8:40 ` Christian Couder
2020-07-07 15:28 ` Junio C Hamano
2020-07-07 5:02 ` [PATCH v2 0/2] Add support for %(contents:size) in ref-filter Jeff King
2020-07-07 6:19 ` Christian Couder
2020-07-08 4:43 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5zb09v4e.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).