From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Michal Koutný" <mkoutny@suse.com>,
git@vger.kernel.org, "Jean Delvare" <jdelvare@suse.de>,
"Elijah Newren" <newren@gmail.com>,
"Usman Akinyemi" <usmanakinyemi202@gmail.com>,
"Taylor Blau" <me@ttaylorr.com>, "René Scharfe" <l.s.r@web.de>
Subject: Re: [PATCH v3 2/2] merge-ll: use tempfile API for external driver files
Date: Tue, 29 Sep 2026 09:51:53 -0700 [thread overview]
Message-ID: <xmqqcxtwhufq.fsf@gitster.g> (raw)
In-Reply-To: <20260929051312.GB1100669@coredump.intra.peff.net> (Jeff King's message of "Tue, 29 Sep 2026 01:13:12 -0400")
Jeff King <peff@peff.net> writes:
> When there's a long(er) running merge driver helper, the user may just
> decide to terminate it with Ctrl+C. That sends a signal to the driver
> program and to the whole process group as well, including the git merge
> command proper. Hence the cleanup code would not run and .merge_file_*
> files are left behind.
>
> We can fix this by using the tempfile API, which auto-cleans files on
> signal or other error. That covers the Ctrl+C case above, as well as any
> other incidental death (e.g., allocation error due to a gigantic
> output).
>
> Note that there is one gotcha here. The current code uses short,
> relative filenames for the tempfiles (like ".merge_file_abc123"). But
> the tempfile API stores and returns absolute paths. Because we run the
> merge driver as a shell command, this can result in problems if the
> leading directories contain shell metacharacters (like our tests, which
> put a space in the trash directory name for exactly this purpose).
>
> If we were starting from scratch, I'd say the correct solution here is
> to shell-quote the filenames we put in the command. But doing so isn't
> strictly backwards compatible, because users might have their own shell
> characters. For example, if I configure a driver like this:
"own shell characters" -> "own shell quoting"?
>
> [merge "foo"]
> driver = "my-driver '%O' '%A' '%B'"
>
> then adding extra quoting will screw things up! Strictly speaking, this
> kind of quoting is wrong (it would fail if %A expanded to something with
> a single-quote in it), but it is entirely harmless with the current
> vanilla relative paths. It doesn't seem worth breaking it.
>
> So let's take the most conservative route, and just continue reporting
> the relative paths.
Very well reasoned, and the implementation exactly matches the
designed behaviour.
Will replace. Let's mark it for 'next' (unless somebody notices
what I overlooked, which is not a very high bar to cross).
Thanks.
next prev parent reply other threads:[~2026-09-29 16:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 15:06 [PATCH] merge-ll: Cleanup merge driver temporaries after interrupt Michal Koutný
2026-09-10 16:22 ` Jeff King
2026-09-11 14:43 ` Michal Koutný
2026-09-11 17:10 ` [PATCH v2 0/3] merge-ll: Cleanup merge driver temporaries after Jeff King
2026-09-11 17:11 ` [PATCH v2 1/3] merge-ll: use strbuf to read back external merge result Jeff King
2026-09-11 18:06 ` Elijah Newren
2026-09-11 18:32 ` Junio C Hamano
2026-09-14 16:53 ` Jeff King
2026-09-11 17:11 ` [PATCH v2 2/3] merge-ll: catch close() errors when writing external tempfiles Jeff King
2026-09-11 18:06 ` Elijah Newren
2026-09-14 16:56 ` Jeff King
2026-09-11 17:13 ` [PATCH v2 3/3] merge-ll: use tempfile API for external driver files Jeff King
2026-09-11 18:10 ` Elijah Newren
2026-09-14 13:24 ` Michal Koutný
2026-09-14 16:57 ` Jeff King
2026-09-14 13:23 ` [PATCH v2 0/3] merge-ll: Cleanup merge driver temporaries after Michal Koutný
2026-09-14 16:59 ` Jeff King
2026-09-29 5:12 ` [PATCH v3 0/2] merge-ll: Cleanup merge driver temporaries after signal Jeff King
2026-09-29 5:12 ` [PATCH v3 1/2] merge-ll: catch close() errors when writing external tempfiles Jeff King
2026-09-29 5:13 ` [PATCH v3 2/2] merge-ll: use tempfile API for external driver files Jeff King
2026-09-29 16:51 ` Junio C Hamano [this message]
2026-09-29 18:25 ` Jeff King
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=xmqqcxtwhufq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jdelvare@suse.de \
--cc=l.s.r@web.de \
--cc=me@ttaylorr.com \
--cc=mkoutny@suse.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=usmanakinyemi202@gmail.com \
/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.