git show commit in beyond compare
Asked Answered
G

6

22

I would like to see a specific commit in Beyond Compare or any other separate diff tool while viewing it via git show. I tried looking at help of git show/difftool/config but couldn't find anything. Does anyone know how it can be done?

I've looked at Git Diff with Beyond Compare and configured Beyond Compare for git difftool but I also want to use it as tool from git show

Goodrich answered 22/9, 2011 at 13:6 Comment(0)
G
25

I managed to use git difftool to see commits that I normally used to see via git show.

git show $commit translates to git difftool $commit^ $commit.

The above command shows difference between commit's parent ($commit^) and commit. All this is of course after configuring Beyond Compare with difftool.

Goodrich answered 6/10, 2011 at 12:6 Comment(1)
git show $commit is not equivalent to git difftool $commit^ $commit if we are reviewing a merge commit. git show presents the merge commit in a special format as produced by git diff-tree --cc $commit. See git-scm.com/docs/git-showOreste
W
13

You can also create an alias "showtool" to wrap the call to git difftool:

set +o histexpand
git config --global alias.showtool "! sh -c 'if [ -z \$1 ]; then REVISION="HEAD"; else REVISION="\$1"; fi; git difftool \$REVISION~ \$REVISION' -"

.. then you can execute:

git showtool 81e945b

.. or just

git showtool

.. as a shortcut for git difftool 81e945b~1 81e945b to show the changes introduced in 81e945b using the configured difftool, or in the second case git difftool HEAD~1 HEAD

Wershba answered 20/8, 2013 at 1:36 Comment(3)
Thanks, this is what I was looking for. I extended it to work also without parameter like git show does: set +o histexpand; git config --global alias.showtool "!sh -c 'if [ -z \$1 ]; then REVISION="HEAD"; else REVISION="\$1"; fi; git difftool \$REVISION~ \$REVISION\' -"Mckeever
Thanks Tomáš, I like that enhancement and have adopted it and edited the solution above. I found one stray backslash in your code, the last one before the closing ', so please check.Wershba
I have expanded this on git-showtool repo to support commands like $ git showtool -y :/my\ commit\ messageScarcely
B
3

Once you have a diff tool set up, like the awesome p4merge, you can do this:

git diff HEAD HEAD~1

Works like a charm.

Similarly if you want to see the commit before that, you can do:

git diff HEAD~1 HEAD~2
Bedard answered 25/8, 2014 at 4:3 Comment(0)
F
1

This worked for me nicely, to show the diff of the last commit

git difftool HEAD~ HEAD

For other commits you can replace HEAD with commit hash eg:

git difftool 1234ABCD~ 1234ABCD
Flanigan answered 16/7, 2013 at 19:38 Comment(0)
B
0

I think that git show is based on the tool set in the GIT_PAGER variable. I don't use Beyond Compare but i think that you can try something like this:

$ GIT_PAGER='bc3' git show <whatever>

Maybe you should fill the GIT_PAGER variable with some additional parameter that allows bc3 process the input.

There are more suitable ways to persist the pager. This question can give you more tips about how to do it.

Barnstorm answered 22/9, 2011 at 14:13 Comment(1)
Thanks. I'll try it out and let you know.Goodrich
S
0

Based on @javabrett answer I have created

https://github.com/albfan/git-showtool

to support commands like

$ git showtool -y :/my\ commit\ message
Scarcely answered 28/12, 2014 at 19:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.