git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] RFC: mergetool: new config guiDefault supports auto-toggling gui by DISPLAY

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Oct 14, 2022, 08:24 UTC
Message-ID
<CAPig+cSPWsiKBU6hgvP_BO7n23nLf7Q-59ZbO4fSL0idcw2qzA@mail.gmail.com>
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:

Show 19 quoted lines
> [...]
> 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`.

Show 8 quoted lines
> 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.
Show 11 quoted lines
> 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.
Show 10 quoted lines
> 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"`.
Show 10 quoted lines
> +       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"`
Show 6 quoted lines
> +       fi
> +       echo $GUI_DEFAULT
> +}
> +
>  gui_mode () {
> +       if [ -z "$GIT_MERGETOOL_GUI" ]
Style: if test -z "$GIT_MERGETOOL_GUI"
Show 19 quoted lines
> +       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?
Previous: Tao Klerks via GitGitGadgetNext: Tao Klerks
Message 12 of 23 in “mergetool: new config guiDefault supports auto-toggling gui by DISPLAY”
  1. mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Oct 12, 2022
  2. Tao KlerksOct 12, 2022
  3. Junio C HamanoOct 12, 2022
  4. Tao KlerksOct 13, 2022
  5. Junio C HamanoOct 13, 2022
  6. Tao KlerksOct 14, 2022
  7. Junio C HamanoOct 14, 2022
  8. Tao KlerksOct 14, 2022
  9. Junio C HamanoOct 14, 2022
  10. Tao KlerksOct 16, 2022
  11. RFC: mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Oct 14, 2022
  12. Eric SunshineOct 14, 2022
  13. Tao KlerksOct 14, 2022
  14. Junio C HamanoOct 14, 2022
  15. Tao KlerksOct 16, 2022
  16. Junio C HamanoOct 17, 2022
  17. RFC: mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Oct 18, 2022
  18. Tao KlerksFeb 17, 2023
  19. mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks via GitGitGadget, Mar 18, 2023
  20. David AguilarApr 4, 2023
  21. Tao KlerksApr 4, 2023
  22. Junio C HamanoApr 4, 2023
  23. David AguilarApr 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.