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

Re: [PATCH 1/2] diff: add --word-diff option that generalizes --color-words

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 5, 2010, 02:06 UTC
Message-ID
<7v39zay7or.fsf@alter.siamese.dyndns.org>
In-Reply-To
<a1e9ef6a4eb1d7930f69e9ac4b63dc3152ebc98c.1270388195.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 12 quoted lines
> This teaches the --color-words engine a more general interface that
> supports two new modes:
>
> * --word-diff=plain, inspired by the 'wdiff' utility (most similar to
>   'wdiff -n <old> <new>'): uses delimiters [-removed-] and {+added+}
>
> * --word-diff=porcelain, which generates an ad-hoc machine readable
>   format:
>   - each diff unit is prefixed by [-+ ] and terminated by newline as
>     in unified diff
>   - newlines in the input are output as a line consisting only of a
>     tilde '~'
Thanks.  This was a fun feature to look at.

I think it is a bug that "git show --word-diff" gives the colored format output when I have "color.ui" configuration.

Even though I may have "color.ui = auto" in the configuration, I am telling the command to do a --word-diff, not --color-words, from the command line, and that should override color.ui settings.

So I think a request for --word-diff that is not --word-diff=color should never use the --color-words _unless_ there is --color on the command line:

	git show --word-diff
	git show --word-diff=plain
	git show --word-diff=porcelain

All of the above may paint hunk headers and metainfo the usual way when I have "color.ui" set, but I do not want them to be painting the diff part like --color-words does. I am fine if "porcelain" did not to paint the metainfo, but I see this feature as three different output types of how word diff is presented, so in that sense, it probably is better to force scripts to explicitly ask for no-color, i.e.

	git show --no-color --word-diff=porcelain
if they want to read and interpret metainfo.

When the command line asks for color explicitly, then we should see the good old --color-words:

	git show --color-words
	git show --word-diff=color

I am not sure what the following two should do. One could argue that these default to --color-words; or --color should apply only to the coloring of metainfo but not the diff part:

        git show --color --word-diff
        git show --word-diff --color

I am slightly in favor of doing the same as --color-words, but people may have different opinions.

The following of course should show the plain word diff but the metainfo and friends colored:

        git show --word-diff=plain --color
        git show --color --word-diff=plain

It might be just the matter of defaulting --word-diff without "=<type>" not to "auto" but to "plain". I haven't looked at the code closely yet.

Previous: Thomas RastNext: Thomas Rast
Message 3 of 15 in “gitk --color-words”
  1. 0/2 gitk --color-wordsThomas Rast, Apr 4, 2010
  2. 1/2 diff: add --word-diff option that generalizes --color-wordsThomas Rast, Apr 4, 2010
  3. Junio C HamanoApr 5, 2010
  4. Thomas RastApr 5, 2010
  5. Junio C HamanoApr 5, 2010
  6. Miles BaderApr 5, 2010
  7. 0/2 gitk --color-wordsThomas Rast, Apr 12, 2010
  8. 1/3 diff: add --word-diff option that generalizes --color-wordsThomas Rast, Apr 12, 2010
  9. Junio C HamanoApr 12, 2010
  10. Thomas RastApr 13, 2010
  11. 2/3 gitk: do not parse " >" context as submodule changeThomas Rast, Apr 12, 2010
  12. gitk: do not parse " >" context as submodule changeThomas Rast, Apr 12, 2010
  13. 3/3 gitk: add the equivalent of diff --color-wordsThomas Rast, Apr 12, 2010
  14. Thomas RastApr 6, 2010
  15. 2/2 gitk: add the equivalent of diff --color-wordsThomas Rast, Apr 4, 2010

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.