From: Junio C Hamano <gitster@pobox.com>
To: Kipras Melnikovas <kipras@kipras.org>
Cc: git@vger.kernel.org, greenfoo@u92.eu
Subject: Re: [PATCH v2] mergetools: vimdiff: use correct tool's name when reading mergetool config
Date: Thu, 15 Feb 2024 10:42:49 -0800 [thread overview]
Message-ID: <xmqq8r3lr2l2.fsf@gitster.g> (raw)
In-Reply-To: <20240215142002.36870-1-kipras@kipras.org> (Kipras Melnikovas's message of "Thu, 15 Feb 2024 16:20:02 +0200")
Kipras Melnikovas <kipras@kipras.org> writes:
> Though, for backwards-compatibility, I've kept the mergetool.vimdiff
> fallback, so that people who unknowingly relied on it, won't have their
> setup broken now.
It is a good consideration, and should be documented ...
> diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt
> index 294f61efd1..8e3d321a57 100644
> --- a/Documentation/config/mergetool.txt
> +++ b/Documentation/config/mergetool.txt
> @@ -45,10 +45,11 @@ mergetool.meld.useAutoMerge::
> value of `false` avoids using `--auto-merge` altogether, and is the
> default value.
>
> -mergetool.vimdiff.layout::
> - The vimdiff backend uses this variable to control how its split
> - windows appear. Applies even if you are using Neovim (`nvim`) or
> - gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section
> +mergetool.{g,n,}vimdiff.layout::
> + The vimdiff backend uses this variable to control how its split windows
> + appear. Use `mergetool.vimdiff` for regular Vim, `mergetool.nvimdiff` for
> + Neovim and `mergetool.gvimdiff` for gVim to configure the merge tool. See
> + BACKEND SPECIFIC HINTS section
... perhaps before "See BACKEND SPECIFIC HINTS section." E.g.
When a variant of vimdiff (vim, Neovim, or gVim) is used as
a mergetool backend, they use this variable to control how
the split windows appear.
The variable `mergetool.<variant>.layout` (where <variant>
is one of `vimdiff`, `nvimdiff`, or `gvimdiff`, depending on
what you are using) is consulted first, and if it is missing,
`mergetool.vimdiff.layout` is used as a fallback. See
BACKEND SPECIFIC HINTS section.
or something?
> diff --git a/mergetools/vimdiff b/mergetools/vimdiff
> index 06937acbf5..0e3058868a 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)
The callers of merge_cmd are careful to do
merge_cmd "$1"
so it would be a good hygiene to also quote $TOOL here, i.e.
layout=$(git config "mergetool.$TOOL.layout")
It might not matter if the caller of run_merge_cmd (which calls
merge_cmd) eventually chooses from a known set of strings hardcoded
in mergetools--lib.sh, but it is much easier to show that you are
doing the right thing without relying on such a detail of what
happens far in the code to quote what you get from the caller
appropriately.
> +
> + # backwards-compatibility:
> + if test -z "$layout"
> + then
> + layout=$(git config mergetool.vimdiff.layout)
> + fi
> +
> + case "$TOOL" in
This one is quoted properly (and TOOL=$1 at the beginning does not
require quoting). The "git config" call above is the only one that
needs to be fixed.
Thanks.
> *vimdiff)
> if test -z "$layout"
> then
>
> base-commit: 4fc51f00ef18d2c0174ab2fd39d0ee473fd144bd
next prev parent reply other threads:[~2024-02-15 18:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 8:39 [PATCH] mergetools: vimdiff: use correct tool's name when reading mergetool config Kipras Melnikovas
2024-02-15 14:20 ` [PATCH v2] " Kipras Melnikovas
2024-02-15 18:42 ` Junio C Hamano [this message]
2024-02-15 20:43 ` Fernando Ramos
2024-02-17 7:43 ` [PATCH v3] " Kipras Melnikovas
2024-02-17 16:27 ` [PATCH v4] " Kipras Melnikovas
2024-02-20 2:52 ` Junio C Hamano
2024-02-21 5:20 ` Kipras Melnikovas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq8r3lr2l2.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=greenfoo@u92.eu \
--cc=kipras@kipras.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).