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

AW: [PATCH v5] git gui: add directly calling merge tool from configuration

From
tobias.boesch@miele.com <tobias.boesch@miele.com>
Date
Sep 16, 2024, 08:42 UTC
Message-ID
<AS2PR08MB8288A8DC805BF4FFB67B1709E1602@AS2PR08MB8288.eurprd08.prod.outlook.com>
In-Reply-To
<2ee3a148-23eb-48cb-8e10-551437fb03d3@kdbg.org>
Show 72 quoted lines
> -----Ursprüngliche Nachricht-----
> Von: Johannes Sixt <j6t@kdbg.org>
> Gesendet: Samstag, 14. September 2024 15:33
> An: Boesch, Tobias <tobias.boesch@miele.com>
> Cc: git@vger.kernel.org; ToBoMi via GitGitGadget <gitgitgadget@gmail.com>
> Betreff: Re: [PATCH v5] git gui: add directly calling merge tool from
> configuration
>
> Am 12.09.24 um 12:17 schrieb ToBoMi via GitGitGadget:
> > Configuration example:
> > [merge]
> >     tool = vscode
> > [mergetool "vscode"]
> >     path = the/path/to/Code.exe
> >     cmd = \"Code.exe\" --wait --merge \"$LOCAL\" \"$REMOTE\"
> \"$BASE\" \"$MERGED\"
>
> This example is not up-to-date anymore, is it?
>
> Also, below are two cases where "mergetool.cmd" is mentioned incorrectly.
>
> > Without the "mergetool.cmd" configuration and an unsupported
> "merge.tool"
> > entry, git gui behaves mainly as before this change and informs the
> > user about an unsupported merge tool. In addtition it also shows a
> > hint to add a configuration entry to use the tool as an unsupported
> > tool with degraded support.
> >
> > If a wrong "mergetool.cmd" is configured by accident, it gets handled
> > by git gui already. In this case git gui informs the user that the
> > merge tool couldn't be opened. This behavior is preserved by this
> > change and should not change.
>
> > --- a/git-gui/lib/mergetool.tcl
> > +++ b/git-gui/lib/mergetool.tcl
> > @@ -272,8 +272,26 @@ proc merge_resolve_tool2 {} {
> >             }
> >     }
> >     default {
> > -           error_popup [mc "Unsupported merge tool '%s'" $tool]
> > -           return
> > +           set tool_cmd [get_config mergetool.$tool.cmd]
> > +           if {$tool_cmd ne {}} {
> > +                   if {([string first {[} $tool_cmd] != -1) || ([string first {]}
> $tool_cmd] != -1)} {
> > +                           error_popup [mc "Unable to process square
> brackets in mergetool.$tool.cmd configuration option.
>
> This $tool in the format string breaks [mc]. It must be %s and an argument. I'll
> fix this up while queuing.
>
> > +
> > +Please remove the square brackets."]
> > +                           return
> > +                   } else {
> > +                           set cmdline {}
> > +                           foreach command_part $tool_cmd {
> > +                                   lappend cmdline [subst -nobackslashes
> -nocommands $command_part]
> > +                           }
> > +                   }
> > +           } else {
> > +                   error_popup [mc "Unsupported merge tool '%s'.
> > +
> > +To use this tool, configure \"mergetool.%s.cmd\" as shown in the
> > +git-config\> +manual page." $tool $tool]
>
> I am surprised that the backslash does not paste the two lines together
> without a space. "git-config" and "manual" do appear as separate words in the
> error message. Nevertheless, since I do not know how this pans out in the
> translation files, I will remove the line continuation and write all on one line.
>

True I also don't know why. You could add a whitespace after the newline and have code matching the documentation of tcl:

"\<newline>whiteSpace A single space character replaces the backslash, newline, and all spaces and tabs after the newline. [...]" From https://www.tcl.tk/man/tcl8.7/TclCmd/Tcl.html#M24

That doesn't change the error message (stays good) in my tests and makes the code compliant to the tcl docs.
Show 8 quoted lines
> > +                   return
> > +           }
> >     }
> >     }
>
> Thank you for your contribution! Below is the range-diff between this
> submission and the queued version.
>

Thank you for fixing the issues left open and your patient review. (Based on your comments and if there is no further notice - I assume that this patch will be processed by your side without further submissions from my side)

Show 73 quoted lines
> -- Hannes
>
> 1:  03e92d6 ! 1:  8ff65c7 git gui: add directly calling merge tool from
> configuration
>     @@ Commit message
>          [merge]
>                  tool = vscode
>          [mergetool "vscode"]
>     -            path = the/path/to/Code.exe
>     -            cmd = \"Code.exe\" --wait --merge \"$LOCAL\" \"$REMOTE\"
> \"$BASE\" \"$MERGED\"
>     +            cmd = \"the/path/to/Code.exe\" --wait --merge \"$LOCAL\"
> \"$REMOTE\" \"$BASE\" \"$MERGED\"
>
>     -    Without the "mergetool.cmd" configuration and an unsupported
> "merge.tool"
>     -    entry, git gui behaves mainly as before this change and informs the user
>     -    about an unsupported merge tool. In addtition it also shows a hint to add
>     -    a configuration entry to use the tool as an unsupported tool with
> degraded
>     -    support.
>     +    Without the "mergetool.<mergetool name>.cmd" entry and an
> unsupported
>     +    "merge.tool" entry, git gui behaves mainly as before this change and
>     +    informs the user about an unsupported merge tool. In addtition, it also
>     +    shows a hint to add a configuration entry to use the tool as an
>     +    unsupported tool with degraded support.
>
>     -    If a wrong "mergetool.cmd" is configured by accident, it gets handled
>     -    by git gui already. In this case git gui informs the user that the merge
>     -    tool couldn't be opened. This behavior is preserved by this change and
>     -    should not change.
>     +    If a wrong "mergetool.<mergetool name>.cmd" is configured by
> accident,
>     +    it gets handled by git gui already. In this case git gui informs the
>     +    user that the merge tool couldn't be opened. This behavior is preserved
>     +    by this change and should not change.
>
>          "Beyond Compare 3" and "Visual Studio Code" were tested as manually
>          configured merge tools.
>
>          Signed-off-by: Tobias Boesch <tobias.boesch@miele.com>
>     +    Signed-off-by: Johannes Sixt <j6t@kdbg.org>
>
>       ## lib/mergetool.tcl ##
>      @@ lib/mergetool.tcl: proc merge_resolve_tool2 {} {
>     @@ lib/mergetool.tcl: proc merge_resolve_tool2 {} {
>      +                set tool_cmd [get_config mergetool.$tool.cmd]
>      +                if {$tool_cmd ne {}} {
>      +                        if {([string first {[} $tool_cmd] != -1) || ([string first {]}
> $tool_cmd] != -1)} {
>     -+                                error_popup [mc "Unable to process square
> brackets in mergetool.$tool.cmd configuration option.
>     ++                                error_popup [mc "Unable to process square
> brackets in \"mergetool.%s.cmd\" configuration option.
>      +
>     -+Please remove the square brackets."]
>     ++Please remove the square brackets." $tool]
>      +                                return
>      +                        } else {
>      +                                set cmdline {}
>     @@ lib/mergetool.tcl: proc merge_resolve_tool2 {} {
>      +                } else {
>      +                        error_popup [mc "Unsupported merge tool '%s'.
>      +
>     -+To use this tool, configure \"mergetool.%s.cmd\" as shown in the git-
> config\
>     -+manual page." $tool $tool]
>     ++To use this tool, configure \"mergetool.%s.cmd\" as shown in the git-
> config manual page." $tool $tool]
>      +                        return
>      +                }
>               }

------------------------------------------------------------------------------------------------- imperial-Werke oHG, Sitz Bünde, Registergericht Bad Oeynhausen - HRA 4825

Previous: Johannes SixtNext: tobias.boesch@miele.com
Message 17 of 19 in “git gui: add directly calling merge tool from gitconfig”
  1. git gui: add directly calling merge tool from gitconfigToBoMi via GitGitGadget, Aug 19, 2024
  2. Johannes SixtAug 24, 2024
  3. AW: [PATCH] git gui: add directly calling merge tool from gitconfigtobias.boesch@miele.com, Aug 27, 2024
  4. AW: [PATCH] git gui: add directly calling merge tool from gitconfigtobias.boesch@miele.com, Aug 27, 2024
  5. git gui: add directly calling merge tool from gitconfigToBoMi via GitGitGadget, Aug 28, 2024
  6. Junio C HamanoAug 28, 2024
  7. AW: [PATCH v2] git gui: add directly calling merge tool from gitconfigtobias.boesch@miele.com, Sep 5, 2024
  8. Johannes SixtAug 31, 2024
  9. AW: [PATCH v2] git gui: add directly calling merge tool from gitconfigtobias.boesch@miele.com, Sep 6, 2024
  10. Johannes SixtSep 6, 2024
  11. git gui: add directly calling merge tool from gitconfigToBoMi via GitGitGadget, Sep 6, 2024
  12. Johannes SixtSep 8, 2024
  13. AW: [PATCH v3] git gui: add directly calling merge tool from gitconfigtobias.boesch@miele.com, Sep 11, 2024
  14. git gui: add directly calling merge tool from configurationToBoMi via GitGitGadget, Sep 11, 2024
  15. git gui: add directly calling merge tool from configurationToBoMi via GitGitGadget, Sep 12, 2024
  16. Johannes SixtSep 14, 2024
  17. AW: [PATCH v5] git gui: add directly calling merge tool from configurationtobias.boesch@miele.com, Sep 16, 2024
  18. AW: [PATCH v5] git gui: add directly calling merge tool from configurationtobias.boesch@miele.com, Nov 7, 2024
  19. Johannes SixtNov 7, 2024

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.