summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06ff64a)
raw | patch | inline | side by side (parent: 06ff64a)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 17 Jun 2008 00:37:21 +0000 (17:37 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 17 Jun 2008 00:37:21 +0000 (17:37 -0700) |
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history |
index c0284775d396fc1ff89406ea9c304acc8f013c43..20135cbe7c8209835dca8d52d1d48e7aa871c1b3 100644 (file)
--- a/diff.c
+++ b/diff.c
static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len)
{
- if (len > 0 && line[len-1] == '\n')
+ int has_trailing_newline = (len > 0 && line[len-1] == '\n');
+ if (has_trailing_newline)
len--;
fputs(set, file);
fwrite(line, len, 1, file);
fputs(reset, file);
- fputc('\n', file);
+ if (has_trailing_newline)
+ fputc('\n', file);
}
static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)