Re: [PATCH v4 2/6] t/lib-patch-mode.sh: fix ignored exit codes
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Dec 27, 2022, 18:14 UTC
- Message-ID
- <221227.86h6xgvhgi.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <d9053dbe-a9b4-3d85-626d-0f1633058646@dunelm.org.uk>
On Tue, Dec 27 2022, Phillip Wood wrote:
Show 19 quoted lines
> Hi Ævar
>
> On 19/12/2022 10:19, Ævar Arnfjörð Bjarmason wrote:
>> Fix code added in b319ef70a94 (Add a small patch-mode testing library,
>> 2009-08-13) to use &&-chaining.
>> This avoids losing both the exit code of a "git" and the "cat"
>> processes.
>> This fixes cases where we'd have e.g. missed memory leaks under
>> SANITIZE=leak, this code doesn't leak now as far as I can tell, but I
>> discovered it while looking at leaks in related code.
>> [...] # verify_saved_state <path>
>> @@ -46,5 +50,6 @@ save_head () {
>> }
>> verify_saved_head () {
>> - test "$(cat _head)" = "$(git rev-parse HEAD)"
>> + git rev-parse HEAD >actual &&
>> + test_cmp _head actual
>
> Aren't these two lines are re-implementing test_cmp_rev()?It does --verify, and this does not.
Could we use it? Yes, but I wanted to narrowly focus on just fixing the lost exit codes in this series. Once you start to untangle "save_head" and "verify_saved_head" you'll see that whether we narrowly used a helper here or not isn't the only thing we could improve.
But such an improvement would make use use --verify, and we'd then want to use that "--verify" for the earlier saved_head too, etc.