Reputation: 336
I'm exploring git after having used svn and am having difficulty finding an equivalent for svn log --diff --diff-cmd=meld
to show the log and for each commit open the diff tool (here meld)
Does one exist?
git log -p
seems to be most of the way there, but doesn't appear to have a --tool=
optiongit difftool
doesn't appear to have an easy mechanism to show the incremental changes along a date/commit rangeUpvotes: 3
Views: 67
Reputation: 15652
No need to have that wired into git, as you can trivially compose that behaviour out of classic posix tools:
git log [...] --pretty=%H | xargs -L1 git show
This will run git show
one-by-one on every commit of whatever commit range you specify in [...]
(study the Specifying Ranges section of gitrevisions(7)
manpage). Of course, you can also substitute any command whatsoever into that xargs call, or even write an explicit | while read line; do echo Buzzing $line; done
loop. Because of --pretty=%H
, we're feeding commit hashes into the pipe, one per line, and -L1
makes xargs call git show <sha>
on every <sha>
from the pipe input.
The default git show
will respect the PAGER
environment variable; export PAGER=less
is one common choice, but I'm enjoying another one called bat, for example.
I hope that answers your need already. A few more tips / suggestions.
On large commit ranges, you might prefer to review simply git log [...] -p
in a single pager instance — instead of running your pager N times. Pressing q to quit it once, is less annoying than pressing q N times. Search (using /) will also work better.
If you insist on viewing diffs in a GUI, consider learning & configuring an IDE integration or a standalone git client. That might work better for you than trying to support your workflows with hybrid CLI+GUI concoctions.
Having said that, you can of course view your diffs in meld
while continuing to operate git cli. Git has a concept of difftool — see this question for guidance: Setting up and using Meld as your Git difftool and mergetool
There're even dedicated difftools that enhance reading of the unified diff syntax (as opposed to the split-diff two-panel format in Meld): diff-so-fancy, delta, likely more. See those repositories' readmes to preview what they do, install and configure into git cli. It's as easy as a snippet in gitconfig like this:
#-- https://github.com/so-fancy/diff-so-fancy
[core]
pager = diff-so-fancy | less --tabs=4 -RFX
[interactive]
diffFilter = diff-so-fancy --patch
[diff-so-fancy]
stripLeadingSymbols = false
markEmptyLines = false
— and yes, that integrates nicely into git show
.
Lastly: I find Meld to be especially useful in the 3-way-diff mode, when resolving conficts during merge or rebase. That's almost the same concept; it's called a mergetool.
git difftool
doesn't appear to have an easy mechanism to show the incremental changes along a date/commit range
That's orthogonal to what difftools do; filtering commit ranges is the job handled by git log
. Please study the Specifying Ranges section of gitrevisions(7)
manpage.
Upvotes: 0