git/mergetools/meld
David Aguilar b12d04503b mergetools/meld: make usage of --output configurable and more robust
Older versions of meld listed --output in `meld --help`.
Newer versions only mention `meld [OPTIONS...]`.
Improve the checks to catch these newer versions.

Add a `mergetool.meld.hasOutput` configuration to allow
overriding the heuristic.

Reported-by: Andrey Novoseltsev <novoselt@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-10-16 11:58:11 -07:00

38 lines
876 B
Plaintext

diff_cmd () {
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
merge_cmd () {
if test -z "${meld_has_output_option:+set}"
then
check_meld_for_output_version
fi
touch "$BACKUP"
if test "$meld_has_output_option" = true
then
"$merge_tool_path" --output "$MERGED" \
"$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
fi
check_unchanged
}
# Check whether we should use 'meld --output <file>'
check_meld_for_output_version () {
meld_path="$(git config mergetool.meld.path)"
meld_path="${meld_path:-meld}"
if meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)
then
: use configured value
elif "$meld_path" --help 2>&1 |
grep -e '--output=' -e '\[OPTION\.\.\.\]' >/dev/null
then
: old ones mention --output and new ones just say OPTION...
meld_has_output_option=true
else
meld_has_output_option=false
fi
}