[PATCH 2/4] repack: populate extension bits incrementally
- From
Jeff King <peff@peff.net>
- Date
- Oct 21, 2022, 21:43 UTC
- Message-ID
- <Y1MSkubbDBh0Ma1G@coredump.intra.peff.net>
- In-Reply-To
- <Y1MR7V8kGolLd8eh@coredump.intra.peff.net>
After generating the main pack and then any additional cruft packs, we iterate over the "names" list (which contains hashes of packs generated by pack-objects), and call populate_pack_exts() for each.
There are two small problems with this:
- repack_promisor_objects() may have added entries to "names", and
already called populate_pack_exts() for them. This is mostly just
wasteful, as we'll stat() the filename with each possible extension,
get the same result, and just overwrite our bits. But it makes the
code flow confusing, and it will become a problem if we try to make
populate_pack_exts() do more things. - it would be nice to record the generated filenames as soon as
possible. We don't currently use them for cleaning up from a failed
operation, but a future patch will do so.Signed-off-by: Jeff King <peff@peff.net> --- builtin/repack.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c index 8e71230bf7..b5bd9e5fed 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -714,10 +714,14 @@ static int write_cruft_pack(const struct pack_objects_args *args, out = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, out) != EOF) { + struct string_list_item *item; + if (line.len != the_hash_algo->hexsz) die(_("repack: Expecting full hex object ID lines only " "from pack-objects.")); - string_list_append(names, line.buf); + + item = string_list_append(names, line.buf); + item->util = populate_pack_exts(line.buf); } fclose(out); @@ -956,9 +960,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix) out = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, out) != EOF) { + struct string_list_item *item; + if (line.len != the_hash_algo->hexsz) die(_("repack: Expecting full hex object ID lines only from pack-objects.")); - string_list_append(&names, line.buf); + item = string_list_append(&names, line.buf); + item->util = populate_pack_exts(item->string); } fclose(out); ret = finish_command(&cmd); @@ -997,10 +1004,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix) string_list_sort(&names); - for_each_string_list_item(item, &names) { - item->util = populate_pack_exts(item->string); - } - close_object_store(the_repository->objects); /*
-- 2.38.1.496.ga614b0e9bd