[PATCH] diff: let --output=<file> default to --no-color

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is highly unlikely that any user would want to see ANSI color
sequences in a file. So let's stop doing that by default.

This is a backwards-incompatible change.

The reason this was not caught earlier is most likely that either
--output=<file> is not used, or only when stdout is redirected
anyway.

Technically, we do not default to --no-color here. Instead, we try to
override the GIT_COLOR_AUTO default because it would let want_color()
test whether stdout (instead of the specified file) is connected to a
terminal. Practically, we require the user to require color "always"
to force writing ANSI color sequences to the output file.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---
Published-As: https://github.com/dscho/git/releases/tag/diff-o-v1

	Just something I noted while working on a bit more consistency
	with the diffopt.file patches.

	This is a backwards-incompatible change, though. So I extracted it
	from the patch series.

 diff.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/diff.c b/diff.c
index fa78fc1..b66b9be 100644
--- a/diff.c
+++ b/diff.c
@@ -3977,6 +3977,8 @@ int diff_opt_parse(struct diff_options *options,
 		if (!options->file)
 			die_errno("Could not open '%s'", path);
 		options->close_file = 1;
+		if (options->use_color != GIT_COLOR_ALWAYS)
+			options->use_color = GIT_COLOR_NEVER;
 		return argcount;
 	} else
 		return 0;
-- 
2.9.0.118.g0e1a633

base-commit: ab7797dbe95fff38d9265869ea367020046db118
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]