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

Re: gitk: how to apply '--color-words' to the diff command

From
DSDirk Süsserott <poststelle@suesserott.de>
Date
Mar 18, 2008, 20:55 UTC
Message-ID
<47E02C32.10009@suesserott.de>
In-Reply-To
<47DEC41D.9050409@dirk.my1.cc>
Show 17 quoted lines
>
> a few days ago I found a patch for gitk that adds a checkbox 'Ignore 
> space change' to the gitk GUI and -- when clicked -- adds the '-w' 
> switch to the diff command. I found that a very convenient way to see 
> 'what has really changed'. The patch was contributed by Steffen 
> Prohaska and has sha1 b9b86007e27d9a06d58feab618a5be1d491ed13e in the
> git://git.kernel.org/pub/scm/git/git.git repository.
>
> Inspired by this, I thought a '--color-words' switch would be even more
> convenient. I took the patch as a template and kinda replaced all
> occurences of '-w' with '--color-words' (do not take this literally).
>
> Unfortunately gitk then shows the diffs not colorized but with those 
> ugly escape sequences instead. I'm not a Python person and just able 
> to 'copy and waste', but probably some of you had the same idea and 
> got it right.
>

I'm not only not a Python person but also not a Tcl person. Did't even figure out the difference. :-(

However, what I figured out is that it's not as simple as I thought: The colorization in question is hard coded in the last 'else' branch of 'getblobdiffline'. When a line starts with a '+' or '-', then it's shown in green or red. To support the --color-words switch it would be neccessary to actually parse diff's output wrt. to the colors. Not that easy, I guess.

Sorry for the noise.
Dirk
Previous: Dirk SüsserottNext: Dirk Süsserott
Message 2 of 3 in “gitk: how to apply '--color-words' to the diff command”
  1. Dirk SüsserottMar 17, 2008
  2. Dirk SüsserottMar 18, 2008
  3. Dirk SüsserottMar 18, 2008

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.