Skip to content

Commit 11f4eb1

Browse files
dschogitster
authored andcommitted
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>
1 parent 0a7b357 commit 11f4eb1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

builtin/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
15781578
setup_pager();
15791579

15801580
if (output_directory) {
1581+
if (rev.diffopt.use_color != GIT_COLOR_ALWAYS)
1582+
rev.diffopt.use_color = GIT_COLOR_NEVER;
15811583
if (use_stdout)
15821584
die(_("standard output, or directory, which one?"));
15831585
if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)

0 commit comments

Comments
 (0)