I'm trying to use an external diff tool to compare a given file from two commits. If I select two commits in SourceTree and neither one is currently checked out, the file is checked out from each branch, copied to a temporary location, and the absolute (full) path of each is passed to the external diff tool. Everything works fine.
However, if one of the commits is currently checked out, the absolute path is not passed to the external diff tool. It seems only the filename (or perhaps relative path, based from the root working dir of the git repo) is passed. This causes the external diff to fail because the current working directory is the directory containing the external diff tool, rather than the appropriate directory within the git workspace ($PWD in SourceTree).
If I replace $LOCAL and $REMOTE with $PWD\$LOCAL and $PWD\$REMOTE, respectively, the absolute path for the file in the currently checked-out commit is passed correctly, but of course this breaks the other one (the temporary file path from the branch which is not checked out).
I've also reproduced the same issue with git difftool on the command-line, but of course when running the path on the command-line, the current working directory is correct. Is there a workaround to make SourceTree prepend $PWD\ only when necessary? If not, is there some other solution that will solve my problem?
This issue seems to be a defect in SourceTree's design. Normally when you use git, your current working directory is in the git repo. SourceTree, on the other hand, does not set the the git repo as the current working directory, so any relative paths will be incorrect.
I ended up having to create a batch file and pass $PWD as an additional argument. (In my testing, I found that $PWD apparently reports the root of the git repo.) The batch file cd's into $PWD, then passes the remaining arguments to the external diff tool.
Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG