* fix the discrepancy between difftool and mergetool where
  the former has the --gui flag and the latter does not by adding the
  functionality to mergetool

* make difftool read 'merge.guitool' as a fallback, in accordance to the
  manpage for difftool: "git difftool falls back to git mergetool
  config variables when the difftool equivalents have not been defined"

* add guitool-related completions

Signed-off-by: Denton Liu <liu.den...@gmail.com>
---
 Documentation/git-difftool.txt         | 3 ++-
 Documentation/git-mergetool.txt        | 8 +++++++-
 contrib/completion/git-completion.bash | 6 ++++--
 git-mergetool.sh                       | 5 ++++-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 224fb3090..0b5d29237 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -89,7 +89,8 @@ instead.  `--no-symlinks` is the default on Windows.
 --gui::
        When 'git-difftool' is invoked with the `-g` or `--gui` option
        the default diff tool will be read from the configured
-       `diff.guitool` variable instead of `diff.tool`.
+       `diff.guitool` variable instead of `diff.tool`. If `diff.guitool`
+       is not defined, it will try and read from `merge.guitool`.
 
 --[no-]trust-exit-code::
        'git-difftool' invokes a diff tool individually on each file.
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 3622d6648..2ab56efcf 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -8,7 +8,7 @@ git-mergetool - Run merge conflict resolution tools to resolve 
merge conflicts
 SYNOPSIS
 --------
 [verse]
-'git mergetool' [--tool=<tool>] [-y | --[no-]prompt] [<file>...]
+'git mergetool' [--tool=<tool>] [-g|--gui] [-y | --[no-]prompt] [<file>...]
 
 DESCRIPTION
 -----------
@@ -64,6 +64,12 @@ variable `mergetool.<tool>.trustExitCode` can be set to 
`true`.
 Otherwise, 'git mergetool' will prompt the user to indicate the
 success of the resolution after the custom tool has exited.
 
+-g::
+--gui::
+       When 'git-mergetool' is invoked with the `-g` or `--gui` option
+       the default diff tool will be read from the configured
+       `merge.guitool` variable instead of `merge.tool`.
+
 --tool-help::
        Print a list of merge tools that may be used with `--tool`.
 
diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 21016bf8d..8a7427f3c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1268,7 +1268,7 @@ _git_difftool ()
                        --base --ours --theirs
                        --no-renames --diff-filter= --find-copies-harder
                        --relative --ignore-submodules
-                       --tool="
+                       --tool= --gui"
                return
                ;;
        esac
@@ -1566,7 +1566,7 @@ _git_mergetool ()
                return
                ;;
        --*)
-               __gitcomp "--tool="
+               __gitcomp "--tool= --gui"
                return
                ;;
        esac
@@ -2189,6 +2189,7 @@ _git_config ()
                diff.submodule
                diff.suppressBlankEmpty
                diff.tool
+               diff.guitool
                diff.wordRegex
                diff.algorithm
                difftool.
@@ -2290,6 +2291,7 @@ _git_config ()
                merge.renormalize
                merge.stat
                merge.tool
+               merge.guitool
                merge.verbosity
                mergetool.
                mergetool.keepBackup
diff --git a/git-mergetool.sh b/git-mergetool.sh
index e52b4e4f2..a17668752 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -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] [-g|--gui] [--tool-help] [-y|--no-prompt|--prompt] 
[-O<orderfile>] [file to merge] ...'
 SUBDIRECTORY_OK=Yes
 NONGIT_OK=Yes
 OPTIONS_SPEC=
@@ -414,6 +414,9 @@ main () {
                                shift ;;
                        esac
                        ;;
+               -g|--gui)
+                       merge_tool=$(git config merge.guitool)
+                       ;;
                -y|--no-prompt)
                        prompt=false
                        ;;
-- 
2.11.0.21.ga274e0a.dirty

Reply via email to