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

Re: [PATCH] Add color to git-add--interactive diffs (Total different idea to solve the problem)

From
PBPeter Baumann <waste.manager@gmx.de>
Date
Oct 22, 2007, 20:47 UTC
Message-ID
<20071022204719.GA23348@xp.machine.xx>
In-Reply-To
<1192351494.7226.18.camel@athena>
On Sun, Oct 14, 2007 at 03:44:54AM -0500, Tom Tobin wrote:
Show 18 quoted lines
> (This is repost; my damned mail client wrapped a line in the patch last
> time, and now I've got that under control.  My apologies!)  :(
> 
> Seeing the recent discussion and code regarding adding color to
> git-add--interactive, I thought I'd throw in my recent attempt at
> colorizing the diffs.  (This doesn't handle anything else, such as the
> prompts.)
> 
> After banging my head against parsing colorized output of git-add-files,
> I gave up and implemented internal colorization keying off of the
> color.diff configuration.
> 
> Hopefully this can be of some use towards fully colorizing
> git-add--interactive; I'll admit up front that Perl isn't my primary
> language, so I apologize in advance for whatever stupidities I've
> introduced.  ;) 
> 
> Signed-off-by: Tom Tobin <korpios@korpios.com>
[...skiping patch ...]
Tossing around ideas, so feel free to ignore me.

Wouldn't it make more sense to implement the diff coloring inside git apply so that you could use something like

        diff file1 file2|git apply --color

to make the generated diff with colors [1]? It already implements the same semantic for generating a diffstat, using

        diff file1 file2|git apply --stat

so we would get a generic diff colorizing tool and you could use inside git add -i the diff without color and just print it out with the git apply --color filter. So if someone implements another tool which needs color handling he could use this output filter.

-Peter
[1]: there is a programm colordiff which does exactly this, but AFAIK git
     colorization has more features.
Previous: Wincent ColaiutaNext: Johannes Schindelin
Message 6 of 9 in “Add color to git-add--interactive diffs (Take 2: now without spurious line break!)”
  1. Add color to git-add--interactive diffs (Take 2: now without spurious line break!)Tom Tobin, Oct 14, 2007
  2. Wincent ColaiutaOct 14, 2007
  3. Johannes SchindelinOct 14, 2007
  4. Andreas EricssonOct 14, 2007
  5. Wincent ColaiutaOct 14, 2007
  6. Peter BaumannOct 22, 2007
  7. Johannes SchindelinOct 22, 2007
  8. Peter BaumannOct 23, 2007
  9. Johannes SchindelinOct 23, 2007

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.