Previously, when having color diffs enabled and redirecting 'git diff' into a file, one ends up with a messed up file containing termcap color stuff. This change disables color when diff output is redirected into a file. Signed-off-by: Sascha Peilicke <saschpe@xxxxxx> --- diff.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/diff.c b/diff.c index 5422c43..cd1ecb0 100644 --- a/diff.c +++ b/diff.c @@ -2854,6 +2854,11 @@ void diff_setup(struct diff_options *options) DIFF_OPT_SET(options, COLOR_DIFF); options->detect_rename = diff_detect_rename_default; + struct stat buf; + if (fstat(fileno(options->file), &buf) != -1 && S_ISREG(buf.st_mode)) { + DIFF_OPT_CLR(options, COLOR_DIFF); + } + if (diff_no_prefix) { options->a_prefix = options->b_prefix = ""; } else if (!diff_mnemonic_prefix) { -- 1.7.3.4 -- Mit freundlichen Grüßen, Sascha Peilicke http://saschpe.wordpress.com
Attachment:
signature.asc
Description: This is a digitally signed message part.