Merge branch 'dl/mergetool-gui-option'
authorJunio C Hamano <gitster@pobox.com>
Tue, 30 Oct 2018 06:43:48 +0000 (15:43 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Oct 2018 06:43:49 +0000 (15:43 +0900)
"git mergetool" learned to take the "--[no-]gui" option, just like
"git difftool" does.

* dl/mergetool-gui-option:
doc: document diff/merge.guitool config keys
completion: support `git mergetool --[no-]gui`
mergetool: accept -g/--[no-]gui as arguments

Documentation/diff-config.txt
Documentation/git-mergetool.txt
Documentation/merge-config.txt
contrib/completion/git-completion.bash
git-mergetool--lib.sh
git-mergetool.sh
index 85bca83c304c6d95422482b9bc7b8d983bfdc85e..e64d983c344656dd00d869005563a1a20efce854 100644 (file)
@@ -177,6 +177,14 @@ diff.tool::
        Any other value is treated as a custom diff tool and requires
        that a corresponding difftool.<tool>.cmd variable is defined.
 
+diff.guitool::
+       Controls which diff tool is used by linkgit:git-difftool[1] when
+       the -g/--gui flag is specified. This variable overrides the value
+       configured in `merge.guitool`. The list below shows the valid
+       built-in values. Any other value is treated as a custom diff tool
+       and requires that a corresponding difftool.<guitool>.cmd variable
+       is defined.
+
 include::mergetools-diff.txt[]
 
 diff.indentHeuristic::
index 3622d66488c7de057d32e02cd4cfd21704500822..0c7975a0507a35f9624516f0844ad11cd5141d50 100644 (file)
@@ -79,6 +79,17 @@ success of the resolution after the custom tool has exited.
        Prompt before each invocation of the merge resolution program
        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>::
        Process files in the order specified in the
        <orderfile>, which has one shell glob pattern per line.
index 662c2713cab4b9762dded702897d9e92ee0a0549..a7f4ea90c11ff6092e77057bd5bee241499cf40f 100644 (file)
@@ -63,6 +63,12 @@ merge.tool::
        Any other value is treated as a custom merge tool and requires
        that a corresponding mergetool.<tool>.cmd variable is defined.
 
+merge.guitool::
+       Controls which merge tool is used by linkgit:git-mergetool[1] when the
+       -g/--gui flag is specified. The list below shows the valid built-in values.
+       Any other value is treated as a custom merge tool and requires that a
+       corresponding mergetool.<guitool>.cmd variable is defined.
+
 include::mergetools-merge.txt[]
 
 merge.verbosity::
index 5f556075d3cbce74c60e81b97d4923a1ff18f78d..86b8f474c8d5af0e5a948b835ba104fd963cbff5 100644 (file)
@@ -1822,7 +1822,7 @@ _git_mergetool ()
                return
                ;;
        --*)
-               __gitcomp "--tool= --prompt --no-prompt"
+               __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
                return
                ;;
        esac
index 9a8b97a2aba9aa9fabb095558c03cb8f27df3d50..83bf52494cd26437eaa3c755c3359951937f1ab2 100644 (file)
@@ -350,17 +350,23 @@ guess_merge_tool () {
 }
 
 get_configured_merge_tool () {
-       # Diff mode first tries diff.tool and falls back to merge.tool.
-       # Merge mode only checks 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
        if diff_mode
        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
-               merge_tool=$(git config merge.tool)
+               merge_tool=$(git config merge.${gui_prefix}tool)
        fi
        if test -n "$merge_tool" && ! valid_tool "$merge_tool"
        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..."
                return 1
        fi
index d07c7f387cf478bbd93d1dada1afa1de80db0fbf..01b9ad59b24ff77221d5db4118c9d0265dc25fad 100755 (executable)
@@ -9,7 +9,7 @@
 # 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
 NONGIT_OK=Yes
 OPTIONS_SPEC=
@@ -389,6 +389,7 @@ print_noop_and_exit () {
 
 main () {
        prompt=$(git config --bool mergetool.prompt)
+       gui_tool=false
        guessed_merge_tool=false
        orderfile=
 
@@ -414,6 +415,12 @@ main () {
                                shift ;;
                        esac
                        ;;
+               --no-gui)
+                       gui_tool=false
+                       ;;
+               -g|--gui)
+                       gui_tool=true
+                       ;;
                -y|--no-prompt)
                        prompt=false
                        ;;
@@ -443,7 +450,7 @@ main () {
        if test -z "$merge_tool"
        then
                # 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.
                if test -z "$merge_tool"
                then