Re: [PATCH 2/2] branch, for-each-ref: add option to omit empty lines
- From
Jeff King <peff@peff.net>
- Date
- Mar 30, 2023, 18:25 UTC
- Message-ID
- <20230330182502.GB3286761@coredump.intra.peff.net>
- In-Reply-To
- <xmqqilei1bgk.fsf@gitster.g>
On Thu, Mar 30, 2023 at 08:54:35AM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> * now we care if output is empty anyway, perhaps we can optimize
> out fwrite() too, perhaps with something like
>
> if (output.len || !omit_empty)
> printf("%.*s\n", output.len, output.buf);
>
> perhaps?
>
> I am not sure about the latter, but we tend to use "%.*s" liberally
> when we could use fwrite() in our codebase for brevity, so ...I think it would be a mistake here, as you can use "%00" in the format to include a NUL in the output.
(The rest of your review seemed quite sensible to me, and I like the idea of the omit-empty option in general).
-Peff