mergetool: accept -g/--[no-]gui as arguments
In line with how difftool accepts a -g/--[no-]gui option, make mergetool accept the same option in order to use the `merge.guitool` variable to find the default mergetool instead of `merge.tool`. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Anmol Mago <anmolmago@gmail.com> Signed-off-by: Brian Ho <briankyho@gmail.com> Signed-off-by: David Lu <david.lu97@outlook.com> Signed-off-by: Ryan Wang <shirui.wang@hotmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c4df23f792
commit
063f2bdbf7
@ -79,6 +79,17 @@ success of the resolution after the custom tool has exited.
|
|||||||
Prompt before each invocation of the merge resolution program
|
Prompt before each invocation of the merge resolution program
|
||||||
to give the user a chance to skip the path.
|
to give the user a chance to skip the path.
|
||||||
|
|
||||||
|
-g::
|
||||||
|
--gui::
|
||||||
|
When 'git-mergetool' is invoked with the `-g` or `--gui` option
|
||||||
|
the default merge tool will be read from the configured
|
||||||
|
`merge.guitool` variable instead of `merge.tool`.
|
||||||
|
|
||||||
|
--no-gui::
|
||||||
|
This overrides a previous `-g` or `--gui` setting and reads the
|
||||||
|
default merge tool will be read from the configured `merge.tool`
|
||||||
|
variable.
|
||||||
|
|
||||||
-O<orderfile>::
|
-O<orderfile>::
|
||||||
Process files in the order specified in the
|
Process files in the order specified in the
|
||||||
<orderfile>, which has one shell glob pattern per line.
|
<orderfile>, which has one shell glob pattern per line.
|
||||||
|
@ -350,17 +350,23 @@ guess_merge_tool () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_configured_merge_tool () {
|
get_configured_merge_tool () {
|
||||||
# Diff mode first tries diff.tool and falls back to merge.tool.
|
# If first argument is true, find the guitool instead
|
||||||
# Merge mode only checks merge.tool
|
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
|
||||||
if diff_mode
|
if diff_mode
|
||||||
then
|
then
|
||||||
merge_tool=$(git config diff.tool || git config merge.tool)
|
merge_tool=$(git config diff.${gui_prefix}tool || git config merge.${gui_prefix}tool)
|
||||||
else
|
else
|
||||||
merge_tool=$(git config merge.tool)
|
merge_tool=$(git config merge.${gui_prefix}tool)
|
||||||
fi
|
fi
|
||||||
if test -n "$merge_tool" && ! valid_tool "$merge_tool"
|
if test -n "$merge_tool" && ! valid_tool "$merge_tool"
|
||||||
then
|
then
|
||||||
echo >&2 "git config option $TOOL_MODE.tool set to unknown tool: $merge_tool"
|
echo >&2 "git config option $TOOL_MODE.${gui_prefix}tool set to unknown tool: $merge_tool"
|
||||||
echo >&2 "Resetting to default..."
|
echo >&2 "Resetting to default..."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
# at the discretion of Junio C Hamano.
|
# at the discretion of Junio C Hamano.
|
||||||
#
|
#
|
||||||
|
|
||||||
USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O<orderfile>] [file to merge] ...'
|
USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-g|--gui|--no-gui] [-O<orderfile>] [file to merge] ...'
|
||||||
SUBDIRECTORY_OK=Yes
|
SUBDIRECTORY_OK=Yes
|
||||||
NONGIT_OK=Yes
|
NONGIT_OK=Yes
|
||||||
OPTIONS_SPEC=
|
OPTIONS_SPEC=
|
||||||
@ -389,6 +389,7 @@ print_noop_and_exit () {
|
|||||||
|
|
||||||
main () {
|
main () {
|
||||||
prompt=$(git config --bool mergetool.prompt)
|
prompt=$(git config --bool mergetool.prompt)
|
||||||
|
gui_tool=false
|
||||||
guessed_merge_tool=false
|
guessed_merge_tool=false
|
||||||
orderfile=
|
orderfile=
|
||||||
|
|
||||||
@ -414,6 +415,12 @@ main () {
|
|||||||
shift ;;
|
shift ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
--no-gui)
|
||||||
|
gui_tool=false
|
||||||
|
;;
|
||||||
|
-g|--gui)
|
||||||
|
gui_tool=true
|
||||||
|
;;
|
||||||
-y|--no-prompt)
|
-y|--no-prompt)
|
||||||
prompt=false
|
prompt=false
|
||||||
;;
|
;;
|
||||||
@ -443,7 +450,7 @@ main () {
|
|||||||
if test -z "$merge_tool"
|
if test -z "$merge_tool"
|
||||||
then
|
then
|
||||||
# Check if a merge tool has been configured
|
# Check if a merge tool has been configured
|
||||||
merge_tool=$(get_configured_merge_tool)
|
merge_tool=$(get_configured_merge_tool $gui_tool)
|
||||||
# Try to guess an appropriate merge tool if no tool has been set.
|
# Try to guess an appropriate merge tool if no tool has been set.
|
||||||
if test -z "$merge_tool"
|
if test -z "$merge_tool"
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user