From: Justin Tobler <jltobler@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, Justin Tobler <jltobler@gmail.com>
Subject: [PATCH 1/2] object-file: lift ODB reprepare out of packfile flush
Date: Sun, 13 Sep 2026 15:26:21 -0500 [thread overview]
Message-ID: <cf14416f224f48475dfc9f79d8ec62756b9fdedf.1789328612.git.jltobler@gmail.com> (raw)
In-Reply-To: <cover.1789328612.git.jltobler@gmail.com>
When flushing a packfile via `flush_packfile_transaction()`,
`odb_reprepare()` is invoked so the written packfile becomes visible in
the current process. In a subsequent commit, repreparing the ODB is
slightly deferred when committing a "files" ODB transaction.
Lift ODB reprepare out of `flush_packfile_transaction()` and instead
require callers to explicitly invoke `odb_reprepare()` if required.
Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
object-file.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/object-file.c b/object-file.c
index a4cbf8b081df..0f123b79fad1 100644
--- a/object-file.c
+++ b/object-file.c
@@ -857,8 +857,6 @@ static void flush_packfile_transaction(struct odb_transaction_files *transaction
memset(state, 0, sizeof(*state));
strbuf_release(&packname);
- /* Make objects we just wrote available to ourselves */
- odb_reprepare(repo->objects);
}
/*
@@ -909,8 +907,10 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas
* to zlib compression and is sufficient for this check.
*/
if (state->nr_written && pack_size_limit_cfg &&
- pack_size_limit_cfg < state->offset + stream->size)
+ pack_size_limit_cfg < state->offset + stream->size) {
flush_packfile_transaction(transaction);
+ odb_reprepare(transaction->base.source->odb);
+ }
CALLOC_ARRAY(idx, 1);
prepare_packfile_transaction(transaction);
@@ -1260,6 +1260,7 @@ static int odb_transaction_files_commit(struct odb_transaction *base)
{
struct odb_transaction_files *transaction =
container_of(base, struct odb_transaction_files, base);
+ int have_packfile = !!transaction->packfile.f;
if (transaction->objdir) {
struct strbuf temp_path = STRBUF_INIT;
@@ -1293,6 +1294,9 @@ static int odb_transaction_files_commit(struct odb_transaction *base)
flush_packfile_transaction(transaction);
+ if (have_packfile)
+ odb_reprepare(transaction->base.source->odb);
+
return 0;
}
--
2.55.0
next prev parent reply other threads:[~2026-09-13 20:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 20:26 [PATCH 0/2] object-file: fix packfile flush during transaction commit Justin Tobler
2026-09-13 20:26 ` Justin Tobler [this message]
2026-09-15 4:40 ` [PATCH 1/2] object-file: lift ODB reprepare out of packfile flush Karthik Nayak
2026-09-15 8:54 ` Justin Tobler
2026-09-23 13:16 ` Patrick Steinhardt
2026-09-23 21:04 ` Justin Tobler
2026-09-24 5:58 ` Patrick Steinhardt
2026-09-24 6:00 ` Patrick Steinhardt
2026-09-13 20:26 ` [PATCH 2/2] object-file: flush transaction packfile before migrating objects Justin Tobler
2026-09-15 4:46 ` Karthik Nayak
2026-09-15 8:59 ` Justin Tobler
2026-09-23 13:16 ` Patrick Steinhardt
2026-09-23 21:17 ` Justin Tobler
2026-09-23 22:03 ` [PATCH v2 0/2] object-file: fix packfile flush during transaction commit Justin Tobler
2026-09-23 22:03 ` [PATCH v2 1/2] object-file: lift ODB reprepare out of packfile flush Justin Tobler
2026-09-24 6:13 ` Patrick Steinhardt
2026-09-23 22:03 ` [PATCH v2 2/2] object-file: flush transaction packfile before migrating objects Justin Tobler
2026-09-24 6:01 ` [PATCH v2 0/2] object-file: fix packfile flush during transaction commit Patrick Steinhardt
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=cf14416f224f48475dfc9f79d8ec62756b9fdedf.1789328612.git.jltobler@gmail.com \
--to=jltobler@gmail.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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