Tig: Support custom diff formatters (diff-so-fancy, delta etc)

Created on 20 Nov 2016  路  19Comments  路  Source: jonas/tig

It'd be nice if tig supported diff-so-fancy, as previously mentioned in #313.

Most helpful comment

+1 for delta support

All 19 comments

just want to bump this!

Is there a workaround for this?
diff-highlight is supported apparently, but I didn't quite get why diff-so-fancy isn't or what needs to be done to make it work

Any updates on this issue? Did somebody get it working?

I'm curious about this too. I really like the clean view d-s-f gives.

I just learned about diff-so-fancy myself. Bump and :+1:

diff-so-fancy support would be awesome! bump :)

This would be awesome !

Oh i need this Feature !

I have looked into adding this support today. Unfortunately, I have not succeeded, and I currently think that I will take quite some effort to implement this support properly.

The diff-so-fancy tool works as a filter of the git diff output (as does diff-highlight which tig has support for). The filter does basically these things:

  1. Tweaks the header of each touched file,
  2. Tweaks the hunk indicators to be more human readable,
  3. Strips the leading + and - signs,
  4. Marks empty lines, and
  5. Adds a fair amount of coloring to different elements of the diff.

It is the added coloring that makes this a hard task. As @jonas mentions in #313,tig was only taught very basic parsing of ANSI control codes when support for diff-highlight was added. Actually, tig has a quite advanced support for coloring of the diffs built-in, and uses the --no-color flag when retrieving the diff, and proceeds to add colors afterwards.

The same could perhaps be done with diff-so-fancy, except that I have not found any way to suppress adding of the ANSI control characters to its output for many elements of the diff. (That could be a pull request to that tool, however, if desired.)

At my current level of understanding of the situation I see these ways forward for this feature:

  1. Teach tig to parse ANSI control characters, or
  2. Implement native support for the other items in the list of features that diff-so-fancy supports (items 1--4 in the list above basically).

I have tried to make tig parse the ANSI control characters, but was not completely successful. I have put this work in a branch, but it is in an extremely rough state, and not complete. (The parsing is _probably_ mostly done, but applying the result in the form of e.g. colored output is not yet performed.) The code can be tested by setting the diff-highlight option to the path of the diff-so-fancy script in the tigrc config file.

Instead of pursuing down this road, I would suggest attempting the second instead: Implementing native support inside tig for the desired features offered by diff-so-fancy, except for its coloring. Feature request #855 targets one of these: Removal of diff + and - signs.

Or does someone else have a different opinion/suggestion?

Note that PR #901 is opened. It should solve items 3 and 4 of the list @andebjor mentions above.

Items 1 and 2 should not be too difficult to implement in tig as well. These lines are already colored by tig.

And then the current/default implementation of diff-highlight (as described in the docs) can handle highlighting the differences within a line.

With that all done (note implementing item 1 and 2 is not even started and #901 is not merged yet) the mentioned features of diff-so-fancy are available in tig.
Or are we missing anything important?

@Liooo can you rename the issue to something like Support custom diff formatters (diff-so-fancy, delta) ? I'd looooove to get diffs formatted & highlighted in tig by https://github.com/dandavison/delta .

@ronjouch
that's a good one, renamed the title 馃憤

would be waiting for diff-so-fancy support

+1 for formatters support

+1

+1 for delta support

+1 for delta support

+1 for delta support

+1 for delta support

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rominf picture rominf  路  6Comments

proski picture proski  路  7Comments

dmalikov picture dmalikov  路  4Comments

brechtm picture brechtm  路  3Comments

dustymabe picture dustymabe  路  3Comments