Skip to content

Commit 66b1160

Browse files
committed
Merge branch 'km/mergetool-vimdiff-layout-fallback'
Variants of vimdiff learned to honor mergetool.<variant>.layout settings. * km/mergetool-vimdiff-layout-fallback: mergetools: vimdiff: use correct tool's name when reading mergetool config
2 parents 03f9f1a + b21d164 commit 66b1160

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

Documentation/config/mergetool.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,21 @@ mergetool.meld.useAutoMerge::
4545
value of `false` avoids using `--auto-merge` altogether, and is the
4646
default value.
4747

48-
mergetool.vimdiff.layout::
49-
The vimdiff backend uses this variable to control how its split
50-
windows appear. Applies even if you are using Neovim (`nvim`) or
51-
gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section
48+
mergetool.<vimdiff variant>.layout::
49+
Configure the split window layout for vimdiff's `<variant>`, which is any of `vimdiff`,
50+
`nvimdiff`, `gvimdiff`.
51+
Upon launching `git mergetool` with `--tool=<variant>` (or without `--tool`
52+
if `merge.tool` is configured as `<variant>`), Git will consult
53+
`mergetool.<variant>.layout` to determine the tool's layout. If the
54+
variant-specific configuration is not available, `vimdiff`'s is used as
55+
fallback. If that too is not available, a default layout with 4 windows
56+
will be used. To configure the layout, see the `BACKEND SPECIFIC HINTS`
57+
ifdef::git-mergetool[]
58+
section.
59+
endif::[]
5260
ifndef::git-mergetool[]
53-
in linkgit:git-mergetool[1].
61+
section in linkgit:git-mergetool[1].
5462
endif::[]
55-
for details.
5663

5764
mergetool.hideResolved::
5865
During a merge, Git will automatically resolve as many conflicts as

Documentation/mergetools/vimdiff.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ Instead of `--tool=vimdiff`, you can also use one of these other variants:
177177

178178
When using these variants, in order to specify a custom layout you will have to
179179
set configuration variables `mergetool.gvimdiff.layout` and
180-
`mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout`
180+
`mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout` (though the
181+
latter will be used as fallback if the variant-specific one is not set).
181182

182183
In addition, for backwards compatibility with previous Git versions, you can
183184
also append `1`, `2` or `3` to either `vimdiff` or any of the variants (ex:

mergetools/vimdiff

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,17 @@ diff_cmd_help () {
371371

372372

373373
merge_cmd () {
374-
layout=$(git config mergetool.vimdiff.layout)
374+
TOOL=$1
375375

376-
case "$1" in
376+
layout=$(git config "mergetool.$TOOL.layout")
377+
378+
# backward compatibility:
379+
if test -z "$layout"
380+
then
381+
layout=$(git config mergetool.vimdiff.layout)
382+
fi
383+
384+
case "$TOOL" in
377385
*vimdiff)
378386
if test -z "$layout"
379387
then

0 commit comments

Comments
 (0)