diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-09-08 08:45:40 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-09-08 08:45:40 +0200 |
commit | fdfb4cfadcfdfe4ebafd0545b5ebb661433ea66c (patch) | |
tree | 6aa57e5f061a32801c706496357f020556cff200 /diff.c | |
parent | Merge branch 'jc/maint-checkout-fix' (diff) | |
parent | diff: Help "less" hide ^M from the output (diff) | |
download | git-fdfb4cfadcfdfe4ebafd0545b5ebb661433ea66c.tar.xz git-fdfb4cfadcfdfe4ebafd0545b5ebb661433ea66c.zip |
Merge branch 'jc/hide-cr-in-diff-from-less'
* jc/hide-cr-in-diff-from-less:
diff: Help "less" hide ^M from the output
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -513,13 +513,20 @@ 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) { - int has_trailing_newline = (len > 0 && line[len-1] == '\n'); + int has_trailing_newline, has_trailing_carriage_return; + + has_trailing_newline = (len > 0 && line[len-1] == '\n'); if (has_trailing_newline) len--; + has_trailing_carriage_return = (len > 0 && line[len-1] == '\r'); + if (has_trailing_carriage_return) + len--; fputs(set, file); fwrite(line, len, 1, file); fputs(reset, file); + if (has_trailing_carriage_return) + fputc('\r', file); if (has_trailing_newline) fputc('\n', file); } |