]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repack: remove 'prepare_pack_objects' from the builtin
authorTaylor Blau <me@ttaylorr.com>
Wed, 15 Oct 2025 22:28:01 +0000 (18:28 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Oct 2025 17:08:54 +0000 (10:08 -0700)
Now that the 'prepare_pack_objects' function no longer refers to
external, static variables, move it out to repack.h as generic
functionality.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
repack.c
repack.h

index f4af830353232cf0f35e5ab45f08eb8f2ef76e73..ff93654cfedf2908ccc6a2e03dcac55a4b268f7b 100644 (file)
@@ -288,40 +288,6 @@ static void collect_pack_filenames(struct existing_packs *existing,
        strbuf_release(&buf);
 }
 
-static void prepare_pack_objects(struct child_process *cmd,
-                                const struct pack_objects_args *args,
-                                const char *out)
-{
-       strvec_push(&cmd->args, "pack-objects");
-       if (args->window)
-               strvec_pushf(&cmd->args, "--window=%s", args->window);
-       if (args->window_memory)
-               strvec_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
-       if (args->depth)
-               strvec_pushf(&cmd->args, "--depth=%s", args->depth);
-       if (args->threads)
-               strvec_pushf(&cmd->args, "--threads=%s", args->threads);
-       if (args->max_pack_size)
-               strvec_pushf(&cmd->args, "--max-pack-size=%lu", args->max_pack_size);
-       if (args->no_reuse_delta)
-               strvec_pushf(&cmd->args, "--no-reuse-delta");
-       if (args->no_reuse_object)
-               strvec_pushf(&cmd->args, "--no-reuse-object");
-       if (args->name_hash_version)
-               strvec_pushf(&cmd->args, "--name-hash-version=%d", args->name_hash_version);
-       if (args->path_walk)
-               strvec_pushf(&cmd->args, "--path-walk");
-       if (args->local)
-               strvec_push(&cmd->args,  "--local");
-       if (args->quiet)
-               strvec_push(&cmd->args,  "--quiet");
-       if (args->delta_base_offset)
-               strvec_push(&cmd->args,  "--delta-base-offset");
-       strvec_push(&cmd->args, out);
-       cmd->git_cmd = 1;
-       cmd->out = -1;
-}
-
 struct write_oid_context {
        struct child_process *cmd;
        const struct git_hash_algo *algop;
index a1f5b796fba005b2e96d5ab4b902f48a1788d1cb..91b6e1cc09cacdc80302af635948dd28ecb2327a 100644 (file)
--- a/repack.c
+++ b/repack.c
@@ -1,5 +1,40 @@
 #include "git-compat-util.h"
 #include "repack.h"
+#include "run-command.h"
+
+void prepare_pack_objects(struct child_process *cmd,
+                         const struct pack_objects_args *args,
+                         const char *out)
+{
+       strvec_push(&cmd->args, "pack-objects");
+       if (args->window)
+               strvec_pushf(&cmd->args, "--window=%s", args->window);
+       if (args->window_memory)
+               strvec_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
+       if (args->depth)
+               strvec_pushf(&cmd->args, "--depth=%s", args->depth);
+       if (args->threads)
+               strvec_pushf(&cmd->args, "--threads=%s", args->threads);
+       if (args->max_pack_size)
+               strvec_pushf(&cmd->args, "--max-pack-size=%lu", args->max_pack_size);
+       if (args->no_reuse_delta)
+               strvec_pushf(&cmd->args, "--no-reuse-delta");
+       if (args->no_reuse_object)
+               strvec_pushf(&cmd->args, "--no-reuse-object");
+       if (args->name_hash_version)
+               strvec_pushf(&cmd->args, "--name-hash-version=%d", args->name_hash_version);
+       if (args->path_walk)
+               strvec_pushf(&cmd->args, "--path-walk");
+       if (args->local)
+               strvec_push(&cmd->args,  "--local");
+       if (args->quiet)
+               strvec_push(&cmd->args,  "--quiet");
+       if (args->delta_base_offset)
+               strvec_push(&cmd->args,  "--delta-base-offset");
+       strvec_push(&cmd->args, out);
+       cmd->git_cmd = 1;
+       cmd->out = -1;
+}
 
 void pack_objects_args_release(struct pack_objects_args *args)
 {
index 12632d7fec16f62551652b91e8d622abe7ebffed..3f7ec207355bf7b6cb9339bd44d03538c41096e1 100644 (file)
--- a/repack.h
+++ b/repack.h
@@ -21,6 +21,11 @@ struct pack_objects_args {
 
 #define PACK_OBJECTS_ARGS_INIT { .delta_base_offset = 1 }
 
+struct child_process;
+
+void prepare_pack_objects(struct child_process *cmd,
+                         const struct pack_objects_args *args,
+                         const char *out);
 void pack_objects_args_release(struct pack_objects_args *args);
 
 #endif /* REPACK_H */