2013-11-26 01:03:52 +04:00
|
|
|
# git-mergetool--lib is a shell library for common merge tool functions
|
2013-01-28 04:52:26 +04:00
|
|
|
|
|
|
|
: ${MERGE_TOOLS_DIR=$(git --exec-path)/mergetools}
|
2013-01-27 04:46:12 +04:00
|
|
|
|
2015-05-20 12:07:22 +03:00
|
|
|
IFS='
|
|
|
|
'
|
|
|
|
|
2013-01-28 04:52:25 +04:00
|
|
|
mode_ok () {
|
|
|
|
if diff_mode
|
|
|
|
then
|
|
|
|
can_diff
|
|
|
|
elif merge_mode
|
|
|
|
then
|
|
|
|
can_merge
|
|
|
|
else
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
is_available () {
|
|
|
|
merge_tool_path=$(translate_merge_tool_path "$1") &&
|
|
|
|
type "$merge_tool_path" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2013-01-30 23:55:46 +04:00
|
|
|
list_config_tools () {
|
|
|
|
section=$1
|
|
|
|
line_prefix=${2:-}
|
|
|
|
|
|
|
|
git config --get-regexp $section'\..*\.cmd' |
|
|
|
|
while read -r key value
|
|
|
|
do
|
|
|
|
toolname=${key#$section.}
|
|
|
|
toolname=${toolname%.cmd}
|
|
|
|
|
|
|
|
printf "%s%s\n" "$line_prefix" "$toolname"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-01-28 04:52:25 +04:00
|
|
|
show_tool_names () {
|
|
|
|
condition=${1:-true} per_line_prefix=${2:-} preamble=${3:-}
|
|
|
|
not_found_msg=${4:-}
|
2013-01-30 23:55:46 +04:00
|
|
|
extra_content=${5:-}
|
2013-01-28 04:52:25 +04:00
|
|
|
|
|
|
|
shown_any=
|
|
|
|
( cd "$MERGE_TOOLS_DIR" && ls ) | {
|
2020-07-30 00:31:12 +03:00
|
|
|
while read scriptname
|
|
|
|
do
|
|
|
|
setup_tool "$scriptname" 2>/dev/null
|
|
|
|
variants="$variants$(list_tool_variants)\n"
|
|
|
|
done
|
|
|
|
variants="$(echo "$variants" | sort | uniq)"
|
|
|
|
|
|
|
|
for toolname in $variants
|
2013-01-28 04:52:25 +04:00
|
|
|
do
|
|
|
|
if setup_tool "$toolname" 2>/dev/null &&
|
|
|
|
(eval "$condition" "$toolname")
|
|
|
|
then
|
|
|
|
if test -n "$preamble"
|
|
|
|
then
|
|
|
|
printf "%s\n" "$preamble"
|
|
|
|
preamble=
|
|
|
|
fi
|
|
|
|
shown_any=yes
|
|
|
|
printf "%s%s\n" "$per_line_prefix" "$toolname"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2013-01-30 23:55:46 +04:00
|
|
|
if test -n "$extra_content"
|
|
|
|
then
|
|
|
|
if test -n "$preamble"
|
|
|
|
then
|
|
|
|
# Note: no '\n' here since we don't want a
|
|
|
|
# blank line if there is no initial content.
|
|
|
|
printf "%s" "$preamble"
|
|
|
|
preamble=
|
|
|
|
fi
|
|
|
|
shown_any=yes
|
|
|
|
printf "\n%s\n" "$extra_content"
|
|
|
|
fi
|
|
|
|
|
2013-01-28 04:52:25 +04:00
|
|
|
if test -n "$preamble" && test -n "$not_found_msg"
|
|
|
|
then
|
|
|
|
printf "%s\n" "$not_found_msg"
|
|
|
|
fi
|
|
|
|
|
|
|
|
test -n "$shown_any"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-29 09:21:11 +03:00
|
|
|
diff_mode () {
|
2009-04-08 11:17:20 +04:00
|
|
|
test "$TOOL_MODE" = diff
|
|
|
|
}
|
|
|
|
|
2019-04-29 09:21:11 +03:00
|
|
|
merge_mode () {
|
2009-04-08 11:17:20 +04:00
|
|
|
test "$TOOL_MODE" = merge
|
|
|
|
}
|
|
|
|
|
2019-04-29 09:21:11 +03:00
|
|
|
gui_mode () {
|
|
|
|
test "$GIT_MERGETOOL_GUI" = true
|
|
|
|
}
|
|
|
|
|
2009-04-08 11:17:20 +04:00
|
|
|
translate_merge_tool_path () {
|
2011-08-18 11:23:46 +04:00
|
|
|
echo "$1"
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
check_unchanged () {
|
2011-08-18 11:23:45 +04:00
|
|
|
if test "$MERGED" -nt "$BACKUP"
|
|
|
|
then
|
2014-11-21 04:20:27 +03:00
|
|
|
return 0
|
2009-04-08 11:17:20 +04:00
|
|
|
else
|
2011-08-18 11:23:45 +04:00
|
|
|
while true
|
|
|
|
do
|
2009-04-08 11:17:20 +04:00
|
|
|
echo "$MERGED seems unchanged."
|
2016-04-12 17:44:20 +03:00
|
|
|
printf "Was the merge successful [y/n]? "
|
2011-09-20 03:40:52 +04:00
|
|
|
read answer || return 1
|
2009-04-08 11:17:20 +04:00
|
|
|
case "$answer" in
|
2014-11-21 04:20:27 +03:00
|
|
|
y*|Y*) return 0 ;;
|
|
|
|
n*|N*) return 1 ;;
|
2009-04-08 11:17:20 +04:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
valid_tool () {
|
2013-01-28 04:52:23 +04:00
|
|
|
setup_tool "$1" && return 0
|
|
|
|
cmd=$(get_merge_tool_cmd "$1")
|
|
|
|
test -n "$cmd"
|
2011-08-18 11:23:46 +04:00
|
|
|
}
|
|
|
|
|
2013-06-16 21:51:22 +04:00
|
|
|
setup_user_tool () {
|
|
|
|
merge_tool_cmd=$(get_merge_tool_cmd "$tool")
|
|
|
|
test -n "$merge_tool_cmd" || return 1
|
|
|
|
|
|
|
|
diff_cmd () {
|
|
|
|
( eval $merge_tool_cmd )
|
|
|
|
}
|
|
|
|
|
|
|
|
merge_cmd () {
|
2016-11-29 12:38:07 +03:00
|
|
|
( eval $merge_tool_cmd )
|
2013-06-16 21:51:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-18 11:23:46 +04:00
|
|
|
setup_tool () {
|
2013-01-27 04:46:12 +04:00
|
|
|
tool="$1"
|
|
|
|
|
2013-07-29 12:18:21 +04:00
|
|
|
# Fallback definitions, to be overridden by tools.
|
2013-01-27 04:46:12 +04:00
|
|
|
can_merge () {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
can_diff () {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
diff_cmd () {
|
2014-11-21 04:20:27 +03:00
|
|
|
return 1
|
2013-01-27 04:46:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
merge_cmd () {
|
2014-11-21 04:20:27 +03:00
|
|
|
return 1
|
2013-01-27 04:46:12 +04:00
|
|
|
}
|
2011-08-18 11:23:46 +04:00
|
|
|
|
2013-01-27 04:46:12 +04:00
|
|
|
translate_merge_tool_path () {
|
|
|
|
echo "$1"
|
|
|
|
}
|
|
|
|
|
2020-07-30 00:31:12 +03:00
|
|
|
list_tool_variants () {
|
|
|
|
echo "$tool"
|
|
|
|
}
|
|
|
|
|
2016-11-29 12:38:07 +03:00
|
|
|
# Most tools' exit codes cannot be trusted, so By default we ignore
|
|
|
|
# their exit code and check the merged file's modification time in
|
|
|
|
# check_unchanged() to determine whether or not the merge was
|
|
|
|
# successful. The return value from run_merge_cmd, by default, is
|
|
|
|
# determined by check_unchanged().
|
|
|
|
#
|
|
|
|
# When a tool's exit code can be trusted then the return value from
|
|
|
|
# run_merge_cmd is simply the tool's exit code, and check_unchanged()
|
|
|
|
# is not called.
|
|
|
|
#
|
|
|
|
# The return value of exit_code_trustable() tells us whether or not we
|
|
|
|
# can trust the tool's exit code.
|
|
|
|
#
|
|
|
|
# User-defined and built-in tools default to false.
|
|
|
|
# Built-in tools advertise that their exit code is trustable by
|
|
|
|
# redefining exit_code_trustable() to true.
|
|
|
|
|
|
|
|
exit_code_trustable () {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2020-07-30 00:31:12 +03:00
|
|
|
if test -f "$MERGE_TOOLS_DIR/$tool"
|
2011-08-18 11:23:46 +04:00
|
|
|
then
|
2020-07-30 00:31:12 +03:00
|
|
|
. "$MERGE_TOOLS_DIR/$tool"
|
|
|
|
elif test -f "$MERGE_TOOLS_DIR/${tool%[0-9]}"
|
|
|
|
then
|
|
|
|
. "$MERGE_TOOLS_DIR/${tool%[0-9]}"
|
|
|
|
else
|
2013-06-16 21:51:22 +04:00
|
|
|
setup_user_tool
|
|
|
|
return $?
|
2011-08-18 11:23:46 +04:00
|
|
|
fi
|
|
|
|
|
2013-06-16 21:51:22 +04:00
|
|
|
# Now let the user override the default command for the tool. If
|
|
|
|
# they have not done so then this will return 1 which we ignore.
|
|
|
|
setup_user_tool
|
2011-08-18 11:23:46 +04:00
|
|
|
|
2020-07-30 00:31:12 +03:00
|
|
|
if ! list_tool_variants | grep -q "^$tool$"
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2011-08-18 11:23:46 +04:00
|
|
|
if merge_mode && ! can_merge
|
|
|
|
then
|
|
|
|
echo "error: '$tool' can not be used to resolve merges" >&2
|
2013-01-27 04:40:06 +04:00
|
|
|
return 1
|
2011-08-18 11:23:46 +04:00
|
|
|
elif diff_mode && ! can_diff
|
|
|
|
then
|
|
|
|
echo "error: '$tool' can only be used to resolve merges" >&2
|
2013-01-27 04:40:06 +04:00
|
|
|
return 1
|
2011-08-18 11:23:46 +04:00
|
|
|
fi
|
|
|
|
return 0
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
get_merge_tool_cmd () {
|
2011-08-18 11:23:46 +04:00
|
|
|
merge_tool="$1"
|
2011-08-18 11:23:45 +04:00
|
|
|
if diff_mode
|
|
|
|
then
|
2013-01-28 04:52:23 +04:00
|
|
|
git config "difftool.$merge_tool.cmd" ||
|
|
|
|
git config "mergetool.$merge_tool.cmd"
|
2009-04-12 07:41:56 +04:00
|
|
|
else
|
2013-01-28 04:52:23 +04:00
|
|
|
git config "mergetool.$merge_tool.cmd"
|
2009-04-12 07:41:56 +04:00
|
|
|
fi
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
|
|
|
|
2016-11-29 12:38:07 +03:00
|
|
|
trust_exit_code () {
|
|
|
|
if git config --bool "mergetool.$1.trustExitCode"
|
|
|
|
then
|
|
|
|
:; # OK
|
|
|
|
elif exit_code_trustable
|
|
|
|
then
|
|
|
|
echo true
|
|
|
|
else
|
|
|
|
echo false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 11:23:46 +04:00
|
|
|
# Entry point for running tools
|
2009-04-08 11:17:20 +04:00
|
|
|
run_merge_tool () {
|
2011-05-26 10:21:01 +04:00
|
|
|
# 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
|
|
|
|
|
2013-01-28 04:52:23 +04:00
|
|
|
merge_tool_path=$(get_merge_tool_path "$1") || exit
|
2009-04-08 11:17:20 +04:00
|
|
|
base_present="$2"
|
|
|
|
|
2011-08-18 11:23:46 +04:00
|
|
|
# Bring tool-specific functions into scope
|
2013-06-16 21:51:22 +04:00
|
|
|
setup_tool "$1" || return 1
|
2011-08-18 11:23:46 +04:00
|
|
|
|
|
|
|
if merge_mode
|
|
|
|
then
|
2012-09-25 11:48:11 +04:00
|
|
|
run_merge_cmd "$1"
|
2011-08-18 11:23:46 +04:00
|
|
|
else
|
2012-09-25 11:48:11 +04:00
|
|
|
run_diff_cmd "$1"
|
2011-08-18 11:23:46 +04:00
|
|
|
fi
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
|
|
|
|
2012-09-25 11:48:11 +04:00
|
|
|
# Run a either a configured or built-in diff tool
|
|
|
|
run_diff_cmd () {
|
2013-06-16 21:51:22 +04:00
|
|
|
diff_cmd "$1"
|
2012-09-25 11:48:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Run a either a configured or built-in merge tool
|
|
|
|
run_merge_cmd () {
|
2016-11-29 12:38:07 +03:00
|
|
|
mergetool_trust_exit_code=$(trust_exit_code "$1")
|
|
|
|
if test "$mergetool_trust_exit_code" = "true"
|
|
|
|
then
|
|
|
|
merge_cmd "$1"
|
|
|
|
else
|
|
|
|
touch "$BACKUP"
|
|
|
|
merge_cmd "$1"
|
|
|
|
check_unchanged
|
|
|
|
fi
|
2012-09-25 11:48:11 +04:00
|
|
|
}
|
|
|
|
|
2012-07-24 01:16:12 +04:00
|
|
|
list_merge_tool_candidates () {
|
2011-08-18 11:23:45 +04:00
|
|
|
if merge_mode
|
|
|
|
then
|
2009-04-08 11:17:20 +04:00
|
|
|
tools="tortoisemerge"
|
|
|
|
else
|
|
|
|
tools="kompare"
|
|
|
|
fi
|
2011-08-18 11:23:45 +04:00
|
|
|
if test -n "$DISPLAY"
|
|
|
|
then
|
|
|
|
if test -n "$GNOME_DESKTOP_SESSION_ID"
|
|
|
|
then
|
2009-04-08 11:17:20 +04:00
|
|
|
tools="meld opendiff kdiff3 tkdiff xxdiff $tools"
|
|
|
|
else
|
|
|
|
tools="opendiff kdiff3 tkdiff xxdiff meld $tools"
|
|
|
|
fi
|
2013-10-13 02:29:35 +04:00
|
|
|
tools="$tools gvimdiff diffuse diffmerge ecmerge"
|
2014-10-21 02:49:36 +04:00
|
|
|
tools="$tools p4merge araxis bc codecompare"
|
2019-04-04 10:34:38 +03:00
|
|
|
tools="$tools smerge"
|
2009-04-08 11:17:20 +04:00
|
|
|
fi
|
2009-11-24 02:29:17 +03:00
|
|
|
case "${VISUAL:-$EDITOR}" in
|
2020-07-30 00:31:13 +03:00
|
|
|
*nvim*)
|
|
|
|
tools="$tools nvimdiff vimdiff emerge"
|
|
|
|
;;
|
2009-11-24 02:29:17 +03:00
|
|
|
*vim*)
|
2020-07-30 00:31:13 +03:00
|
|
|
tools="$tools vimdiff nvimdiff emerge"
|
2009-11-24 02:29:17 +03:00
|
|
|
;;
|
|
|
|
*)
|
2020-07-30 00:31:13 +03:00
|
|
|
tools="$tools emerge vimdiff nvimdiff"
|
2009-11-24 02:29:17 +03:00
|
|
|
;;
|
|
|
|
esac
|
2012-07-24 01:16:12 +04:00
|
|
|
}
|
|
|
|
|
2013-01-25 13:43:48 +04:00
|
|
|
show_tool_help () {
|
2013-10-04 18:34:53 +04:00
|
|
|
tool_opt="'git ${TOOL_MODE}tool --tool=<tool>'"
|
2013-01-25 13:43:54 +04:00
|
|
|
|
2013-01-28 04:52:25 +04:00
|
|
|
tab=' '
|
|
|
|
LF='
|
|
|
|
'
|
|
|
|
any_shown=no
|
2013-01-25 13:43:50 +04:00
|
|
|
|
|
|
|
cmd_name=${TOOL_MODE}tool
|
2013-01-30 23:55:46 +04:00
|
|
|
config_tools=$({
|
|
|
|
diff_mode && list_config_tools difftool "$tab$tab"
|
|
|
|
list_config_tools mergetool "$tab$tab"
|
|
|
|
} | sort)
|
|
|
|
extra_content=
|
|
|
|
if test -n "$config_tools"
|
|
|
|
then
|
|
|
|
extra_content="${tab}user-defined:${LF}$config_tools"
|
|
|
|
fi
|
|
|
|
|
2013-01-28 04:52:25 +04:00
|
|
|
show_tool_names 'mode_ok && is_available' "$tab$tab" \
|
|
|
|
"$tool_opt may be set to one of the following:" \
|
2013-01-30 23:55:46 +04:00
|
|
|
"No suitable tool for 'git $cmd_name --tool=<tool>' found." \
|
|
|
|
"$extra_content" &&
|
2013-01-28 04:52:25 +04:00
|
|
|
any_shown=yes
|
|
|
|
|
|
|
|
show_tool_names 'mode_ok && ! is_available' "$tab$tab" \
|
|
|
|
"${LF}The following tools are valid, but not currently available:" &&
|
|
|
|
any_shown=yes
|
|
|
|
|
|
|
|
if test "$any_shown" = yes
|
2013-01-25 13:43:48 +04:00
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "Some of the tools listed above only work in a windowed"
|
|
|
|
echo "environment. If run in a terminal-only session, they will fail."
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2012-07-24 01:16:12 +04:00
|
|
|
guess_merge_tool () {
|
|
|
|
list_merge_tool_candidates
|
2013-01-28 04:52:24 +04:00
|
|
|
cat >&2 <<-EOF
|
|
|
|
|
|
|
|
This message is displayed because '$TOOL_MODE.tool' is not configured.
|
|
|
|
See 'git ${TOOL_MODE}tool --tool-help' or 'git help config' for more details.
|
|
|
|
'git ${TOOL_MODE}tool' will now attempt to use one of the following tools:
|
|
|
|
$tools
|
|
|
|
EOF
|
2009-04-08 11:17:20 +04:00
|
|
|
|
|
|
|
# Loop over each candidate and stop when a valid merge tool is found.
|
2015-06-19 12:30:55 +03:00
|
|
|
IFS=' '
|
2013-01-28 04:52:25 +04:00
|
|
|
for tool in $tools
|
2009-04-08 11:17:20 +04:00
|
|
|
do
|
2013-01-28 04:52:25 +04:00
|
|
|
is_available "$tool" && echo "$tool" && return 0
|
2009-04-08 11:17:20 +04:00
|
|
|
done
|
|
|
|
|
2013-01-28 04:52:25 +04:00
|
|
|
echo >&2 "No known ${TOOL_MODE} tool is available."
|
2009-04-12 07:41:56 +04:00
|
|
|
return 1
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
get_configured_merge_tool () {
|
2019-04-29 09:21:14 +03:00
|
|
|
keys=
|
2011-08-18 11:23:45 +04:00
|
|
|
if diff_mode
|
|
|
|
then
|
2019-04-29 09:21:14 +03:00
|
|
|
if gui_mode
|
|
|
|
then
|
|
|
|
keys="diff.guitool merge.guitool diff.tool merge.tool"
|
|
|
|
else
|
|
|
|
keys="diff.tool merge.tool"
|
|
|
|
fi
|
2009-04-12 07:41:56 +04:00
|
|
|
else
|
2019-04-29 09:21:14 +03:00
|
|
|
if gui_mode
|
|
|
|
then
|
|
|
|
keys="merge.guitool merge.tool"
|
|
|
|
else
|
|
|
|
keys="merge.tool"
|
|
|
|
fi
|
2009-04-08 11:17:20 +04:00
|
|
|
fi
|
2019-04-29 09:21:14 +03:00
|
|
|
|
|
|
|
merge_tool=$(
|
|
|
|
IFS=' '
|
|
|
|
for key in $keys
|
|
|
|
do
|
|
|
|
selected=$(git config $key)
|
|
|
|
if test -n "$selected"
|
|
|
|
then
|
|
|
|
echo "$selected"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done)
|
|
|
|
|
2011-08-18 11:23:45 +04:00
|
|
|
if test -n "$merge_tool" && ! valid_tool "$merge_tool"
|
|
|
|
then
|
2018-10-24 19:25:31 +03:00
|
|
|
echo >&2 "git config option $TOOL_MODE.${gui_prefix}tool set to unknown tool: $merge_tool"
|
2009-04-08 11:17:20 +04:00
|
|
|
echo >&2 "Resetting to default..."
|
|
|
|
return 1
|
|
|
|
fi
|
2009-04-12 07:41:56 +04:00
|
|
|
echo "$merge_tool"
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
get_merge_tool_path () {
|
|
|
|
# A merge tool has been set, so verify that it's valid.
|
2011-08-18 11:23:46 +04:00
|
|
|
merge_tool="$1"
|
2011-08-18 11:23:45 +04:00
|
|
|
if ! valid_tool "$merge_tool"
|
|
|
|
then
|
2009-04-08 11:17:20 +04:00
|
|
|
echo >&2 "Unknown merge tool $merge_tool"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-08-18 11:23:45 +04:00
|
|
|
if diff_mode
|
|
|
|
then
|
2009-04-12 07:41:56 +04:00
|
|
|
merge_tool_path=$(git config difftool."$merge_tool".path ||
|
2011-08-05 17:31:29 +04:00
|
|
|
git config mergetool."$merge_tool".path)
|
2009-04-12 07:41:56 +04:00
|
|
|
else
|
|
|
|
merge_tool_path=$(git config mergetool."$merge_tool".path)
|
2009-04-08 11:17:20 +04:00
|
|
|
fi
|
2011-08-18 11:23:45 +04:00
|
|
|
if test -z "$merge_tool_path"
|
|
|
|
then
|
2013-01-28 04:52:23 +04:00
|
|
|
merge_tool_path=$(translate_merge_tool_path "$merge_tool")
|
2009-04-08 11:17:20 +04:00
|
|
|
fi
|
2009-04-12 07:41:56 +04:00
|
|
|
if test -z "$(get_merge_tool_cmd "$merge_tool")" &&
|
2011-08-18 11:23:45 +04:00
|
|
|
! type "$merge_tool_path" >/dev/null 2>&1
|
|
|
|
then
|
2009-04-12 07:41:56 +04:00
|
|
|
echo >&2 "The $TOOL_MODE tool $merge_tool is not available as"\
|
2011-08-05 17:31:29 +04:00
|
|
|
"'$merge_tool_path'"
|
2009-04-08 11:17:20 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$merge_tool_path"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_merge_tool () {
|
2019-04-29 09:21:08 +03:00
|
|
|
is_guessed=false
|
2009-04-08 11:17:20 +04:00
|
|
|
# Check if a merge tool has been configured
|
2013-01-28 04:52:23 +04:00
|
|
|
merge_tool=$(get_configured_merge_tool)
|
2009-04-08 11:17:20 +04:00
|
|
|
# Try to guess an appropriate merge tool if no tool has been set.
|
2011-08-18 11:23:45 +04:00
|
|
|
if test -z "$merge_tool"
|
|
|
|
then
|
2013-01-28 04:52:23 +04:00
|
|
|
merge_tool=$(guess_merge_tool) || exit
|
2019-04-29 09:21:08 +03:00
|
|
|
is_guessed=true
|
2009-04-08 11:17:20 +04:00
|
|
|
fi
|
|
|
|
echo "$merge_tool"
|
2019-04-29 09:21:08 +03:00
|
|
|
test "$is_guessed" = false
|
2009-04-08 11:17:20 +04:00
|
|
|
}
|
2016-03-26 02:17:56 +03:00
|
|
|
|
|
|
|
mergetool_find_win32_cmd () {
|
|
|
|
executable=$1
|
|
|
|
sub_directory=$2
|
|
|
|
|
|
|
|
# Use $executable if it exists in $PATH
|
|
|
|
if type -p "$executable" >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
printf '%s' "$executable"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Look for executable in the typical locations
|
|
|
|
for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
|
|
|
|
cut -d '=' -f 2- | sort -u)
|
|
|
|
do
|
|
|
|
if test -n "$directory" && test -x "$directory/$sub_directory/$executable"
|
|
|
|
then
|
|
|
|
printf '%s' "$directory/$sub_directory/$executable"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
printf '%s' "$executable"
|
|
|
|
}
|