Re: [PATCH GSoC v3 1/8] t5701: use test_file_size() to get the size of a file

"Pablo Sabater" <[email protected]> Mon, 03 Aug 2026 23:12:46 +0200
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
On Mon Aug 3, 2026 at 7:21 PM CEST, Junio C Hamano wrote:
> Pablo Sabater <[email protected]> writes:
>
>> The 'basics of object-info' test runs 'wc -c | xargs' twice to get the
>> size of two.t. The pipe to xargs is only there to strip the blanks
>> that some platforms pad the output of wc with.
>>
>> Use the test_file_size() helper, which outputs the size directly, and
>> store the result in a variable. Because 'git rev-parse two:two.t' is
>> also run twice, store its output in a variable as well.
>
> It also has the benefit of retaining the exit status from commands
> run inside a $( ... ) construct placed within a HERE-document.
> Earlier, if your "git rev-parse" failed, you would not have noticed
> it directly (though you would probably have seen the "expect" file
> containing unexpected content).  Now your assignment fails when you
> compute two_oid, if your "git rev-parse" segfaults.

I will add that next reroll.

Thanks,
Pablo