repack: remove 'prepare_pack_objects' from the builtin
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>
Taylor Blau committed
Oct 15, 2025 at 18:28 UTC
7005d2594b73d30beae7abebdd035becca05299d
3 files changed
+40
-34
builtin/repack.c
-34
@@ -288,40 +288,6 @@ static void collect_pack_filenames(struct existing_packs *existing,
288
strbuf_release(&buf);
289
}
290
291
-static void prepare_pack_objects(struct child_process *cmd,
292
- const struct pack_objects_args *args,
293
- const char *out)
294
-{
295
- strvec_push(&cmd->args, "pack-objects");
296
- if (args->window)
297
- strvec_pushf(&cmd->args, "--window=%s", args->window);
298
- if (args->window_memory)
299
- strvec_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
300
- if (args->depth)
301
- strvec_pushf(&cmd->args, "--depth=%s", args->depth);
302
- if (args->threads)
303
- strvec_pushf(&cmd->args, "--threads=%s", args->threads);
304
- if (args->max_pack_size)
305
- strvec_pushf(&cmd->args, "--max-pack-size=%lu", args->max_pack_size);
306
- if (args->no_reuse_delta)
307
- strvec_pushf(&cmd->args, "--no-reuse-delta");
308
- if (args->no_reuse_object)
309
- strvec_pushf(&cmd->args, "--no-reuse-object");
310
- if (args->name_hash_version)
311
- strvec_pushf(&cmd->args, "--name-hash-version=%d", args->name_hash_version);
312
- if (args->path_walk)
313
- strvec_pushf(&cmd->args, "--path-walk");
314
- if (args->local)
315
- strvec_push(&cmd->args, "--local");
316
- if (args->quiet)
317
- strvec_push(&cmd->args, "--quiet");
318
- if (args->delta_base_offset)
319
- strvec_push(&cmd->args, "--delta-base-offset");
320
- strvec_push(&cmd->args, out);
321
- cmd->git_cmd = 1;
322
- cmd->out = -1;
323
-}
324
-
291
struct write_oid_context {
292
struct child_process *cmd;
293
const struct git_hash_algo *algop;
repack.c
+35
@@ -1,5 +1,40 @@
1
#include "git-compat-util.h"
2
#include "repack.h"
3
+#include "run-command.h"
4
+
5
+void prepare_pack_objects(struct child_process *cmd,
6
+ const struct pack_objects_args *args,
7
+ const char *out)
8
+{
9
+ strvec_push(&cmd->args, "pack-objects");
10
+ if (args->window)
11
+ strvec_pushf(&cmd->args, "--window=%s", args->window);
12
+ if (args->window_memory)
13
+ strvec_pushf(&cmd->args, "--window-memory=%s", args->window_memory);
14
+ if (args->depth)
15
+ strvec_pushf(&cmd->args, "--depth=%s", args->depth);
16
+ if (args->threads)
17
+ strvec_pushf(&cmd->args, "--threads=%s", args->threads);
18
+ if (args->max_pack_size)
19
+ strvec_pushf(&cmd->args, "--max-pack-size=%lu", args->max_pack_size);
20
+ if (args->no_reuse_delta)
21
+ strvec_pushf(&cmd->args, "--no-reuse-delta");
22
+ if (args->no_reuse_object)
23
+ strvec_pushf(&cmd->args, "--no-reuse-object");
24
+ if (args->name_hash_version)
25
+ strvec_pushf(&cmd->args, "--name-hash-version=%d", args->name_hash_version);
26
+ if (args->path_walk)
27
+ strvec_pushf(&cmd->args, "--path-walk");
28
+ if (args->local)
29
+ strvec_push(&cmd->args, "--local");
30
+ if (args->quiet)
31
+ strvec_push(&cmd->args, "--quiet");
32
+ if (args->delta_base_offset)
33
+ strvec_push(&cmd->args, "--delta-base-offset");
34
+ strvec_push(&cmd->args, out);
35
+ cmd->git_cmd = 1;
36
+ cmd->out = -1;
37
+}
38
39
void pack_objects_args_release(struct pack_objects_args *args)
40
{
repack.h
+5
@@ -21,6 +21,11 @@ struct pack_objects_args {
21
22
#define PACK_OBJECTS_ARGS_INIT { .delta_base_offset = 1 }
23
24
+struct child_process;
25
+
26
+void prepare_pack_objects(struct child_process *cmd,
27
+ const struct pack_objects_args *args,
28
+ const char *out);
29
void pack_objects_args_release(struct pack_objects_args *args);
30
31
#endif /* REPACK_H */