From: Patrick Steinhardt <ps@pks.im>
To: Royce Remer <royceremer@gmail.com>
Cc: git@vger.kernel.org, Taylor Blau <me@ttaylorr.com>,
Junio C Hamano <gitster@pobox.com>,
Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH 1/1] pack-write, pack-bitmap-write: register tmp pack files for cleanup
Date: Mon, 28 Sep 2026 09:58:41 +0200 [thread overview]
Message-ID: <aroeMVWrwvlC1MrH@pks.im> (raw)
In-Reply-To: <20260925205633.530651-2-royceremer@gmail.com>
On Fri, Sep 25, 2026 at 01:56:33PM -0700, Royce Remer wrote:
> diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
> index 1bcb3f98a4..c566419690 100644
> --- a/pack-bitmap-write.c
> +++ b/pack-bitmap-write.c
> @@ -1378,6 +1379,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,
>
> int fd = odb_mkstemp(writer->repo->objects, &tmp_file,
> "pack/tmp_bitmap_XXXXXX");
> + struct tempfile *tmp = register_tempfile(tmp_file.buf);
>
> if (writer->pseudo_merges_nr)
> options |= BITMAP_OPT_PSEUDO_MERGES;
> @@ -1435,6 +1437,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,
>
> if (rename(tmp_file.buf, filename))
> die_errno("unable to rename temporary bitmap file to '%s'", filename);
> + delete_tempfile(&tmp);
>
> strbuf_release(&tmp_file);
> free(offsets);
The fact that we add calls to `register_tempfile()` to almost every
single callsites that uses `odb_mkstemp()` makes me wonder whether the
interface itself is maybe misdesigned. Like, should it maybe return a
tempfile instead of returning a file descriptor so that callers don't
have to manually register it?
I also wonder whether `odb_mkstemp()` even sits at the right level to
begin with. It's ultimately specific to the "files" backend, as it
assumes that files live in "objects/". Would it be preferable if we
instead made it part of the "tempfile.h" API, where the only difference
to other functions is that it knows to also support leading directories?
We could for example have a new "_d" suffix for `mks_tempfile()`
functions.
Thanks!
Patrick
prev parent reply other threads:[~2026-09-28 7:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 20:56 [PATCH 0/1] pack-write, pack-bitmap-write: register tmp pack files for cleanup Royce Remer
2026-09-25 20:56 ` [PATCH 1/1] " Royce Remer
2026-09-28 7:58 ` Patrick Steinhardt [this message]
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=aroeMVWrwvlC1MrH@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=newren@gmail.com \
--cc=royceremer@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox