Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket breaks diff and mergetool commands in gitconfig by adding quotes

Jason Orr February 15, 2023

I have an external diff and merge tool configured in Sourcetree which works 99% of the time without issue. The lines in my .gitconfig for my diff and merge tools are:

[difftool "sourcetree"]
cmd = ~/bin/lvcompareWrapper.sh \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = ~/bin/lvmergeWrapper.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"

Notice there are no single quotes around the paths to my scripts. When my .gitconfig file is configured like this, the external diff and merge tools work just fine (Ctrl+D opens my external diff tool correctly).

However, whenever I open Tools»Options in Sourcetree, my .gitconfig file gets modified, and the only changes are that singe quotes are added around the paths pointing to my diff and merge scripts:

[difftool "sourcetree"]
cmd = '~/bin/lvcompareWrapper.sh' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = '~/bin/lvmergeWrapper.sh' \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
trustExitCode = true

Sourcetree has added single quotes around the paths, which prevents the external diff and merge from working properly from Sourcetree (Ctrl+D does nothing).

I've been having to keep my .gitconfig file open in notepad++ for months so I can manually delete these extra quotes every time I open Sourcetree's options because if I don't, my diff tool stops working, even though I have "Allow Sourcetree to modify your global Git and Mercurial config files" unchecked. I have even marked my .gitconfig file as "Read-Only" in Windows but it still gets modified by Sourcetree whenever I open Options.

image.png

If I use Git Bash, the diff tool works and does not modify .gitconfig, if I use TortoiseGit, the diff tool works and does not modify .gitconfig. Only Sourcetree modifies my .gitconfig and breaks my diff tools every time. Extremely frustrating.

In the "Diff" tab in Sourcetree's options, the External Diff/Merge commands are greyed out and I can't edit them, but even still, Sourcetree is modifying my .gitconfig file.

image.png

I have System Git enabled, and I am running on Sourcetree version 3.4.11, although this has been happening for a while (I think I've updated Sourcetree twice since installing it on this computer)

image.png

How do I stop Sourcetree from modifying my global .gitconfig and breaking my diff tools every time I open Tools»Options? It's driving me insane.

OS: Windows 10 22H2 (19045.2486)
Sourcetree: 3.4.11
Git: 2.38.1.windows.1

2 answers

1 vote
fredzvt July 3, 2023

Sorry, I don't have an answer for you, I think this is a problem in SourceTree's code and there is nothing we can configure to change it.

But your question helped me figure out why the external tool was not working on my end. Thanks for that!

https://community.atlassian.com/t5/Sourcetree-questions/External-Diff-does-not-work/qaq-p/2403772

0 votes
Jason Orr March 21, 2023

Nothing? No one has any idea? Is this intended behavior for Sourcetree, or is there some configuration or setting I'm missing?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events