gitdifftoolmergetool

Is Git's auto-detection scripted or is it within some Git executable?


This question is based on VonC's comment at the thread.

Is Git's auto-detection for difftool or mergetool scripted or is it within some Git executable?


Solution

  • It's scripted in git-mergetool. I found this at line 344 of my copy.

    if test -z "$merge_tool"; then
        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 "Resetting to default..."
            unset merge_tool
        fi
    fi
    
    if test -z "$merge_tool" ; then
        if test -n "$DISPLAY"; then
            merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff"
            if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
                merge_tool_candidates="meld $merge_tool_candidates"
            fi
            if test "$KDE_FULL_SESSION" = "true"; then
                merge_tool_candidates="kdiff3 $merge_tool_candidates"
            fi
        fi
        if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
            merge_tool_candidates="$merge_tool_candidates emerge"
        fi
    (snip)