diff.c: fix emit_line() again not to add extra line
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
06ff64ae3d
commit
4afbcab989
4
diff.c
4
diff.c
@ -514,12 +514,14 @@ 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);
|
||||
if (has_trailing_newline)
|
||||
fputc('\n', file);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user