difftool: remove merge options for opendiff, tkdiff, kdiff3 and xxdiff
[gitweb.git] / contrib / difftool / git-difftool-helper
index db3af6a833f030cae94dbcd5926aac1b380969a7..ef684b6f68e8376fb20761b8936bef6d9dbee2e3 100755 (executable)
@@ -69,7 +69,7 @@ launch_merge_tool () {
                "$merge_tool_path" --auto \
                        --L1 "$basename (A)" \
                        --L2 "$basename (B)" \
-                       -o "$MERGED" "$LOCAL" "$REMOTE" \
+                       "$LOCAL" "$REMOTE" \
                        > /dev/null 2>&1
                ;;
 
@@ -78,7 +78,7 @@ launch_merge_tool () {
                ;;
 
        tkdiff)
-               "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
+               "$merge_tool_path" "$LOCAL" "$REMOTE"
                ;;
 
        meld)
@@ -86,26 +86,22 @@ launch_merge_tool () {
                ;;
 
        vimdiff)
-               "$merge_tool_path" -c "wincmd l" "$LOCAL" "$REMOTE"
+               "$merge_tool_path" -d -c "wincmd l" "$LOCAL" "$REMOTE"
                ;;
 
        gvimdiff)
-               "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$REMOTE"
+               "$merge_tool_path" -d -c "wincmd l" -f "$LOCAL" "$REMOTE"
                ;;
 
        xxdiff)
                "$merge_tool_path" \
-                       -X \
-                       -R 'Accel.SaveAsMerged: "Ctrl-S"' \
                        -R 'Accel.Search: "Ctrl+F"' \
                        -R 'Accel.SearchForward: "Ctrl-G"' \
-                       --merged-file "$MERGED" \
                        "$LOCAL" "$REMOTE"
                ;;
 
        opendiff)
-               "$merge_tool_path" "$LOCAL" "$REMOTE" \
-                       -merge "$MERGED" | cat
+               "$merge_tool_path" "$LOCAL" "$REMOTE" | cat
                ;;
 
        ecmerge)
@@ -128,8 +124,10 @@ launch_merge_tool () {
        cleanup_temp_files
 }
 
-# Verifies that mergetool.<tool>.cmd exists
+# Verifies that (difftool|mergetool).<tool>.cmd exists
 valid_custom_tool() {
+       merge_tool_cmd="$(git config difftool.$1.cmd)"
+       test -z "$merge_tool_cmd" &&
        merge_tool_cmd="$(git config mergetool.$1.cmd)"
        test -n "$merge_tool_cmd"
 }
@@ -150,11 +148,20 @@ valid_tool() {
 }
 
 # Sets up the merge_tool_path variable.
-# This handles the mergetool.<tool>.path configuration.
+# This handles the difftool.<tool>.path configuration.
+# This also falls back to mergetool defaults.
 init_merge_tool_path() {
+       merge_tool_path=$(git config difftool."$1".path)
+       test -z "$merge_tool_path" &&
        merge_tool_path=$(git config mergetool."$1".path)
        if test -z "$merge_tool_path"; then
                case "$1" in
+               vimdiff)
+                       merge_tool_path=vim
+                       ;;
+               gvimdiff)
+                       merge_tool_path=gvim
+                       ;;
                emerge)
                        merge_tool_path=emacs
                        ;;
@@ -165,15 +172,19 @@ init_merge_tool_path() {
        fi
 }
 
-# Allow the GIT_MERGE_TOOL variable to provide a default value
+# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values
 test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL"
+test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL"
 
-# If not merge tool was specified then use the merge.tool
+# If merge tool was not specified then use the diff.tool
 # configuration variable.  If that's invalid then reset merge_tool.
+# Fallback to merge.tool.
 if test -z "$merge_tool"; then
+       merge_tool=$(git config diff.tool)
+       test -z "$merge_tool" &&
        merge_tool=$(git config merge.tool)
        if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
-               echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
+               echo >&2 "git config option diff.tool set to unknown tool: $merge_tool"
                echo >&2 "Resetting to default..."
                unset merge_tool
        fi