Re: Potential bug in --color-words output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Simeon,

On Fri, 28 Oct 2022, Simeon Krastnikov wrote:

> Given an initial file with the contents "not to be", which I then change to
> "to be", the output of 'git diff --color-words', is
>
>   notto be
>
> with the first three letters colored red.

This seems to be a limitation of the original `--color-words` design.

FWIW I find myself using these three aliases all the time now, i.e. using
a different word-coloring mode that works much better for me:

	[alias]
		cwdiff = diff --color-words=\"[A-Za-z0-9_]+|.\"
	        cwlog = log --color-words=\"[A-Za-z0-9_]+|.\"
		cwshow = show --color-words=\"[A-Za-z0-9_]+|.\"

Explanation: the regex `[A-Za-z0-9_]+|.` treats runs of alphanumerical
characters (including the underscore) as words, and also treats any
individual characters that do not fall into that category as "words".

The only downside of this is that the coloring does not help identifying
white-space differences because only the foreground color is changed
(which does not result in any visible difference for white-space
characters).

Maybe these aliases help you, too?

Ciao,
Johannes

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux