From: <rsbecker@nexbridge.com>
To: "'Johannes Sixt'" <j6t@kdbg.org>
Cc: <git@vger.kernel.org>
Subject: RE: [QUESTION] mergetool environment variables
Date: Sat, 13 Sep 2025 10:42:24 -0400 [thread overview]
Message-ID: <000201dc24bc$a1b8d9d0$e52a8d70$@nexbridge.com> (raw)
In-Reply-To: <a5e01f0f-1789-427c-83c3-90644fa234c9@kdbg.org>
On September 13, 2025 3:05 AM, Johannes Sixt wrote:
>Am 12.09.25 um 22:16 schrieb rsbecker@nexbridge.com:
>> I am trying to integrate a custom mergetool with a shell wrapper.
>> What I get from the online help is the following description referring
>> to the command and environment variables.
>>
>> mergetool.<tool>.cmd
>> Specify the command to invoke the specified merge tool.
>> The specified command is evaluated in shell with the following
>> variables available: BASE is the name of a
>
>Take note: this talks about "variables", not "environment variables".
>
>> temporary file containing the common base of the files to be merged,
>> if available; LOCAL is the name of a temporary file containing the
>> contents of the file on the current branch; REMOTE is the name of a
>> temporary file containing the contents of the file from the branch
>> being merged; MERGED contains the name of the file to which the merge
>> tool should write the results of a successful merge.
>>
>> When I try to use this from a shell, simply with:
>> #!/bin/sh
>> env
>> exit 1
>>
>> the described environment variables: BASE, LOCAL, REMOTE, and MERGED,
>> are not present.
>
>Look at the scripts in the directory mergetools/ and note that they are only (large)
>shell code fragements without a shbang line. They are not even executable.
Let me try to infer what is happening and please correct me if my assumptions
are wrong:
Git includes an existing shell fragment with the appropriate tool name from
git-core/mergetools/tool-name instead of creating a dedicated shell in which to
run the merge tool script.
It then uses ${merge-tool-path} to execute the tool based on whether diff_cmd() or
merge_cmd() is invoked. Because BASE, LOCAL, REMOTE, and MERGED are not
exported, they are not visible to sub-shells.
This does not apply if the tool is unknown to the mergetools directory, so must be
contributed and packaged into git to work according to the documentation.
So a custom mergetool will not have access to these variables and has to hack
through what is in the working index based on file_BASE_num, etc. instead of
having direct information on what is being merged.
That about right?
next prev parent reply other threads:[~2025-09-13 14:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 20:16 [QUESTION] mergetool environment variables rsbecker
2025-09-13 7:04 ` Johannes Sixt
2025-09-13 14:42 ` rsbecker [this message]
2025-09-13 21:03 ` Johannes Sixt
2025-09-14 0:18 ` rsbecker
2025-09-14 6:38 ` Junio C Hamano
2025-09-14 13:48 ` Phillip Wood
2025-09-15 15:35 ` D. Ben Knoble
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='000201dc24bc$a1b8d9d0$e52a8d70$@nexbridge.com' \
--to=rsbecker@nexbridge.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.