Merge branch 'jn/plug-empty-tree-leak'
[gitweb.git] / git-mergetool--lib.sh
index 4db9212331259664732f031438b7b87b7a10244f..9a89e8f31981a0c82cf25ab6c75a6f841c7ba79b 100644 (file)
@@ -79,13 +79,18 @@ get_merge_tool_cmd () {
        fi
        if diff_mode; then
                echo "$(git config difftool.$merge_tool.cmd ||
-                       git config mergetool.$merge_tool.cmd)"
+                       git config mergetool.$merge_tool.cmd)"
        else
                echo "$(git config mergetool.$merge_tool.cmd)"
        fi
 }
 
 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
                ;;
@@ -412,7 +419,7 @@ get_merge_tool_path () {
        fi
        if diff_mode; then
                merge_tool_path=$(git config difftool."$merge_tool".path ||
-                                 git config mergetool."$merge_tool".path)
+                                 git config mergetool."$merge_tool".path)
        else
                merge_tool_path=$(git config mergetool."$merge_tool".path)
        fi
@@ -422,7 +429,7 @@ get_merge_tool_path () {
        if test -z "$(get_merge_tool_cmd "$merge_tool")" &&
        ! type "$merge_tool_path" > /dev/null 2>&1; then
                echo >&2 "The $TOOL_MODE tool $merge_tool is not available as"\
-                        "'$merge_tool_path'"
+                        "'$merge_tool_path'"
                exit 1
        fi
        echo "$merge_tool_path"