From: Patrick Steinhardt <ps@pks.im>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>,
Justin Tobler <jltobler@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 11/14] odb: introduce mtime fields for object info requests
Date: Mon, 26 Jan 2026 09:53:30 +0100 [thread overview]
Message-ID: <aXcrii58bIdLttI2@pks.im> (raw)
In-Reply-To: <aXO0cNaY3DWu6aQ2@nand.local>
On Fri, Jan 23, 2026 at 12:48:32PM -0500, Taylor Blau wrote:
> On Fri, Jan 23, 2026 at 10:43:07AM +0100, Patrick Steinhardt wrote:
> > > > diff --git a/odb.c b/odb.c
> > > > index 65f0447aa5..67decd3908 100644
> > > > --- a/odb.c
> > > > +++ b/odb.c
> > > > @@ -702,6 +702,8 @@ static int do_oid_object_info_extended(struct object_database *odb,
> > > > oidclr(oi->delta_base_oid, odb->repo->hash_algo);
> > > > if (oi->contentp)
> > > > *oi->contentp = xmemdupz(co->buf, co->size);
> > > > + if (oi->mtimep)
> > > > + *oi->mtimep = 0;
> > >
> > > Assuming that you do not change the object_info request/response
> > > semantics, I wonder if it might make sense to zero out the entirety of
> > > the response section as a belt-and-suspenders mechanism in case future
> > > contributors forget to assign zero to the new fields themselves.
> >
> > Splitting up the request/response structure as you proposed in a
> > previous patch could definitely help with this. I'd prefer to rather do
> > such a bigger change as a follow-up though as it would lead to a lot of
> > churn.
>
> I'm OK with pushing the larger change down the road, but I am a little
> uncomfortable with the interim state being introduced here. Perhaps a
> compromise here would be to have the caller supply a pointer to an
> object_info struct, whose request fields we honor. The response fields
> would then be written into a separate object_info struct via an
> out-parameter.
>
> I don't know. I think that ^ this suggestion is kind of ugly, but I'm
> trying to come up with something that doesn't introduce the risk I
> described above in the interim between this patch series and the one
> you're proposing later on.
I think it's actually not _that_ ugly, and I like the additional safety
that it brings us.
Thanks!
Patrick
diff --git a/object-file.c b/object-file.c
index bc5209f2fe..6785821c8c 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1804,7 +1804,7 @@ int for_each_loose_file_in_source(struct odb_source *source,
struct for_each_object_wrapper_data {
struct odb_source *source;
- struct object_info *oi;
+ const struct object_info *request;
odb_for_each_object_cb cb;
void *cb_data;
};
@@ -1814,21 +1814,28 @@ static int for_each_object_wrapper_cb(const struct object_id *oid,
void *cb_data)
{
struct for_each_object_wrapper_data *data = cb_data;
- if (data->oi &&
- read_object_info_from_path(data->source, path, oid, data->oi, 0) < 0)
+
+ if (data->request) {
+ struct object_info oi = *data->request;
+
+ if (read_object_info_from_path(data->source, path, oid, &oi, 0) < 0)
return -1;
- return data->cb(oid, data->oi, data->cb_data);
+
+ return data->cb(oid, &oi, data->cb_data);
+ } else {
+ return data->cb(oid, NULL, data->cb_data);
+ }
}
int odb_source_loose_for_each_object(struct odb_source *source,
- struct object_info *oi,
+ const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags)
{
struct for_each_object_wrapper_data data = {
.source = source,
- .oi = oi,
+ .request = request,
.cb = cb,
.cb_data = cb_data,
};
diff --git a/object-file.h b/object-file.h
index af7f57d2a1..d9979baea8 100644
--- a/object-file.h
+++ b/object-file.h
@@ -128,12 +128,13 @@ int for_each_loose_file_in_source(struct odb_source *source,
/*
* Iterate through all loose objects in the given object database source and
- * invoke the callback function for each of them. If given, the object info
- * will be populated with the object's data as if you had called
- * `odb_source_loose_read_object_info()` on the object.
+ * invoke the callback function for each of them. If an object info request is
+ * given, then the object info will be read for every individual object and
+ * passed to the callback as if `odb_source_loose_read_object_info()` was
+ * called for the object.
*/
int odb_source_loose_for_each_object(struct odb_source *source,
- struct object_info *oi,
+ const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags);
diff --git a/odb.c b/odb.c
index 67decd3908..9d9a3fad62 100644
--- a/odb.c
+++ b/odb.c
@@ -998,7 +998,7 @@ int odb_freshen_object(struct object_database *odb,
}
int odb_for_each_object(struct object_database *odb,
- struct object_info *oi,
+ const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags)
@@ -1011,12 +1011,14 @@ int odb_for_each_object(struct object_database *odb,
continue;
if (!(flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY)) {
- ret = odb_source_loose_for_each_object(source, oi, cb, cb_data, flags);
+ ret = odb_source_loose_for_each_object(source, request,
+ cb, cb_data, flags);
if (ret)
return ret;
}
- ret = packfile_store_for_each_object(source->packfiles, oi, cb, cb_data, flags);
+ ret = packfile_store_for_each_object(source->packfiles, request,
+ cb, cb_data, flags);
if (ret)
return ret;
}
diff --git a/odb.h b/odb.h
index 72d69ffcb3..8ad0fcc02f 100644
--- a/odb.h
+++ b/odb.h
@@ -492,6 +492,9 @@ typedef int (*odb_for_each_object_cb)(const struct object_id *oid,
* Iterate through all objects contained in the object database. Note that
* objects may be iterated over multiple times in case they are either stored
* in different backends or in case they are stored in multiple sources.
+ * If an object info request is given, then the object info will be read and
+ * passed to the callback as if `odb_read_object_info()` was called for the
+ * object.
*
* Returning a non-zero error code from the callback function will cause
* iteration to abort. The error code will be propagated.
@@ -500,7 +503,7 @@ typedef int (*odb_for_each_object_cb)(const struct object_id *oid,
* an arbitrary non-zero error code returned by the callback itself.
*/
int odb_for_each_object(struct object_database *odb,
- struct object_info *oi,
+ const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags);
diff --git a/packfile.c b/packfile.c
index e455150d65..57fbf51876 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2329,7 +2329,7 @@ int for_each_object_in_pack(struct packed_git *p,
struct packfile_store_for_each_object_wrapper_data {
struct packfile_store *store;
- struct object_info *oi;
+ const struct object_info *request;
odb_for_each_object_cb cb;
void *cb_data;
};
@@ -2341,28 +2341,31 @@ static int packfile_store_for_each_object_wrapper(const struct object_id *oid,
{
struct packfile_store_for_each_object_wrapper_data *data = cb_data;
- if (data->oi) {
+ if (data->request) {
off_t offset = nth_packed_object_offset(pack, index_pos);
+ struct object_info oi = *data->request;
if (packed_object_info_with_index_pos(pack, offset,
- &index_pos, data->oi) < 0) {
+ &index_pos, &oi) < 0) {
mark_bad_packed_object(pack, oid);
return -1;
}
- }
- return data->cb(oid, data->oi, data->cb_data);
+ return data->cb(oid, &oi, data->cb_data);
+ } else {
+ return data->cb(oid, NULL, data->cb_data);
+ }
}
int packfile_store_for_each_object(struct packfile_store *store,
- struct object_info *oi,
+ const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags)
{
struct packfile_store_for_each_object_wrapper_data data = {
.store = store,
- .oi = oi,
+ .request = request,
.cb = cb,
.cb_data = cb_data,
};
diff --git a/packfile.h b/packfile.h
index 8e0d2b7661..1a1b720764 100644
--- a/packfile.h
+++ b/packfile.h
@@ -343,14 +343,15 @@ int for_each_object_in_pack(struct packed_git *p,
/*
* Iterate through all packed objects in the given packfile store and invoke
- * the callback function for each of them. If given, the object info will be
- * populated with the object's data as if you had called
- * `packfile_store_read_object_info()` on the object.
+ * the callback function for each of them. If an object info request is given,
+ * then the object info will be read for every individual object and passed to
+ * the callback as if `packfile_store_read_object_info()` was called for the
+ * object.
*
* The flags parameter is a combination of `odb_for_each_object_flags`.
*/
int packfile_store_for_each_object(struct packfile_store *store,
- struct object_info *oi,
+ const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
unsigned flags);
next prev parent reply other threads:[~2026-01-26 8:53 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:04 [PATCH 00/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-15 18:00 ` Justin Tobler
2026-01-15 11:04 ` [PATCH 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-15 18:31 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-20 9:09 ` Karthik Nayak
2026-01-15 11:04 ` [PATCH 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-15 20:54 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-20 9:16 ` Karthik Nayak
2026-01-15 11:04 ` [PATCH 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-15 21:17 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-16 17:46 ` Justin Tobler
2026-01-19 7:10 ` Patrick Steinhardt
2026-01-20 9:20 ` Karthik Nayak
2026-01-21 7:39 ` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-15 21:24 ` Justin Tobler
2026-01-15 11:04 ` [PATCH 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-15 21:44 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-16 17:47 ` Justin Tobler
2026-01-19 7:10 ` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-01-15 13:50 ` [PATCH 00/14] odb: introduce `odb_for_each_object()` Junio C Hamano
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-16 16:49 ` Junio C Hamano
2026-01-20 15:25 ` [PATCH v2 " Patrick Steinhardt
2026-01-20 15:25 ` [PATCH v2 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-20 15:25 ` [PATCH v2 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-20 15:25 ` [PATCH v2 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 00/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-21 21:11 ` Jeff King
2026-01-22 0:00 ` Taylor Blau
2026-01-22 15:41 ` Junio C Hamano
2026-01-22 19:23 ` Jeff King
2026-01-23 10:57 ` Patrick Steinhardt
2026-01-26 22:32 ` Junio C Hamano
2026-01-22 6:50 ` Patrick Steinhardt
2026-01-22 23:44 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-22 0:04 ` Taylor Blau
2026-01-22 6:51 ` Patrick Steinhardt
2026-01-22 23:47 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-22 0:15 ` Taylor Blau
2026-01-22 6:52 ` Patrick Steinhardt
2026-01-23 0:01 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-22 1:37 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-23 0:06 ` Taylor Blau
2026-01-23 9:42 ` Patrick Steinhardt
2026-01-23 9:52 ` Chris Torek
2026-01-23 16:22 ` Junio C Hamano
2026-01-23 17:45 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-23 0:13 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-23 0:32 ` Taylor Blau
2026-01-23 9:42 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-23 0:33 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-23 0:46 ` Taylor Blau
2026-01-23 9:43 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-23 1:06 ` Taylor Blau
2026-01-23 9:43 ` Patrick Steinhardt
2026-01-23 17:48 ` Taylor Blau
2026-01-26 8:53 ` Patrick Steinhardt [this message]
2026-01-21 12:50 ` [PATCH v3 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-23 1:21 ` Taylor Blau
2026-01-23 9:43 ` Patrick Steinhardt
2026-01-23 18:35 ` Taylor Blau
2026-01-26 8:53 ` Patrick Steinhardt
2026-01-29 11:08 ` Jeff King
2026-01-30 12:57 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-01-22 1:33 ` [PATCH v3 00/14] odb: introduce `odb_for_each_object()` Taylor Blau
2026-01-22 17:02 ` Junio C Hamano
2026-01-26 9:51 ` [PATCH v4 " Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-02-20 22:59 ` [PATCH v4 00/14] odb: introduce `odb_for_each_object()` Junio C Hamano
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=aXcrii58bIdLttI2@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=me@ttaylorr.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