Skip to content

Commit 7005d25

Browse files
ttaylorrgitster
authored andcommitted
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>
1 parent e35ef71 commit 7005d25

3 files changed

Lines changed: 40 additions & 34 deletions

File tree

builtin/repack.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -288,40 +288,6 @@ static void collect_pack_filenames(struct existing_packs *existing,
288288
strbuf_release(&buf);
289289
}
290290

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-
325291
struct write_oid_context {
326292
struct child_process *cmd;
327293
const struct git_hash_algo *algop;

repack.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
#include "git-compat-util.h"
22
#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+
}
338

439
void pack_objects_args_release(struct pack_objects_args *args)
540
{

repack.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ struct pack_objects_args {
2121

2222
#define PACK_OBJECTS_ARGS_INIT { .delta_base_offset = 1 }
2323

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);
2429
void pack_objects_args_release(struct pack_objects_args *args);
2530

2631
#endif /* REPACK_H */

0 commit comments

Comments
 (0)