[diffoscope] diffoscope with git difftool
bnewbold at robocracy.org
bnewbold at robocracy.org
Thu Apr 7 04:04:21 CEST 2016
Hey Folks!
I learned a new way to use diffoscope today: for visualizing diffs with
git. This is only really helpful if you happen to have binary files (eg,
.pdf, executables) or archives (.tar.gz, etc) in git, which some consider
faux pas, but happens pretty frequently.
If you add something like this to your ~/.gitconfig:
[difftool]
prompt = false
[difftool "diffoscope"]
cmd = "if [ $LOCAL = /dev/null ]; then diffoscope --new $REMOTE; else diffoscope $LOCAL $REMOTE; fi"
Then you can can replace `git diff <args>` with `git difftool -t
diffoscope <args>` and get console output. Additionally, if you install
the `ruby-bcat` package on debian to get the "browser cat" tool (for
viewing HTML piped into stdin), you can add:
[difftool "diffoscope-html"]
cmd = "if [ $LOCAL = /dev/null ]; then diffoscope --new $REMOTE --html
- | bcat; else diffoscope $LOCAL $REMOTE --html - | bcat; fi"
and use `git difftool -t diffoscope-html <args>.
Neato!
It might be helpful in the future for diffoscope to recognize that if the
first argument is /dev/null (or an empty file) that the `--new` argument
is implied, but this might also be unexpected behavior. I worked around it
with the above shell hack (git difftool passes /dev/null as the "$LOCAL"
when a file is new vs. changed).
--bryan
More information about the diffoscope
mailing list