Last active
April 25, 2021 05:21
-
-
Save jaburns/4e9f18a7fe3294970feaa69e4892a681 to your computer and use it in GitHub Desktop.
Using VS as mergetool on WSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[merge] | |
tool = vs | |
[mergetool "vs"] | |
cmd = /home/XXX/win_merge.sh merge $LOCAL $REMOTE $BASE $MERGED | |
trustExitCode = false | |
[mergetool] | |
keepBackup = false | |
[diff] | |
tool = vs | |
[difftool "vs"] | |
cmd = /home/XXX/win_merge.sh diff $LOCAL $PWD/$REMOTE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
VS_MERGE='/mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsDiffMerge.exe' | |
get_filename() { | |
echo "$1" | sed 's:.*/::' | |
} | |
resolve_path() { | |
pushd "$(dirname "$1")" >/dev/null | |
local base_path="$(pwd -P | sed 's:/mnt/::;s_/_:/_;s:/:\\:g')" | |
echo "$base_path\\$(get_filename "$1")" | |
popd >/dev/null | |
} | |
do_diff() { | |
local tmp_local="$(get_filename $1)" | |
local remote="$(resolve_path "$2")" | |
cp "$1" "/mnt/c/Windows/Temp/$tmp_local" | |
"$VS_MERGE" /t "C:\\Windows\\Temp\\$tmp_local" "$remote" Source Target | |
} | |
case "$1" in | |
diff) do_diff "$2" "$3" ;; | |
merge) "$VS_MERGE" /m "$2" "$3" "$4" "$5" ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
.gitconfig
above specifies stuff to add to your~/.gitconfig
file. Replace the paths starting with/home/XXX
to wherever you end up droppingwin_merge.sh
, but they must be absolute paths.