summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-06-16 17:39:50 -0700
committerJunio C Hamano <gitster@pobox.com>2008-06-16 17:39:50 -0700
commit5f54de5bd07481f6d88e8dbd5551f3356ecbf513 (patch)
treec7e18035bebac574a1c44a38ef4fa9daf7fe0ddc /diff.c
parent9dc784a970ba5cc3871f7244c6bf6a823754f0a0 (diff)
parent4afbcab9898ce63ad641dd0de6e9b69deda44330 (diff)
downloadgit-5f54de5bd07481f6d88e8dbd5551f3356ecbf513.tar.gz
Merge branch 'maint'
* maint: diff.c: fix emit_line() again not to add extra line
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index f23657bd34..5262490086 100644
--- a/diff.c
+++ b/diff.c
@@ -514,13 +514,15 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
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)