Re: [PATCH v3 4/4] ref-filter: add support for %(contents:size)
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 9, 2020, 00:14 UTC
- Message-ID
- <xmqqtuyhzgro.fsf@gitster.c.googlers.com>
- In-Reply-To
- <xmqqk0zf3y8s.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Of course, we _could_ update the test_atom to do something magic > only when the 'contents' atom is being asked. We notice that $2 is > 'contents', do the usual test_expect_success for 'contents', and > then measure the byte length of $3 ourselves and test > 'contents:size'. That way, all the above test updates would become > unnecessary (and the last two hunks of this patch can also go). > > That approach may even allow you to hide the details of sanitize-pgp > in the updated test_atom so that the actual tests may not have to get > updated even for signed tags.
After seeing the "wc -c" portability issues, I am now even more inclined to say that the above is the right direction. The portability worries can and should be encapsulated in a single test_atom helper function, just as it can be used to hide the differences between signed tags, annotated tags and commits.
Thanks.
Show 9 quoted lines
>> +# 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
>> + "
>> +}