Re: [PATCH 5/5] format-patch: avoid freopen()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jun 22, 2016, 16:14 UTC
- Message-ID
- <alpine.DEB.2.20.1606221811300.10382@virtualbox>
- In-Reply-To
- <xmqqeg7pns0a.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On Wed, 22 Jun 2016, Junio C Hamano wrote:
Show 15 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> 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=<some new setting> 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