From: Taylor Blau <ttaylorr@openai.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Ted Nyman <tnyman@openai.com>, Elijah Newren <newren@github.com>
Subject: [PATCH 1/4] pack-objects: introduce `stdin_packs_context` struct
Date: Tue, 29 Sep 2026 20:28:45 -0500 [thread overview]
Message-ID: <64bb13e2db2e5c22e842c188e08861d63e99dc77.1790731662.git.me@ttaylorr.com> (raw)
In-Reply-To: <cover.1790731662.git.me@ttaylorr.com>
`stdin_packs_read_input()` currently receives a pointer to the
`rev_info` struct and '--stdin-packs' mode separately as arguments, but
the object enumeration callbacks only receive a pointer to the
`rev_info` struct.
Wrap the pair in a new `stdin_packs_context` struct so that a future
change may reference the '--stdin-packs' mode within the various
object enumeration callbacks.
Signed-off-by: Taylor Blau <ttaylorr@openai.com>
---
builtin/pack-objects.c | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index af9390a46b9..01adf80a2bc 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3804,11 +3804,17 @@ static int git_pack_config(const char *k, const char *v,
static int stdin_packs_found_nr;
static int stdin_packs_hints_nr;
+struct stdin_packs_context {
+ struct rev_info *revs;
+ enum stdin_packs_mode mode;
+};
+
static int add_object_entry_from_pack(const struct object_id *oid,
struct packed_git *p,
uint32_t pos,
void *_data)
{
+ struct stdin_packs_context *ctx = _data;
off_t ofs;
struct object_info oi = OBJECT_INFO_INIT;
enum object_type type = OBJ_NONE;
@@ -3827,7 +3833,6 @@ static int add_object_entry_from_pack(const struct object_id *oid,
die(_("could not get type of object %s in pack %s"),
oid_to_hex(oid), p->pack_name);
} else if (type == OBJ_COMMIT) {
- struct rev_info *revs = _data;
/*
* commits in included packs are used as starting points
* for the subsequent revision walk
@@ -3840,7 +3845,7 @@ static int add_object_entry_from_pack(const struct object_id *oid,
* However, we'll only add those objects to the packing
* list after checking `want_object_in_pack()` below.
*/
- add_pending_oid(revs, NULL, oid, 0);
+ add_pending_oid(ctx->revs, NULL, oid, 0);
}
if (!want_object_in_pack(oid, 0, &p, &ofs))
@@ -3954,8 +3959,9 @@ static int stdin_packs_include_check(struct commit *commit, void *data)
}
static void stdin_packs_add_pack_entries(struct strmap *packs,
- struct rev_info *revs)
+ struct stdin_packs_context *ctx)
{
+ struct rev_info *revs = ctx->revs;
struct string_list keys = STRING_LIST_INIT_NODUP;
struct string_list_item *item;
struct hashmap_iter iter;
@@ -3994,15 +4000,14 @@ static void stdin_packs_add_pack_entries(struct strmap *packs,
(info->kind & STDIN_PACK_EXCLUDE_OPEN))
for_each_object_in_pack(info->p,
add_object_entry_from_pack,
- revs,
+ ctx,
ODB_FOR_EACH_OBJECT_PACK_ORDER);
}
string_list_clear(&keys, 0);
}
-static void stdin_packs_read_input(struct rev_info *revs,
- enum stdin_packs_mode mode)
+static void stdin_packs_read_input(struct stdin_packs_context *ctx)
{
struct strbuf buf = STRBUF_INIT;
struct strmap packs = STRMAP_INIT;
@@ -4017,7 +4022,7 @@ static void stdin_packs_read_input(struct rev_info *revs,
continue;
else if (*key == '^')
kind = STDIN_PACK_EXCLUDE_CLOSED;
- else if (*key == '!' && mode == STDIN_PACKS_MODE_FOLLOW)
+ else if (*key == '!' && ctx->mode == STDIN_PACKS_MODE_FOLLOW)
kind = STDIN_PACK_EXCLUDE_OPEN;
if (kind != STDIN_PACK_INCLUDE)
@@ -4082,19 +4087,23 @@ static void stdin_packs_read_input(struct rev_info *revs,
info->p = p;
}
- stdin_packs_add_pack_entries(&packs, revs);
+ stdin_packs_add_pack_entries(&packs, ctx);
strbuf_release(&buf);
strmap_clear(&packs, 1);
}
-static void add_unreachable_loose_objects(struct rev_info *revs);
+static void add_unreachable_loose_objects(struct stdin_packs_context *ctx);
static void read_stdin_packs(struct repository *repo,
enum stdin_packs_mode mode, int rev_list_unpacked)
{
int prev_fetch_if_missing = repo->fetch_if_missing;
struct rev_info revs;
+ struct stdin_packs_context ctx = {
+ .revs = &revs,
+ .mode = mode,
+ };
/*
* The revision walk may hit objects that are promised, only. As the
@@ -4131,9 +4140,9 @@ static void read_stdin_packs(struct repository *repo,
*/
ignore_packed_keep_in_core_open = 1;
}
- stdin_packs_read_input(&revs, mode);
+ stdin_packs_read_input(&ctx);
if (rev_list_unpacked)
- add_unreachable_loose_objects(&revs);
+ add_unreachable_loose_objects(&ctx);
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
@@ -4541,7 +4550,7 @@ static void add_objects_in_unpacked_packs(void)
static int add_loose_object(const struct object_id *oid, const char *path,
void *data)
{
- struct rev_info *revs = data;
+ struct stdin_packs_context *ctx = data;
enum object_type type = odb_read_object_info(the_repository->objects, oid, NULL);
if (type < 0) {
@@ -4563,8 +4572,8 @@ static int add_loose_object(const struct object_id *oid, const char *path,
add_object_entry(oid, type, "", 0);
}
- if (revs && type == OBJ_COMMIT)
- add_pending_oid(revs, NULL, oid, 0);
+ if (ctx && type == OBJ_COMMIT)
+ add_pending_oid(ctx->revs, NULL, oid, 0);
return 0;
}
@@ -4574,10 +4583,10 @@ static int add_loose_object(const struct object_id *oid, const char *path,
* add_object_entry will weed out duplicates, so we just add every
* loose object we find.
*/
-static void add_unreachable_loose_objects(struct rev_info *revs)
+static void add_unreachable_loose_objects(struct stdin_packs_context *ctx)
{
for_each_loose_file_in_source(the_repository->objects->sources,
- add_loose_object, NULL, NULL, revs);
+ add_loose_object, NULL, NULL, ctx);
}
static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
--
2.56.0.4.gbee41d2fc68
next prev parent reply other threads:[~2026-09-30 1:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 1:28 [PATCH 0/4] repack: various corner cases for cruft-less MIDXs Taylor Blau
2026-09-30 1:28 ` Taylor Blau [this message]
2026-09-30 17:42 ` [PATCH 1/4] pack-objects: introduce `stdin_packs_context` struct Junio C Hamano
2026-10-01 3:13 ` Taylor Blau
2026-09-30 1:28 ` [PATCH 2/4] pack-objects: ensure tree/tag closure with '--stdin-packs=follow' Taylor Blau
2026-09-30 17:51 ` Junio C Hamano
2026-09-30 18:16 ` Derrick Stolee
2026-10-01 3:14 ` Taylor Blau
2026-10-01 23:22 ` Elijah Newren
2026-10-02 0:51 ` Taylor Blau
2026-10-02 23:02 ` Jeff King
2026-09-30 20:31 ` Jeff King
2026-10-01 3:18 ` Taylor Blau
2026-09-30 1:28 ` [PATCH 3/4] repack: retain cruft packs in MIDXs after incremental repacks Taylor Blau
2026-09-30 20:45 ` Jeff King
2026-10-01 3:21 ` Taylor Blau
2026-09-30 1:28 ` [PATCH 4/4] repack: retain cruft packs in MIDXs containing kept packs Taylor Blau
2026-09-30 20:53 ` Jeff King
2026-10-01 3:35 ` Taylor Blau
2026-09-30 20:55 ` [PATCH 0/4] repack: various corner cases for cruft-less MIDXs Jeff King
2026-10-01 3:37 ` Taylor Blau
2026-10-01 4:11 ` [PATCH v2 0/8] " Taylor Blau
2026-10-01 4:11 ` [PATCH v2 1/8] pack-objects: introduce `stdin_packs_context` struct Taylor Blau
2026-10-01 4:11 ` [PATCH v2 2/8] pack-objects: ensure tree/tag closure with '--stdin-packs=follow' Taylor Blau
2026-10-02 23:13 ` Jeff King
2026-10-03 0:55 ` Taylor Blau
2026-10-03 1:06 ` Jeff King
2026-10-01 4:11 ` [PATCH v2 3/8] repack: retain cruft packs in MIDXs after incremental repacks Taylor Blau
2026-10-01 4:11 ` [PATCH v2 4/8] repack: use a sorted list for explicitly kept packs Taylor Blau
2026-10-02 23:16 ` Jeff King
2026-10-01 4:11 ` [PATCH v2 5/8] repack: follow kept packs when omitting cruft from the MIDX Taylor Blau
2026-10-02 23:25 ` Jeff King
2026-10-03 0:50 ` Taylor Blau
2026-10-01 4:11 ` [PATCH v2 6/8] repack: track the preferred pack explicitly in MIDX write steps Taylor Blau
2026-10-02 23:28 ` Jeff King
2026-10-03 1:00 ` Taylor Blau
2026-10-03 1:07 ` Jeff King
2026-10-01 4:12 ` [PATCH v2 7/8] repack: defer allocating the append plan's write step Taylor Blau
2026-10-01 4:12 ` [PATCH v2 8/8] repack: include required packs in incremental MIDX writes Taylor Blau
2026-10-02 23:41 ` Jeff King
2026-10-03 1:01 ` Taylor Blau
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=64bb13e2db2e5c22e842c188e08861d63e99dc77.1790731662.git.me@ttaylorr.com \
--to=ttaylorr@openai.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@github.com \
--cc=peff@peff.net \
--cc=tnyman@openai.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