From: Johannes Schindelin Date: Wed, 22 Jun 2016 16:14:43 GMT Subject: Re: [PATCH 5/5] format-patch: avoid freopen() Message-ID: In-Reply-To: Hi Junio, On Wed, 22 Jun 2016, Junio C Hamano wrote: > Johannes Schindelin writes: > > > But there's a rub... If you specify --color *explicitly*, use_color is set > > to GIT_COLOR_ALWAYS and the file indeed contains ANSI sequences (i.e. my > > analysis above left out the command-line part). > > Heh, the command-line is the _ONLY_ thing I raised, as we knew > ui.color is not an issue in this codepath, in $gmane/297757. > > Going back to that and reading again, I suggested to check with > GIT_COLOR_AUTO (i.e. if it is left to "auto", disable it) because I > think the former is a much more future-proof way (imagine that we > may add --color= in the future) than checking with > GIT_COLOR_ALWAYS (i.e. if it is not explicitly set to "always", > disable it). Well, if I change `rev.diffopt.use_color != GIT_COLOR_ALWAYS` to `rev.diffopt.use_color == GIT_COLOR_AUTO`, then the files will contain ugly ANSI color sequences if I run `git format-patch -o . -3`. The reason is, as I tried to explain, that the use_color field is *not* initialized to GIT_COLOR_AUTO (which is equivalent to 2), but to -1. So the difference between your version and mine is that mine works ;-) Ciao, Dscho