Web lists-archives.com

Re: Bug#925288: ITP: diff-so-fancy -- Good-lookin' diffs. Actually… nah… The best-lookin' diffs.

Hello guys,

To my surprise multiple people expressed their interest in
productivity-friendly diff highlighting.  So let me write a brief
summary on this topic, after some investigation.

Mattia told me privately about the alternative of diff-so-fancy:

  diff a b | colordiff | diff-highlight | less -R


* colordiff does the same thing as 'diff --color'. For older
  Debian systems, diffutils doesn't support the '--color'.
  Sid users don't need this package.

* diff-highlight is the script shipped in git package, quite easy to use
  1. cd /usr/share/doc/git/contrib/diff-highlight/
  2. sudo make
  3. use the resulting executable as a filter:
     git config --global core.pager "XXX/diff-highlight | less --tabs=4 -RFX"

Now let's look at diff-so-fancy. In fact the diff-highlight (denoted
as 'DH' below, not your favorite debhelper) shipped in the git package
is able to produce similar result compared to diff-so-fancy (denoted as 'DSF'
below), except for

* DH doesn't mangle standard notations of the patch format; while
  DSF mangles them. See example below.

I started to doubt why git upstream doesn't enable such a
useful productivity feature by default? Who will be aware of
the existence of diff-highlight if he/she doesn't look into
the source tree?

======================= DH example

diff --git a/dotfile/gitconfig b/dotfile/gitconfig
index 90a5ee6f..7c7633e7 100644
--- a/dotfile/gitconfig
+++ b/dotfile/gitconfig
@@ -1,5 +1,5 @@
-   pager = less
+   pager = diff-so-fancy | less --tabs=4 -RFX
    editor = vim
    quotepath = false

======================= DSF example

modified: dotfile/gitconfig
@ dotfile/gitconfig:2 @
	pager = less
	pager = diff-so-fancy | less --tabs=4 -RFX
	editor = vim
	quotepath = false

On Fri, Mar 22, 2019 at 05:16:07PM +0200, Peter Pentchev wrote:
> On Fri, Mar 22, 2019 at 05:06:10PM +0200, Peter Pentchev wrote:
> > On Fri, Mar 22, 2019 at 03:34:37PM +0100, Adam Borowski wrote:
> > [snip]
> > > Highlighting changes inside the line is a massive improvement.
> > > 
> > > There's an implementation of this in "git" itself already, named
> > > diff-highlight.  Alas, either I'm a complete idiot, or its documentation is
> > > not quite adequate -- some time ago I wasted over an hour trying to get that
> > > implementation to work, without success.
> > 
> [snip shell snippets]
> > 
> > You're welcome... and thanks for bringing diff-highlight to my attention so
> > that I could whip these up :)  Now only to figure out how to get the colors
> > more similar to the ones that Vim uses (I use a ~/bin/vdiff script that
> > pipes stuff through `vim -c 'set ft=diff' -` and I really, really like its
> > colors)...
> Uh, well, please note that this is in no way meant to say that there is
> no need for this ITP; on the contrary, if there is an external, configurable
> tool that can be used for other stuff, too, please go ahead and package it!
> G'luck,
> Peter
> -- 
> Peter Pentchev  roam@{ringlet.net,debian.org,FreeBSD.org} pp@xxxxxxxxxxxx
> PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13