tig icon indicating copy to clipboard operation
tig copied to clipboard

color-words support

Open Oblomov opened this issue 13 years ago • 21 comments

Currently, tig has no support for color-words in diffs. In fact, starting tig wit the --color-words option fails with "No revisions match the given argument" (which is quite misleading as error message).

This should probably be consiered a long-term TODO, as it requires some heavy-duty re-engineering of the diff view, especially with respect to highlighting. Also, color-word support would require massaging the input parameters, since the word-diff option should always be turned into 'porcelain'.

Oblomov avatar Apr 30 '12 20:04 Oblomov

While looking at issue #26, I have been looking into adding support for --word-diff=porcelain as a way to provide side-by-side diff support. AFAIK, the parsing of the word diff can be shared, but will require different rendering methods. So yeah, I agree that it will require some work to get proper highlighting. For example, the line->data member will probably have to become a struct of line boxes on which we can attach color and length information. Since the diff view shares a lot of code with the pager and stage view it probably makes sense to also use this line box struct for all the current 'pager-based' views.

jonas avatar Apr 30 '12 22:04 jonas

+1 --color-words

franciscolourenco avatar May 07 '12 02:05 franciscolourenco

Yes, great goal!

danielhopkins avatar Jun 12 '12 20:06 danielhopkins

Would also be great if this supported --word-regex as well. It's sometimes nice to do a character diff. This would be a handy toggle setting too.

Line Diff -> Word Diff -> Character Diff

danielhopkins avatar Jun 12 '12 20:06 danielhopkins

Okay, I got ahead of myself. After learning a bit more. Porcelain support looks like it would be great. Github seems to have this dialed in, so hopefully using something like they do would be helpful :)

danielhopkins avatar Jun 12 '12 21:06 danielhopkins

Support for word-diff would be just awesome!

zyv avatar Aug 14 '12 09:08 zyv

+1 for this feature. In the meantime I helped myself with an external command to have easy access to the output from within tig.

status= W !git diff --color-words --cached %(file)

metaodi avatar Jun 06 '13 12:06 metaodi

+1 --color-words

xapple avatar Apr 24 '14 09:04 xapple

+1, this would make diffs much easier!

jeremyckahn avatar May 13 '14 18:05 jeremyckahn

+1

langner avatar May 30 '14 12:05 langner

+1

xapple avatar Nov 12 '14 16:11 xapple

+1

nkmry avatar Dec 06 '14 08:12 nkmry

Any news on this? It's been open for more than four years now ;-)

wilzbach avatar Jun 30 '16 21:06 wilzbach

+1

timotheecour avatar Feb 04 '17 20:02 timotheecour

attempted exporting TIG_DIFF_OPTS=--color-words but no luck, seems inline color escapes are not supported?

+1

hhartz avatar Feb 21 '18 13:02 hhartz

+1 very useful. Why one should leave tig to get colored diff (with options)?

petRUShka avatar Jul 18 '18 18:07 petRUShka

+1 for this feature

I've just discovered tig but without --color-words it's much less valuable for me than it would be with it

SassNinja avatar Aug 21 '18 11:08 SassNinja

Any improvement in this feature?

avatar-lavventura avatar Jun 12 '21 17:06 avatar-lavventura

If I'm not mistaken, it is implemented in tig 2.5.5. I added this to my tigrc:

bind diff D :toggle word-diff

and it works like a charm when pressing shift-d (the separators are a bit verbose, but this is git's plain mode, not tig's fault).

hydrargyrum avatar Jun 22 '22 12:06 hydrargyrum

the separators are a bit verbose, but this is git's plain mode, not tig's fault

I don't think you can argue that it's git's fault when git has a color mode for the word diff. I, and I would assume most people, would like this way to display it, not the plain way.

trygveaa avatar Jun 22 '22 15:06 trygveaa

Maybe the selected word-diff mode should be configurable in tig then. Plain mode is still useful for example if the terminal has no color support.

hydrargyrum avatar Jun 22 '22 20:06 hydrargyrum