summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-06-22 15:01:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-24 22:15:55 (GMT)
commit11f4eb19843c28b1c50d3c1bef1183e6313b87b8 (patch)
tree9e9af0779776d540fb0508d1577fd338b5288bdf /builtin
parent0a7b357737e3352ce1b0385313c1efc1b2564dbb (diff)
downloadgit-11f4eb19843c28b1c50d3c1bef1183e6313b87b8.zip
git-11f4eb19843c28b1c50d3c1bef1183e6313b87b8.tar.gz
git-11f4eb19843c28b1c50d3c1bef1183e6313b87b8.tar.bz2
format-patch: explicitly switch off color when writing to files
The --color=auto handling is done by seeing if file descriptor 1 (the standard output) is connected to a terminal. format-patch used freopen() to reuse the standard output stream even when sending its output to an on-disk file, and this check is appropriate. In the next step, however, we will stop reusing "FILE *stdout", and instead start using arbitrary file descriptor obtained by doing an fopen(3) ourselves. The check --color=auto does will become useless, as we no longer are writing to the standard output stream. But then, we do not need to guess to begin with. As argued in the commit message of 7787570c (format-patch: ignore ui.color, 2011-09-13), we do not allow the ui.color setting to affect format-patch's output. The only time, therefore, that we allow color sequences to be written to the output files is when the user specified the --color=always command-line option explicitly. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/log.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/log.c b/builtin/log.c
index 27bc88d..1985ed3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1578,6 +1578,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
setup_pager();
if (output_directory) {
+ if (rev.diffopt.use_color != GIT_COLOR_ALWAYS)
+ rev.diffopt.use_color = GIT_COLOR_NEVER;
if (use_stdout)
die(_("standard output, or directory, which one?"));
if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)