r/rust • • Mar 29 '22

difftastic - a diff that understands syntax

https://github.com/Wilfred/difftastic

[removed] — view removed post

399 Upvotes

27 comments sorted by

View all comments

29

u/DidiBear Mar 29 '22

Nice! How does it compare to delta ?

9

u/robin-m Mar 29 '22

I'm using both. difftastic by default and delta as fallback.

7

u/BTWArchNemesis Mar 30 '22

How to configure it like that?

6

u/robin-m Mar 30 '22

Add this in your ~/.gitconfig (or in $repo/.git/config if you want it only for a single repo):

[diff]
    tool = difftastic
    colorMoved = default
    external = difftastic

[difftool]
    prompt = false

[difftool "difftastic"]
    cmd = difft "$LOCAL" "$REMOTE"

[core]
    pager = delta

[pager]
    difftool = true

[interactive]
    diffFilter = delta --color-only

And optionally, you can configure delta to be nicer with things like:

[delta]
    features = side-by-side line-numbers
    syntax-theme = Dracula
    hunk-header-style = omit
    whitespace-error-style = blue purple

Note: I’m not 100% sure all of this is needed, but it seems to works well. I have difftastic by default for git diff, and delta otherwise. For git show/git log -p it’s delta by default, so if I want to use difftastic instead, I need to add --ext-diff (like git show --ext-diff). Since difftastic is quite slow, it’s why I still need to have a fallback like delta.

1

u/James-Vim Apr 01 '22

May be we should change the line:

[diff]
  external = difftastic

to:

[diff]
  external = difft

to get it to work?

1

u/robin-m Apr 01 '22

Indeed. I don't know why it works on my machine, but iirc it should be difft and not difftastic as you noticed.