git v1.6.0 still didn't work, neither v1.5.6.4. (however,v1.5.5 works on
mingwin)
I checked the source code of v1.6.0, and I found emit_line didn't check
whether there is a cr at eol.
I have fixed it.
From dae20e25960c73bd7ccc0939fe096bb68a009fb5 Mon Sep 17 00:00:00 2001
From: erwangg <redacted>
Date: Wed, 27 Aug 2008 12:22:43 +0800
Subject: [PATCH] ingore cr at eol when diff with color=auto
---
diff.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/diff.c b/diff.c
index 18fa7a7..846a9af 100644
--- a/diff.c
+++ b/diff.c
@@ -517,9 +517,16 @@ static void emit_line(FILE *file, const char *set,
const char *reset, const char
if (has_trailing_newline)
len--;
+ int has_trailing_return = (len > 0 && line[len-1] == '\r');
+ if (has_trailing_return)
+ len--;
+
fputs(set, file);
fwrite(line, len, 1, file);
fputs(reset, file);
+
+ if (has_trailing_return)
+ fputc('\r', file);
if (has_trailing_newline)
fputc('\n', file);
}@@ -535,7 +542,7 @@ static void emit_add_line(const char *reset, struct
emit_callback *ecbdata, cons
/* Emit just the prefix, then the rest. */
emit_line(ecbdata->file, set, reset, line, ecbdata->nparents);
ws_check_emit(line + ecbdata->nparents,
- len - ecbdata->nparents, ecbdata->ws_rule,
+ len - ecbdata->nparents, ecbdata->ws_rule|WS_CR_AT_EOL,
ecbdata->file, set, reset, ws);
}
}
--
1.6.0.GIT
--
View this message in context: http://n2.nabble.com/question%3A-how-to-ignore-extral-CR-when-diff-dos-format-files-with-%27color%3Dauto%27-tp783231p788498.html
Sent from the git mailing list archive at Nabble.com.