From: Eric Sunshine <sunshine@sunshineco.com>
To: Tao Klerks via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Tao Klerks <tao@klerks.biz>
Subject: Re: [PATCH v2] RFC: mergetool: new config guiDefault supports auto-toggling gui by DISPLAY
Date: Fri, 14 Oct 2022 04:24:16 -0400 [thread overview]
Message-ID: <CAPig+cSPWsiKBU6hgvP_BO7n23nLf7Q-59ZbO4fSL0idcw2qzA@mail.gmail.com> (raw)
In-Reply-To: <pull.1381.v2.git.1665734440009.gitgitgadget@gmail.com>
"On Fri, Oct 14, 2022 at 4:07 AM Tao Klerks via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> [...]
> As proposed in <xmqqmtb8jsej.fsf@gitster.g>, introduce new configuration
> options, difftool.guiDefault and mergetool.guiDefault, supporting a special
> value "auto" which causes the corresponding tool or guitool to be selected
> depending on the presence of a non-empty DISPLAY value. Also support "true"
> to say "default to the guitool (unless --no-gui is passed on the
> commandline)", and "false" as the previous default behavior when these new
> configuration options are not specified.
>
> Signed-off-by: Tao Klerks <tao@klerks.biz>
> ---
> diff --git a/Documentation/config/difftool.txt b/Documentation/config/difftool.txt
> @@ -34,3 +34,10 @@ See the `--trust-exit-code` option in linkgit:git-difftool[1] for more details.
> +difftool.guiDefault::
> + Set 'true' to use the diff.guitool by default (equivalent to specifying
> + the "--gui" argument), or "auto" to select diff.guitool or diff.tool
> + depending on the presence of a DISPLAY environment variable value. The
> + default is 'false', where the "--gui" argument must be provided
> + explicitly for the diff.guitool to be used.
Let's use backticks rather than double-quotes to ensure that these get
typeset similar to other documentation; i.e. `--gui`, `auto`,
`diff.guitool`, `diff.tool`, `DISPLAY`.
> diff --git a/Documentation/config/mergetool.txt b/Documentation/config/mergetool.txt
> @@ -85,3 +85,10 @@ mergetool.writeToTemp::
> +mergetool.guiDefault::
> + Set 'true' to use the merge.guitool by default (equivalent to
> + specifying the "--gui" argument), or "auto" to select merge.guitool
> + or merge.tool depending on the presence of a DISPLAY environment
> + variable value. The default is 'false', where the "--gui" argument
> + must be provided explicitly for the merge.guitool to be used.
Ditto.
> diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
> @@ -97,10 +97,12 @@ instead. `--no-symlinks` is the default on Windows.
> --[no-]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`. This may be
> + autoselected using the configuration variable
> + `difftool.guiDefault`. The `--no-gui` option can be used to
> + override these settings. If `diff.guitool` is not set, we will
> + fallback in the order of `merge.guitool`, `diff.tool`,
> + `merge.tool` until a tool is found.
Correct use of backticks here. Good.
Probably want: s/autoselected/auto-selected/ or /.../selected automatically/
> diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
> @@ -85,12 +85,13 @@ success of the resolution after the custom tool has exited.
> + configured under `merge.tool`. This may be autoselected using
> + the configuration variable `mergetool.guiDefault`.
Ditto: "autoselected"
> --no-gui::
> + This overrides a previous `-g` or `--gui` setting or
> + `mergetool.guiDefault` configuration and reads the default merge
> + tool from the configured `merge.tool` variable.
Backticks; good.
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> @@ -97,7 +97,33 @@ merge_mode () {
> +get_gui_default () {
> + if diff_mode
> + then
> + GUI_DEFAULT_KEY="difftool.guiDefault"
> + else
> + GUI_DEFAULT_KEY="mergetool.guiDefault"
> + fi
> + GUI_DEFAULT_CONFIG_LCASE=$(git config --default false --get $GUI_DEFAULT_KEY | tr 'A-Z' 'a-z')
Too many spaces before pipe symbol.
Nit: It doesn't matter in this case, but you could safeguard against
(possible?) future problems by using double-quotes in `--get
"$GUI_DEFAULT_KEY"`.
> + if test "$GUI_DEFAULT_CONFIG_LCASE" = "auto"
> + then
> + if test -n "$DISPLAY"
> + then
> + GUI_DEFAULT=true
> + else
> + GUI_DEFAULT=false
> + fi
> + else
> + GUI_DEFAULT=$(git config --default false --bool --get $GUI_DEFAULT_KEY)
Ditto: `--get "$GUI_DEFAULT_KEY"`
> + fi
> + echo $GUI_DEFAULT
> +}
> +
> gui_mode () {
> + if [ -z "$GIT_MERGETOOL_GUI" ]
Style: if test -z "$GIT_MERGETOOL_GUI"
> + then
> + GIT_MERGETOOL_GUI=$(get_gui_default)
> + fi
> test "$GIT_MERGETOOL_GUI" = true
> }
>
> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
> @@ -860,4 +860,43 @@ test_expect_success 'mergetool hideResolved' '
> +test_expect_success 'mergetool with guiDefault' '
> + test_config mergetool.guiDefault true &&
> + yes "" | git mergetool subdir/file3 &&
> +
> + yes "d" | git mergetool file11 &&
> + yes "d" | git mergetool file12 &&
> + yes "l" | git mergetool submod &&
> +
> +
> + echo "gui main updated" >expect &&
> + test_cmp expect file1 &&
Accidental double-spacing?
next prev parent reply other threads:[~2022-10-14 8:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 15:59 [PATCH] mergetool: new config guiDefault supports auto-toggling gui by DISPLAY Tao Klerks via GitGitGadget
2022-10-12 16:08 ` Tao Klerks
2022-10-12 18:12 ` Junio C Hamano
2022-10-13 6:49 ` Tao Klerks
2022-10-13 21:58 ` Junio C Hamano
2022-10-14 4:53 ` Tao Klerks
2022-10-14 9:10 ` Junio C Hamano
2022-10-14 12:32 ` Tao Klerks
2022-10-14 15:37 ` Junio C Hamano
2022-10-16 20:07 ` Tao Klerks
2022-10-14 8:00 ` [PATCH v2] RFC: " Tao Klerks via GitGitGadget
2022-10-14 8:24 ` Eric Sunshine [this message]
2022-10-14 9:11 ` Tao Klerks
2022-10-14 15:45 ` Junio C Hamano
2022-10-16 20:19 ` Tao Klerks
2022-10-17 5:50 ` Junio C Hamano
2022-10-18 6:54 ` [PATCH v3] " Tao Klerks via GitGitGadget
2023-02-17 10:59 ` Tao Klerks
2023-03-18 15:27 ` [PATCH v4] " Tao Klerks via GitGitGadget
2023-04-04 9:46 ` David Aguilar
2023-04-04 14:50 ` Tao Klerks
2023-04-04 20:35 ` Junio C Hamano
2023-04-06 3:33 ` David Aguilar
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPig+cSPWsiKBU6hgvP_BO7n23nLf7Q-59ZbO4fSL0idcw2qzA@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=tao@klerks.biz \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).