aboutsummaryrefslogtreecommitdiffstats
path: root/mergetools
diff options
context:
space:
mode:
authorKipras Melnikovas <kipras@kipras.org>2024-02-17 18:27:18 +0200
committerJunio C Hamano <gitster@pobox.com>2024-02-19 08:45:14 -0800
commitb21d164275b9186421ebe39498be47ea9f171694 (patch)
tree8505fb1ed296f54f994fff9ba6f6abd7149d40a6 /mergetools
parent96c8a0712e569dd2812bf4fb5e72113caf326500 (diff)
downloadgit-b21d164275b9186421ebe39498be47ea9f171694.tar.gz
mergetools: vimdiff: use correct tool's name when reading mergetool config
The /mergetools/vimdiff script, which handles both vimdiff, nvimdiff and gvimdiff mergetools (the latter 2 simply source the vimdiff script), has a function merge_cmd() which read the layout variable from git config, and it would always read the value of mergetool.**vimdiff**.layout, instead of the mergetool being currently used (vimdiff or nvimdiff or gvimdiff). It looks like in 7b5cf8be18 (vimdiff: add tool documentation, 2022-03-30), we explained the current behavior in Documentation/config/mergetool.txt: ``` mergetool.vimdiff.layout:: The vimdiff backend uses this variable to control how its split windows look like. Applies even if you are using Neovim (`nvim`) or gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section ``` which makes sense why it's explained this way - the vimdiff backend is used by gvim and nvim. But the mergetool's configuration should be separate for each tool, and indeed that's confirmed in same commit at Documentation/mergetools/vimdiff.txt: ``` Variants Instead of `--tool=vimdiff`, you can also use one of these other variants: * `--tool=gvimdiff`, to open gVim instead of Vim. * `--tool=nvimdiff`, to open Neovim instead of Vim. When using these variants, in order to specify a custom layout you will have to set configuration variables `mergetool.gvimdiff.layout` and `mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout` ``` So it looks like we just forgot to update the 1 part of the vimdiff script that read the config variable. Cheers. Though, for backward compatibility, I've kept the mergetool.vimdiff fallback, so that people who unknowingly relied on it, won't have their setup broken now. Signed-off-by: Kipras Melnikovas <kipras@kipras.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mergetools')
-rw-r--r--mergetools/vimdiff12
1 files changed, 10 insertions, 2 deletions
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 06937acbf5..97e376329b 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -371,9 +371,17 @@ diff_cmd_help () {
merge_cmd () {
- layout=$(git config mergetool.vimdiff.layout)
+ TOOL=$1
- case "$1" in
+ layout=$(git config "mergetool.$TOOL.layout")
+
+ # backward compatibility:
+ if test -z "$layout"
+ then
+ layout=$(git config mergetool.vimdiff.layout)
+ fi
+
+ case "$TOOL" in
*vimdiff)
if test -z "$layout"
then