summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-11-27 22:04:10 -0800
committerJunio C Hamano <gitster@pobox.com>2009-11-27 22:33:53 -0800
commit06a4755270b86a2af20a5c1f0d785311472b5223 (patch)
treeede83e7c993aa2ddb3f696e62f816d902468bcdf /diff.c
parentc8e1c3d3e8ed326fe9e8ba5616db2e81a41fcc16 (diff)
downloadgit-06a4755270b86a2af20a5c1f0d785311472b5223.tar.gz
emit_line(): don't emit an empty <SET><RESET> followed by a newline
When emit_line() is called with an empty line (but non-zero length, as we send line terminating LF or CRLF to the function), it used to emit <SET><RESET> followed by a newline. Stop the wastefulness. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index 0d7f5ea4a8..108c7d7644 100644
--- a/diff.c
+++ b/diff.c
@@ -295,12 +295,13 @@ static void emit_line_0(FILE *file, const char *set, const char *reset,
nofirst = 0;
}
- fputs(set, file);
-
- if (!nofirst)
- fputc(first, file);
- fwrite(line, len, 1, file);
- fputs(reset, file);
+ if (len || !nofirst) {
+ fputs(set, file);
+ if (!nofirst)
+ fputc(first, file);
+ fwrite(line, len, 1, file);
+ fputs(reset, file);
+ }
if (has_trailing_carriage_return)
fputc('\r', file);
if (has_trailing_newline)