summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8e1c3d)
raw | patch | inline | side by side (parent: c8e1c3d)
author | Junio C Hamano <gitster@pobox.com> | |
Sat, 28 Nov 2009 06:04:10 +0000 (22:04 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 28 Nov 2009 06:33:53 +0000 (22:33 -0800) |
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>
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>
diff.c | patch | blob | history | |
t/t4034-diff-words.sh | patch | blob | history |
index 0d7f5ea4a87d2152638f36b30d6366406d33bfa9..108c7d76441398386dd887e9ab608262c31286b4 100644 (file)
--- a/diff.c
+++ b/diff.c
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)
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 21db6e95c4dd7ccf2f25d887fc2c42f3adcd4124..2d24fbeda67772e0dd5e3331d74b0befabff272c 100755 (executable)
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
<WHITE>+++ b/post<RESET>
<BROWN>@@ -1,3 +1,7 @@<RESET>
<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
-<RESET>
+
a = b + c<RESET>
<GREEN>aa = a<RESET>
<WHITE>+++ b/post<RESET>
<BROWN>@@ -1,3 +1,7 @@<RESET>
h(4),<GREEN>hh<RESET>[44]
-<RESET>
+
a = b + c<RESET>
<GREEN>aa = a<RESET>
<WHITE>+++ b/post<RESET>
<BROWN>@@ -1,3 +1,7 @@<RESET>
h(4)<GREEN>,hh[44]<RESET>
-<RESET>
+
a = b + c<RESET>
<GREEN>aa = a<RESET>
<WHITE>+++ b/post<RESET>
<BROWN>@@ -1,3 +1,7 @@<RESET>
h(4),<GREEN>hh[44<RESET>]
-<RESET>
+
a = b + c<RESET>
<GREEN>aa = a<RESET>