Thread (1 message) 1 message, 1 author, 2019-09-10

Re: [RFC PATCH 1/1] for-each-ref: do not output empty lines

From: Junio C Hamano <hidden>
Date: 2019-09-10 06:14:42

Junio C Hamano [off-list ref] writes:
quoted
 	fwrite(final_buf.buf, 1, final_buf.len, stdout);
+	if (final_buf.len)
+		putchar('\n');
While we are introducing a conditional, let's drop the useless
fwrite of 0-byte while we are at it [*1*], i.e.

	if (final_buf.len && !omit_empty_lines) {
Of course, that's a typo for "||"; if it is not empty, we'd emit no
matter what, and if omit_empty is not given, we'd emit whether it is
empty or not.
		fwrite(final_buf.buf, 1, final_buf.len, stdout);
		putchar('\n');
	}

Thanks.


[Footnote]

*1* "While we are at it", the existing code tempts me to drop fwrite
    and replace it with something along the lines of...

	printf("%*s\n", count, buf)

    but I refrained from doing so.  An enhancement patch like this
    is not a place to "improve" existing code (which should be done
    as a separate patch).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help