Sublime Forum

External diff tool menu

#1

Following the documentation, I made a simple menu located in the …button to the right of Search in the toolbar to use external diff viewers to compare the selected commit with current state, HEAD or previous commit, also offering to compare the uncommitted current state with HEAD. To use this, put the following in a new file Action.sublime-menu, in the User loose packages/User directory (e.g. for mac, it’s ~/Library/Application Support/Sublime Merge/Packages/User) (for other platforms, refer to the location listed here). To see how to set up git difftool, see this.

File Action.sublime-menu:

[
    {
        "caption":"External diff...",
        "children":
        [
            {
                "caption": "with current state",
                "command": "git",
                "args": {"argv": ["difftool","$short_commit"]}
            },
            {
                "caption": "with previous",
                "command": "git",
                "args": {"argv": ["difftool","$short_commit^!"]}
            },
            {
                "caption": "with HEAD",
                "command": "git",
                "args": {"argv": ["difftool","$short_commit","HEAD"]}
            },
            {
                "caption": "current vs. HEAD",
                "command": "git",
                "args": {"argv": ["difftool"]}
            }
             
        ]
    }
]

6 Likes

External Diff/Merge tool
#2

This is a very good workaround, thanks for pointing out. I have only one issue left… Many times I need to compare two “random” commits. For this to work, I need to access both selected commits, but only one is accessible. Based on the documentation, only the full (or short) hash of the selected commit ($commit and $short_commit) is available.

I’m new here, so how does it work? Should I propose an enhancement here in this forum/post? In this case I would like to ask the devs to make accessible both selected commits. With this enhancement I could set up a custom menu (e.g. Action.sublime-menu, like the one kindly provided by moiraine) to be able to send the diff to my external tool.

2 Likes

#3

Very interesting tools with great potential if only as @rjelinek said would be possible pick up any commit hash.

Anyway I’m facing a weird behavior…or better the script doesn’t work and doesn’t open up the diff view.
I probably missing some configuration in git env because as per screenshot below, the command is execute as aspected but I have to manual confirm smerge to be lunched
(kind of impossible from sublime merge as the command is considered success)

My current git configuration is very basic and standard

[merge]
	tool = smerge
[mergetool "smerge"]
	trustExitCode = false
[diff]
	tool = smerge

The same behavior happens by terminal, if I run the diff command I have to press Y to kind of confirm my intent and finally see smerge showing the diff.


PS: sorry for the overlay image attached, but as new user I can post only one per post :sweat_smile:

Am I missing something kind “auto-accept” setting in my git config?

Thanks

jD4k

0 Likes

#4

I believe this is a case of --prompt / --no-prompt.

You may want to set:

[mergetool "smerge"]
  prompt = false
0 Likes

#5

Thanks @djohnston

I’d found that option googling a while this morning without having the time to try it out.
Of course, it’s the key and now everything works like a charm.

Now it’s not a real issue, but even when sublime it use as difftool it always shows up with the classic 3way editor when the classic 2 would be more than enough, this kind of changes has to come from main dev and there is nothing we can do about it.

Best improve would be, as has been already said few posts above the ability to pick up any commint by his SHA1 <— just in case any bored developer is passing by! :stuck_out_tongue_closed_eyes::upside_down_face::stuck_out_tongue:

0 Likes

#6

I have been using the Action.sublime-menu workaround successfully for some time on Catalina. On my freshly installed Big Sur MacBook it does not work anymore. Is there anything new I should know?

Thanks
Peter

0 Likes

#7

I don’t think anything’s changed recently that would stop something like this from working. How is it failing? Is it not running the appropriate commands or having problems doing so?

0 Likes

#8

The additional action menu is not displayed. I carefully checked the file name and location. Are there any Sublime Merge logs I can check for errors?

0 Likes

#9

Ugh - never mind, I found a syntax error in Action.sublime-menu. No idea how it got messed up.

Thanks
Peter

1 Like

#10

Here I get “fatal: bad object 00000000000”
Sublime Merge Build 2074.

Update: Fixed by configuring git in sublime merge not with “bundled” but with “system” and set up beyond compare as described here.

0 Likes