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

Re: [QUESTION] '--color-words' for 'git add -p'?

From
Jeff King <peff@peff.net>
Date
Apr 29, 2011, 22:38 UTC
Message-ID
<20110429223814.GB3434@sigill.intra.peff.net>
In-Reply-To
<20110429164210.GA14937@kudu.in-berlin.de>
On Fri, Apr 29, 2011 at 06:42:10PM +0200, Valentin Haenel wrote:
> is it possible to use some kind of magic to get 'git add -p' to display
> diff with '--color-words' option? I tried GIT_DIFF_OPTS but w/o success.

No, it's not currently. The output of --color-words cannot be applied as a patch, so we would have to do something like diff an extra time, match up the hunks, show the user one hunk, and then apply the other.

In fact, that is what we already do to get color at all. It works very well there, since we know the hunks will match exactly. I'm not 100% sure, though, that color-words will produce exactly the same set of hunks that a regular line-oriented diff will. Which would be a problem.

-Peff
Previous: Valentin Haenel
Message 2 of 2 in “[QUESTION] '--color-words' for 'git add -p'?”
  1. Valentin HaenelApr 29, 2011
  2. Jeff KingApr 29, 2011

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.