aboutsummaryrefslogtreecommitdiff
path: root/repack.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-10-15 18:29:30 -0400
committerJunio C Hamano <gitster@pobox.com>2025-10-16 10:08:56 -0700
commitfa0787a6cc1d8e7ef1e2e8398bdc13b987c61d69 (patch)
tree28425ca729aabf060a21965bb9863c9c28bed898 /repack.c
parent80db3cd18985609340f40b2b06f4ef9f86a2cbe0 (diff)
downloadgit-fa0787a6cc1d8e7ef1e2e8398bdc13b987c61d69.tar.xz
repack: move `finish_pack_objects_cmd()` out of the builtin
In a similar spirit as the previous commit(s), now that the function `finish_pack_objects_cmd()` has no explicit dependencies within the repack builtin, let's extract it. This prepares us to extract the remaining two functions within the repack builtin that explicitly write packfiles, which are `write_cruft_pack()` and `write_filtered_pack()`, which will be done in the future commits. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repack.c')
-rw-r--r--repack.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/repack.c b/repack.c
index d2ee9f2460..2c478970f3 100644
--- a/repack.c
+++ b/repack.c
@@ -82,6 +82,39 @@ bool write_pack_opts_is_local(const struct write_pack_opts *opts)
return starts_with(opts->destination, opts->packdir);
}
+int finish_pack_objects_cmd(const struct git_hash_algo *algop,
+ const struct write_pack_opts *opts,
+ struct child_process *cmd,
+ struct string_list *names)
+{
+ FILE *out;
+ bool local = write_pack_opts_is_local(opts);
+ struct strbuf line = STRBUF_INIT;
+
+ out = xfdopen(cmd->out, "r");
+ while (strbuf_getline_lf(&line, out) != EOF) {
+ struct string_list_item *item;
+
+ if (line.len != algop->hexsz)
+ die(_("repack: Expecting full hex object ID lines only "
+ "from pack-objects."));
+ /*
+ * Avoid putting packs written outside of the repository in the
+ * list of names.
+ */
+ if (local) {
+ item = string_list_append(names, line.buf);
+ item->util = generated_pack_populate(line.buf,
+ opts->packtmp);
+ }
+ }
+ fclose(out);
+
+ strbuf_release(&line);
+
+ return finish_command(cmd);
+}
+
#define DELETE_PACK 1
#define RETAIN_PACK 2