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

Re: [QUESTION] mergetool environment variables

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Sep 15, 2025, 15:35 UTC
Message-ID
<CALnO6CDqDWLHfitqxHqOtL5Ej9XMfZUmC9j1dgQG6xiZGHQZMA@mail.gmail.com>
In-Reply-To
<a57d5857-b096-4d92-993a-3f09d15cdcb9@gmail.com>

The text of this reply sat in my drafts, so my apologies for getting it out later than I intended. I agree with Phillip's reply below, to which I've moved the text so it makes sense :)

On Sun, Sep 14, 2025 at 9:51 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 41 quoted lines
>
> Hi Randall
>
> On 14/09/2025 01:18, rsbecker@nexbridge.com wrote:
> > On September 13, 2025 5:04 PM, Johannes Sixt wrote:
> >> To: rsbecker@nexbridge.com
> >> Cc: git@vger.kernel.org
> >> Subject: Re: [QUESTION] mergetool environment variables
> >>
> >> Am 13.09.25 um 16:42 schrieb rsbecker@nexbridge.com:
> >>> Let me try to infer what is happening and please correct me if my
> >>> assumptions are wrong:
> >> I'm sorry to say that I can't help. I tried to disentangle what is going on, but this
> >> stuff is far too convoluted to be understood in a few minutes. I cannot tell if it is
> >> possible to write a mergetool that is not installed with Git.
> >>
> >> I would just copy one of the existing tool scripts and run `make install` from the Git
> >> source directory.
> >
> > Yes, it needs to be in the git install area. Adding export BASE export LOCAL, etc.,
> > works to resolve the situation. I wonder whether that should be documented.
>
> Looking at t7610-mergetool.sh I think you can use mergetool.<tool>.cmd
> to call a user defined merge tool. The value of the config variable is
> eval'd in the shell so if you run
>
>      git config mergetool.my-tool.cmd 'my-tool "$BASE" "$LOCAL" "$REMOTE"'
>
> then
>
>      git mergetool --tool=my-tool
>
> will run
>
>      my-tool <base-file> <local-file> <remote-file>
>
> on each unmerged file
>
> Thanks
>
> Phillip

I run a custom merge tool, and I am fairly certain it has access to these variables. But I pass them in the config defining the tool to the « main » command in the versions where I use them.

See history around https://github.com/benknoble/Dotfiles/blob/4a4fe9678bdc5b34dc826058fbe85d29cc4d7722/links/gitconfig#L130.

Otherwise this would seem an unfortunate interface.
-- 
D. Ben Knoble
Previous: Phillip Wood
Message 8 of 8 in “[QUESTION] mergetool environment variables”
  1. rsbecker@nexbridge.comSep 12, 2025
  2. Johannes SixtSep 13, 2025
  3. rsbecker@nexbridge.comSep 13, 2025
  4. Johannes SixtSep 13, 2025
  5. rsbecker@nexbridge.comSep 14, 2025
  6. Junio C HamanoSep 14, 2025
  7. Phillip WoodSep 14, 2025
  8. D. Ben KnobleSep 15, 2025

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.