Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External diff viewer #219

Open
tomaz opened this issue Nov 1, 2013 · 10 comments
Open

External diff viewer #219

tomaz opened this issue Nov 1, 2013 · 10 comments
Labels
Milestone

Comments

@tomaz
Copy link

tomaz commented Nov 1, 2013

Can't find a way to use external diff viewer (kaleideoscope for example). Am I missing something or is this not possible?

@jonas
Copy link
Owner

jonas commented Nov 1, 2013

There's no global option to open an external diff viewer. Would be a nice
feature though.

What is possible today is to remap the key binding for opening a commit
diff in Tig so that it calls a shell script that calls your diff viewer:

bind main Enter !/path/to/script %(commit)

If you already have it set up your external diff viewer in Git the above
could probably be simplified.
On Nov 1, 2013 2:11 AM, "tomaz" [email protected] wrote:

Can't find a way to use external diff viewer (kaleideoscope for example).
Am I missing something or is this not possible?


Reply to this email directly or view it on GitHubhttps://github.com//issues/219
.

@tomaz
Copy link
Author

tomaz commented Nov 1, 2013

Will try the workaround. The option would be very useful IMHO. External tools usually provide nicer visual representation than git diff. Plus having it open in another window simultaneously while writing commit message is big help. At least that's how I function.

I checked the source code and tried few things already, but it didn't work. Would probably need to spend more time with code to better understand. If you won't consider adding this in forseeable future, I can take another look if you can send me some tips that will guide me to proper direction. Especially if binding will not be enough.

On 1. nov. 2013, at 13:34, Jonas Fonseca [email protected] wrote:

There's no global option to open an external diff viewer. Would be a nice
feature though.

What is possible today is to remap the key binding for opening a commit
diff in Tig so that it calls a shell script that calls your diff viewer:

bind main Enter !/path/to/script %(commit)

If you already have it set up your external diff viewer in Git the above
could probably be simplified.

@jargv
Copy link

jargv commented Dec 9, 2015

Is there any more information about setting up the binding? The example given by @jonas above appears to diff all changes for a commit. I'd like to diff a singe file externally, for example, from the status view.

@jonas
Copy link
Owner

jonas commented Jan 8, 2016

@jargv Untested but something like the following:

git difftool --tool vimdiff --no-prompt %(commit) %(file)

@vitalybe
Copy link

I've made the following difftool bindings in .tigrc:

bind status <F4> !git difftool -y %(commit) %(file)
bind generic <F5> !git difftool -d --no-symlinks %(commit)

F4 - In status view shows the diff of the selected file
F5 - Useful in both log view and status view to see all changed files at once using git's dir-diff

@jonas jonas modified the milestones: tig-2.2, tig-2.3 Aug 13, 2016
@jonas jonas modified the milestones: tig-2.3, tig-2.4 Jul 10, 2017
@kmac
Copy link

kmac commented Jul 20, 2018

I was playing around with some of the above solutions. They all compare a commit against the HEAD revision, whereas I want to compare against the previous revision. I tried using %(commit)~1 as an argument to the difftool command, but that's not parsed correctly to the external call.

I ended up creating a script, tig-difftool-helper.sh which tailors the arguments to difftool (simplified here):

#!/bin/bash
if [ -z "$2" ]; then
  git difftool -y "${1}" "${1}~1"  # diff against previous commit
else
  git difftool -y "${1}" "${1}~1" -- "$2"  # filebased diff against previous
fi

And these bindings in .tigrc:

# in diff view, diff against previous commit:
bind diff <F4> !tig-difftool-helper.sh %(commit) %(file)
# generic, diff commit against previous commit:
bind generic <F5> !tig-difftool-helper.sh %(commit)
# in status and stage view there's no commit: diff against HEAD (no need for helper):
bind status <F4> !git difftool -y -- %(file)
bind stage <F4> !git difftool -y -- %(file)

@koutcher
Copy link
Collaborator

The external script shouldn’t be necessary, you will find some hints in issue #26.

@vitalybe
Copy link

@kmac Here is what I did to achieve the same:

# compare commit in log view with its parent per http://stackoverflow.com/questions/436362/shorthand-for-diff-of-git-commit-with-its-parent
bind main <F4> !git difftool -d %(commit)^!

@liming01
Copy link

liming01 commented Sep 11, 2023

@jonas.
Can we support difftastic? It supports syntax tree diff which can be useful for those languages that have auto formatter (e.g. rust lang).

I set it as git external diff, and then git diff --ext-diff works fine.
But when running tig --ext-diff, it displayed without any color/highlight.

@pablospe
Copy link

Duplicated issue? See Issue #542.
Also there is this comment that might be interested for you, although it is using delta instead of difftastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants