git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] add--interactive.perl: specify --no-color explicitly

From
Jeff King <peff@peff.net>
Date
Sep 7, 2020, 08:25 UTC
Message-ID
<20200907082510.GA1264377@coredump.intra.peff.net>
In-Reply-To
<20200907081739.GB1263923@coredump.intra.peff.net>
On Mon, Sep 07, 2020 at 04:17:39AM -0400, Jeff King wrote:
Show 12 quoted lines
> Our color tests of "git add -p" do something a bit different from how a
> normal user would behave: we pretend there's a pager in use, so that Git
> thinks it's OK to write color to a non-tty stdout.  This comes from
> 8539b46534 (t3701: avoid depending on the TTY prerequisite, 2019-12-06),
> which allows us to avoid a lot of complicated mock-tty code.
> 
> However, those environment variables also make their way down to
> sub-processes of add--interactive, including the "diff-files" we run to
> generate the patches. As a result, it thinks it should output color,
> too. So in t3701.50, for example, the machine-readable version of the
> diff we get unexpectedly has color in it. We fail to parse it as a diff
> and think there are zero hunks.
By the way, this is an instance of a more generic bug, which is that:
  git -p my-script

will cause any sub-programs of git-my-script to think their stdout is going to a pager, even if my-script redirects them to a file or another pipe.

I had a solution long ago in:
  https://lore.kernel.org/git/20150810052353.GB15441@sigill.intra.peff.net/

but it raises a bunch of interesting portability questions. Since this comes up so rarely, I never really pursued it further.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 4 of 7 in “some minor add--interactive fixes”
  1. 0/2 some minor add--interactive fixesJeff King, Sep 7, 2020
  2. 1/2 add-patch: fix inverted return code of repo_read_index()Jeff King, Sep 7, 2020
  3. 2/2 add--interactive.perl: specify --no-color explicitlyJeff King, Sep 7, 2020
  4. Jeff KingSep 7, 2020
  5. Junio C HamanoSep 8, 2020
  6. Johannes SchindelinSep 8, 2020
  7. Jeff KingSep 9, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.