git: Add difftastic syntax diffing

If difft command is installed we can git diff on syntactic changes only
using `gdy` (or `gdys` for staged) which will spit out a (treesitter)
syntax-aware side by side comparison.
Really nice for refactoring diffs.
This commit is contained in:
Marty Oehme 2023-12-12 12:15:07 +01:00
parent d459d79de0
commit 13c87f365d
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 13 additions and 1 deletions

View file

@ -6,6 +6,8 @@
defaultBranch = main
[core]
pager = delta
[pager]
difftool = true
[interactive]
diffFilter = delta --color-only
[merge]
@ -23,6 +25,7 @@
pushall = "!git remote | xargs -I R git push R" # push to all connected remotes
fetchall = "!git remote | xargs -I R git fetch R" # fetch from all connected remotes
diffword = "!git diff --word-diff=color --word-diff-regex='[0-9A-Za-z_]+'" # word-wise diff, good for prose
diffsyn = "!git difftool --tool difftastic" # add syntax-driven diff using treesitter
[commit]
gpgsign = true # sign commits as me
verbose = true # Always show diff when preparing commit message
@ -32,6 +35,10 @@
rebase = true # always rebase on pulling, obviates merge commits
[diff]
colorMoved = zebra # also color stuff that has simply been moved, in a classy zebra-color
[difftool]
prompt = false
[difftool "difftastic"]
cmd = difft "$LOCAL" "$REMOTE"
[color.diff]
meta = "9"
frag = "magenta bold"

View file

@ -38,8 +38,13 @@ alias gdds='git diffword --staged'
alias gi='git ignore'
# syntax-based diff
if exist difft; then
alias gdy='git diffsyn'
alias gdys='git diffsyn --staged'
fi
# show last committed content
alias gll='git last'
alias gdl='git last'
# show quick log overview
alias glg='git log --oneline --decorate --graph'
alias glgd="git log --graph --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"