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

Re: RFC: git diff colorization idea

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 23, 2009, 00:32 UTC
Message-ID
<7vhc3q6evi.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<53497057-1ADE-4300-9F35-B218959606FE@wincent.com>
Wincent Colaiuta <win@wincent.com> writes:
Show 8 quoted lines
> I'm also thinking that perhaps a per-character approach might be
> useful here instead of a per-word one (it would make that last hunk
> look better in the mock-up screenshot that I posted); if I go the per-
> character route then that suggests that "--color-chars" might be the
> right option name, and the color slots would then be
> color.diff.new.char and color.diff.old.char.
>
> Any feedback or suggestions before I get in too deep?
I personally find your "prposal" picture too loud to my eye.
I would have expected you to propose something like this:
  | _git_remote ()
  | {
  |-    local subcommands="add rm show prune <red>update</red>"
  |+    local subcommands="add <green>rename</green> rm show prune"
  |     local subcommand=$(__git_find_subcommand "$subcommands")"
  |     if ...

if the patch were to remove update and add rename, that is. If there is no deletion but only insertion, you would only see green.

And that way you do not need new color slots. You can use new color and old color as before, and the coloring will be done to highlight only the parts that really matter.

If you were to go this route, I suspect that showing the unchanged part on the preimage line in light gray might make sense, like:

  | _git_remote ()
  | {
  |-    <gray>local subcommands="add rm show prune<gray> <red>update</red>"
  |+    local subcommands="add <green>rename</green> rm show prune"
  |     local subcommand=$(__git_find_subcommand "$subcommands")"
  |     if ...
because there will be the same chars/words on the postimage line anyway.
Just 2c from somebody who does not like colors very much.
Previous: Wincent ColaiutaNext: Wincent Colaiuta
Message 2 of 6 in “RFC: git diff colorization idea”
  1. Wincent ColaiutaJan 23, 2009
  2. Junio C HamanoJan 23, 2009
  3. Wincent ColaiutaJan 23, 2009
  4. Junio C HamanoJan 23, 2009
  5. Nanako ShiraishiJan 23, 2009
  6. Jakub NarebskiJan 23, 2009

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.