summaryrefslogtreecommitdiff
path: root/git-mergetool--lib.sh
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2011-05-26 06:21:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-26 22:05:52 (GMT)
commitf9ad901fd31991837c9648bbee8ac18b39aa0891 (patch)
tree19c31a93951cc9f26596fe88bed8fd9ad34c72d6 /git-mergetool--lib.sh
parent26b052515d1714918a7da4bfcdaaca37dc4db2e0 (diff)
downloadgit-f9ad901fd31991837c9648bbee8ac18b39aa0891.zip
git-f9ad901fd31991837c9648bbee8ac18b39aa0891.tar.gz
git-f9ad901fd31991837c9648bbee8ac18b39aa0891.tar.bz2
git-mergetool--lib: Make vimdiff retain the current directory
When using difftool with vimdiff it can be unexpected that the current directory changes to the root of the project. Tell vim to chdir to the value of $GIT_PREFIX to fix this. Care is taken to quote the variable so that vim expands it. This avoids problems when directory names contain spaces. Signed-off-by: David Aguilar <davvid@gmail.com> Reported-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-mergetool--lib.sh')
-rw-r--r--git-mergetool--lib.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index fb3f52b..f5a100a 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -86,6 +86,11 @@ get_merge_tool_cmd () {
}
run_merge_tool () {
+ # If GIT_PREFIX is empty then we cannot use it in tools
+ # that expect to be able to chdir() to its value.
+ GIT_PREFIX=${GIT_PREFIX:-.}
+ export GIT_PREFIX
+
merge_tool_path="$(get_merge_tool_path "$1")" || exit
base_present="$2"
status=0
@@ -188,6 +193,7 @@ run_merge_tool () {
check_unchanged
else
"$merge_tool_path" -R -f -d -c "wincmd l" \
+ -c 'cd $GIT_PREFIX' \
"$LOCAL" "$REMOTE"
fi
;;
@@ -199,6 +205,7 @@ run_merge_tool () {
check_unchanged
else
"$merge_tool_path" -R -f -d -c "wincmd l" \
+ -c 'cd $GIT_PREFIX' \
"$LOCAL" "$REMOTE"
fi
;;