sublime_merge icon indicating copy to clipboard operation
sublime_merge copied to clipboard

Diff/Merge on non-git files

Open TheClams opened this issue 6 years ago • 29 comments

Problem description

There is no diff/merge tool with proper syntax highlighting like SublimeMerge, but it can only works in a git environment. There is a lot of non-git cases where diff/merge is required The name SublimeMerge put emphasis on Merge not Git, so allow the tools to be used in situation where there is no git repository.

Preferred solution

Support a simple command-line option like : "smerge base mine others". This would make it easy to call SublimeMerge from other revision control tools.

Alternatives

And an even greater upgrade would be to allow diff/merge directly on two directories,

TheClams avatar Oct 02 '18 05:10 TheClams

Yes, please.

When I first saw Sublime Merge announcement, I was over the moon thinking that there is finally a viable alternative to outdated $250 two/three-way diff & merge tool that I use regularly (on macOS).

If you could somehow extend Sublime Merge functionality, so that it could be used outside of version control repositories for diff/merge operations — I'd gladly pay extra for such extension. Though to be useful in my case, it has to support directory diff.

inikitin avatar Oct 06 '18 12:10 inikitin

This would definitely be a big selling point. Beeing able to use it for all kind of merge/comparison operations would just remove the need for another inferior tool.

TheEggi avatar Oct 23 '18 09:10 TheEggi

This also allows it to be used with git mergetool and git difftool.

baharclerode avatar Oct 25 '18 17:10 baharclerode

I do not know how well it works, but @sonOfRa has a Gist to do that.

michaelblyons avatar Nov 21 '18 19:11 michaelblyons

Also, can we have a full file side-by-side diff please? Bonus points for mini-map.

erincatto avatar Nov 22 '18 23:11 erincatto

When I saw the name, SublimeMerge, I assumed it was product in the merge category like Araxis Merge, WinMerge, P4Merge, DiffMerge etc all of which merge files and have nothing to do with version control.

Maybe that's my bad for originally mis-understanding the product (a git front end, not merge software). But, I'd love better merge software. I use Slickedit's built in merge all the time as it allows comparing entire trees and merging in either direction and also marks if I've visited a file or not so I have some idea which files I've checked. One thing I really like about Slickedit's merge is that both sides are live so if I see a minor issue in the diff I can fix it right there, remove some white space, add a missing semicolon, etc.., without having to switch apps. Of course I can keep using other software but given the diffing code is in SublimeMerge it seems a natural thing for it to support this use case? (or I guess you're just reading git's diff output in which case maybe not?) Or maybe you could fork, it, rename this SublimeGit and actually make a SublimeMerge to compete with other merge software?

greggman avatar Nov 26 '18 06:11 greggman

+1

I've been using Araxis Merge for 10+ years. I'd love to have a Sublime replacement.

forrestthewoods avatar Nov 26 '18 19:11 forrestthewoods

Does Sublime Merge currently support opening an arbitrary .diff file to take advantage of the great side-by-side syntax highlighting? This would be very convenient for viewing patch files without needing to apply the patch to a repo first.

I'm not sure if what I described should be a stand-alone feature request or if it's baked into this one.

hintron avatar Jan 07 '19 21:01 hintron

For what it's worth, this is all I want out of Sublime Merge. If I could use it as a git mergetool, you would have my money today.

djspiewak avatar Feb 02 '19 18:02 djspiewak

Hi all,

Just a quick update - in the latest dev build of Sublime Merge (1105), we've added a mergetool mode for smerge (the command line tool). It currently works on Linux and MacOS, with Windows support to come in the next build.

For details, see smerge --help

dpjohnst avatar Mar 05 '19 12:03 dpjohnst

@dpjohnst How would one configure this to work with git-difftool? I've tried the following:

[diff]
  tool = sublime_merge
[difftool "sublime_merge"]
  trustExitCode = true
  cmd = smerge mergetool \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"
$ git init
Initialized empty Git repository in /private/tmp/tmp.gmSsqFnrui/.git/

$ mkdir foo

$ echo baz > foo/bar

$ git add foo/

$ git commit -am blah
[master (root-commit) 9a4d664] blah
 1 file changed, 1 insertion(+)
 create mode 100644 foo/bar

$ echo bax > foo/bar

$ git commit -am blahblah
[master ccafdc7] blahblah
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git difftool --dir-diff HEAD^ -- foo/

But I get the following error:

image

Any ideas?

zx8 avatar Mar 05 '19 15:03 zx8

You might need a --wait before mergetool in your command

TheClams avatar Mar 05 '19 15:03 TheClams

@dpjohnst Take my money

djspiewak avatar Mar 05 '19 15:03 djspiewak

@TheClams Nice tip! Note that -w/--wait is not a documented option in the output of smerge --help, but seems to be supported:

$ smerge --help
Sublime Merge build 1105

Usage: smerge path                                         Open the given repository
   or: smerge search query                                 Search for commits in the current repository
   or: smerge blame file [line]                            Blame the given file in the current repository
   or: smerge log file                                     Show the file history in the current repository
   or: smerge mergetool [base] left right [-o merged]      Opens the merge tool for the given files

  -n or --new-window:      Open a new window
  -b or --background:      Don't activate the application
  -h or --help:            Show help (this message) and exit
  -v or --version:         Show version and exit

That said, I think the issue is also that smerge doesn't (yet?) support diffing directories (i.e. --dir-diff). Seems to work when I exclude the --dir-diff option.


[edit] Looks like --wait is no longer needed in Build 1106+:

image

zx8 avatar Mar 05 '19 15:03 zx8

Is this working in windows now too?

TheEggi avatar Mar 10 '19 08:03 TheEggi

Hi @TheEggi,

As of the latest development build, this feature is supported on all platforms.

dpjohnst avatar Mar 12 '19 04:03 dpjohnst

There seems to be a bug with argument parsing, calling the mergetool like its documented will try to find a git repo in the applications path (and above). Look at the call below and the strace output:

strace smerge mergetool ./package/glibc/glibc.mk ./package/glibc/glibc.mk ./package/glibc/glibc.hash -o /tmp/xx
stat("/usr/bin/smerge/.git", 0x7ffd3ed8d2e8) = -1 ENOTDIR (Not a directory)
stat("/usr/bin/smerge/.git", 0x7ffd3ed8d2e8) = -1 ENOTDIR (Not a directory)
stat("/usr/bin/smerge/config", 0x7ffd3ed8d198) = -1 ENOTDIR (Not a directory)
stat("/usr/bin/.git", 0x7ffd3ed8d2e8)   = -1 ENOENT (No such file or directory)
stat("/usr/bin/.git", 0x7ffd3ed8d2e8)   = -1 ENOENT (No such file or directory)
stat("/usr/bin/config", 0x7ffd3ed8d198) = -1 ENOENT (No such file or directory)
stat("/usr/.git", 0x7ffd3ed8d2e8)       = -1 ENOENT (No such file or directory)
stat("/usr/.git", 0x7ffd3ed8d2e8)       = -1 ENOENT (No such file or directory)
stat("/usr/config", 0x7ffd3ed8d198)     = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
brk(0x1b60000)                          = 0x1b60000
write(1, "Unable to find a git repository "..., 51Unable to find a git repository at /usr/bin/smerge

What does work correctly, is adding any path as another argument:

strace smerge mergetool ./package/glibc/glibc.mk ./package/glibc/glibc.mk ./package/glibc/glibc.hash -o /tmp/xx /some/phantasy/path

Build is Sublime Merge Build 1107 on Linux x86_64 (Debian 10)

nolange avatar Mar 15 '19 23:03 nolange

There seems to be an issue with the windows version. Somehow it tries to add the current path to the parameters - not sure if there is a way to work around this issue:

Following command is not working:

smerge mergetool "D:\new_folder_4/1.tps" "D:/new_folder_4/2.tps"

Error message:

---------------------------
Sublime Merge
---------------------------
Error reading file: C:\D:\new_folder_4\1.tps
---------------------------
OK   
---------------------------

I tried to add a "/" in front of the paramater, which would lead to the following command: smerge mergetool "/D:\new_folder_4/1.tps" "/D:/new_folder_4/2.tps"

Afterwards it seems to not add the current directory anymore, but the path itself is incorrect (as expected).

---------------------------
Sublime Merge
---------------------------
Error reading file: D::\new_folder_4\1.tps
---------------------------
OK   
---------------------------

Edit: This issue is now fixed in 1108. Thank you for fixing it! Only thing left now is the difftool/2 way diff for it to be a complete replacement to other tools.

TheEggi avatar Mar 17 '19 10:03 TheEggi

Are there plans to support diffing directories?

nikitaourazbaev avatar Mar 19 '19 16:03 nikitaourazbaev

@nolange thanks for the report! This has been fixed as of build 1109.

@TheEggi thank you for the report also! As you've noted this has been fixed as of build 1108.

@nikitaourazbaev currently we haven't got any plans to support directory diffing, however this may change in the future. If you haven't already, I suggest putting up a feature request on this issue tracker :)

dpjohnst avatar Mar 21 '19 01:03 dpjohnst

@dpjohnst this feature request is about diffing non-git files (and directories) ;)

bbars avatar Mar 21 '19 09:03 bbars

+1 on this, first class support for git difftool would be tops, it's the one thing that's keeping smerge from being basically a perfect git gui for me.

patrickfatrick avatar Mar 23 '20 15:03 patrickfatrick

I don't think a merge tool is the correct answer to this issue, at least that's not what first comes to my mind when i try to diff two files. What i expect is a simple diff, with the possibility to copy or save it.

AmjadHD avatar Aug 18 '20 19:08 AmjadHD

What about sublimerge? it does diff of files/clipboard/selection and all within sublime text (you do not need to launch SM in order to diff 2 files)

dspasic12 avatar Dec 17 '21 08:12 dspasic12

Subscribed to this issue update, personally, very much looking forward to Sublime Merge adding a local file comparison feature.

a1waysbeta avatar Dec 18 '21 11:12 a1waysbeta

Has there been any update on this feature? for folder diff

rakeshmalik91 avatar Mar 01 '24 12:03 rakeshmalik91

There's barely any update to the app, let alone new features. I'm worried this will become abandonware 🤷🏽

kuntau avatar Jul 11 '24 15:07 kuntau

There's barely any update to the app, let alone new features. I'm worried this will become abandonware 🤷🏽

On Discord, Dylan said there's stuff coming. I don't know which things he might be speaking about, but it's not abandoned.

michaelblyons avatar Jul 11 '24 17:07 michaelblyons