Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting diff-so-fancy in diff view #542

Open
Liooo opened this issue Nov 20, 2016 · 10 comments

Comments

@Liooo
Copy link

commented Nov 20, 2016

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

@diego898

This comment has been minimized.

Copy link

commented Feb 5, 2018

just want to bump this!

@EnCey

This comment has been minimized.

Copy link

commented Feb 21, 2018

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

@yilazius

This comment has been minimized.

Copy link

commented Apr 24, 2018

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

@alok

This comment has been minimized.

Copy link

commented May 22, 2018

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

@mathomp4

This comment has been minimized.

Copy link

commented Aug 31, 2018

I just learned about diff-so-fancy myself. Bump and 👍

@graves501

This comment has been minimized.

Copy link

commented Sep 8, 2018

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

@patrickelectric

This comment has been minimized.

Copy link

commented Nov 1, 2018

This would be awesome !

@gwellner

This comment has been minimized.

Copy link

commented Feb 28, 2019

Oh i need this Feature !

@andebjor

This comment has been minimized.

Copy link
Contributor

commented Mar 2, 2019

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?

@ffes

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.