Skip to content

Instantly share code, notes, and snippets.

@steadystatic
Forked from jaburns/.gitconfig
Created December 22, 2020 16:43
Show Gist options
  • Save steadystatic/1f5eb7f5560d538ee181ac5f235ad7d5 to your computer and use it in GitHub Desktop.
Save steadystatic/1f5eb7f5560d538ee181ac5f235ad7d5 to your computer and use it in GitHub Desktop.
Using VS as mergetool on WSL
[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
#!/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