Re: [PATCH 8/8] check-whitespace: detect if no base_commit is provided
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 11, 2024, 14:41 UTC
- Message-ID
- <xmqqsewgng80.fsf@gitster.g>
- In-Reply-To
- <CAOLa=ZSUZGqxHbEtpR3fadOFf=YPVxbo8W7SwyB9j5am14EB7A@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 18 quoted lines
>> I was commenting on the exit status check done here:
>>
>> +gitLogOutput=$(git log --check --pretty=format:"---% h% s" "${baseCommit}"..)
>> +if test $? -ne 0
>> +then
>> + echo -n $gitLogOutput
>> + exit 1
>> +fi
>>
>> Even though the output is captured in a variable, the exit status of
>> "git log --check" is still seen by the shell and "if test $? = 0"
>> next line say "ah, the thing exited with non-zero status so lets
>> echo the whole thing and exit with 1", before it gets to the while
>> loop we have below the above piece of code, no?
>
> My bad, I thought you were referring to the code before my changes. Yes,
> here you're right, we don't need the check since the shell would capture
> the non-zero status.OK.
Because in the next round, you'd be checking the error condition of "git rev-parse $baseCommit" or something that is specifically designed to check the validity of user input, and not the error result from the actual "log --check", the above becomes moot ;-)
Thanks.