Re: [PATCH v2] test_must_be_empty: simplify file existence check
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 28, 2018, 05:20 UTC
- Message-ID
- <xmqqzi2s93p6.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <xmqqd0zp9i0d.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 28 quoted lines
>> test_must_be_empty () {
>> - if ! test -f "$1"
>> - then
>> - echo "'$1' is missing"
>> - return 1
>> - elif test -s "$1"
>> + test_path_is_file "$1" &&
>> + if test -s "$1"
>> then
>> echo "'$1' is not empty, it contains:"
>> cat "$1"
>
> "Just call it" is fine as an idea but
>
> A &&
> if B
> then
> ...
> fi
>
> is somewhat questionable. Shouldn't we make it
>
> if A && B
> then
> ...
> fi
>
> instead?Nah, you want to treat A's success as a condition *not* to enter the "then" clause in this case, so my rewrite is bogus. SOrry for the noise.