From: Patrick Steinhardt Date: Fri, 02 Oct 2026 10:08:21 GMT Subject: [PATCH 10/13] odb/source: make `will_destroy` an implementation detail Message-ID: <20261002-pks-odb-move-alternates-v1-10-8a63507b88c4@pks.im> In-Reply-To: <20261002-pks-odb-move-alternates-v1-0-8a63507b88c4@pks.im> The `struct odb_source::will_destroy` flag tracks whether a source is part of a transaction that we know we'll destruct anyway. If so, the backend can optimize for that particular case, for example by not flushing any data to disk. While the intent is sensible, it assumes that transactions are backed by a separate source that's being linked into the object database. But that may or may not be true, as backends may have significantly better ways to achieve the same. So the assumption doesn't make much sense in the first place, as we're now tracking backend-specific details on the generic `struct odb_source` level. Move the field from the generic source into the "loose" source, as this is the only source that ever makes use of it anyway. Signed-off-by: Patrick Steinhardt --- odb/source-loose.c | 2 +- odb/source-loose.h | 3 +++ odb/source.h | 5 ----- tmp-objdir.c | 4 +--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/odb/source-loose.c b/odb/source-loose.c index 3c9edba46a..b2fbccd3c0 100644 --- a/odb/source-loose.c +++ b/odb/source-loose.c @@ -599,7 +599,7 @@ static int odb_source_loose_freshen_object(struct odb_source *source, static void close_loose_object(struct odb_source_loose *loose, int fd, const char *filename) { - if (loose->base.will_destroy) + if (loose->will_destroy) goto out; if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT)) diff --git a/odb/source-loose.h b/odb/source-loose.h index 3cf2e1f8f1..7c7e845fe3 100644 --- a/odb/source-loose.h +++ b/odb/source-loose.h @@ -28,6 +28,9 @@ struct odb_source_loose { /* Map between object IDs for loose objects. */ struct loose_object_map *map; + + /* Whether this is a source that will never be committed to disk. */ + int will_destroy; }; struct odb_source_loose *odb_source_loose_new(struct object_database *odb, diff --git a/odb/source.h b/odb/source.h index ea00873763..9fd2b2e5b5 100644 --- a/odb/source.h +++ b/odb/source.h @@ -81,11 +81,6 @@ struct odb_source { */ bool local; - /* - * This object store is ephemeral, so there is no need to fsync. - */ - int will_destroy; - /* * Path to the source. If this is a relative path, it is relative to * the current working directory. diff --git a/tmp-objdir.c b/tmp-objdir.c index 719b55e580..2f2ffbbc7d 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -14,7 +14,6 @@ #include "odb/source.h" #include "odb/source-files.h" #include "odb/source-loose.h" -#include "odb/source-packed.h" #include "repository.h" struct tmp_objdir { @@ -213,8 +212,7 @@ struct tmp_objdir *tmp_objdir_create(struct repository *r, * since the objects in the database may roll back. */ t->temp_dir = odb_files_dir_new(t->repo->objects, t->path.buf, false); - t->temp_dir->loose->base.will_destroy = will_destroy; - t->temp_dir->packed->base.will_destroy = will_destroy; + t->temp_dir->loose->will_destroy = will_destroy; t->temp_dir->next = files->dirs; t->orig_dir = files->dirs; -- 2.56.0.379.gc618271300.dirty