}
}
-diff_mode() {
+diff_mode () {
test "$TOOL_MODE" = diff
}
-merge_mode() {
+merge_mode () {
test "$TOOL_MODE" = merge
}
+gui_mode () {
+ test "$GIT_MERGETOOL_GUI" = true
+}
+
translate_merge_tool_path () {
echo "$1"
}
}
get_configured_merge_tool () {
- # If first argument is true, find the guitool instead
- if test "$1" = true
- then
- gui_prefix=gui
- fi
-
- # Diff mode first tries diff.(gui)tool and falls back to merge.(gui)tool.
- # Merge mode only checks merge.(gui)tool
+ keys=
if diff_mode
then
- merge_tool=$(git config diff.${gui_prefix}tool || git config merge.${gui_prefix}tool)
+ if gui_mode
+ then
+ keys="diff.guitool merge.guitool diff.tool merge.tool"
+ else
+ keys="diff.tool merge.tool"
+ fi
else
- merge_tool=$(git config merge.${gui_prefix}tool)
+ if gui_mode
+ then
+ keys="merge.guitool merge.tool"
+ else
+ keys="merge.tool"
+ fi
fi
+
+ merge_tool=$(
+ IFS=' '
+ for key in $keys
+ do
+ selected=$(git config $key)
+ if test -n "$selected"
+ then
+ echo "$selected"
+ return
+ fi
+ done)
+
if test -n "$merge_tool" && ! valid_tool "$merge_tool"
then
echo >&2 "git config option $TOOL_MODE.${gui_prefix}tool set to unknown tool: $merge_tool"
}
get_merge_tool () {
+ is_guessed=false
# Check if a merge tool has been configured
merge_tool=$(get_configured_merge_tool)
# Try to guess an appropriate merge tool if no tool has been set.
if test -z "$merge_tool"
then
merge_tool=$(guess_merge_tool) || exit
+ is_guessed=true
fi
echo "$merge_tool"
+ test "$is_guessed" = false
}
mergetool_find_win32_cmd () {