Skip to content

Commit e35ef71

Browse files
ttaylorrgitster
authored andcommitted
repack: move 'delta_base_offset' to 'struct pack_objects_args'
The static variable 'delta_base_offset' determines whether or not we pass the "--delta-base-offset" command-line argument when spawning pack-objects as a child process. Its introduction dates back to when repack was rewritten in C, all the way back in a1bbc6c (repack: rewrite the shell script in C, 2013-09-15). 'struct pack_objects_args' was introduced much later on in 4571324 (builtin/repack.c: allow configuring cruft pack generation, 2022-05-20), but did not move the 'delta_base_offset' variable. Since the 'delta_base_offset' is a property of an individual pack-objects command, re-introduce that variable as a member of 'struct pack_objects_args', which will enable further code movement in the subsequent commits. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 19f6e8d commit e35ef71

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

builtin/repack.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#define RETAIN_PACK 2
3535

3636
static int pack_everything;
37-
static int delta_base_offset = 1;
3837
static int pack_kept_objects = -1;
3938
static int write_bitmaps = -1;
4039
static int use_delta_islands;
@@ -63,9 +62,10 @@ static int repack_config(const char *var, const char *value,
6362
const struct config_context *ctx, void *cb)
6463
{
6564
struct repack_config_ctx *repack_ctx = cb;
65+
struct pack_objects_args *po_args = repack_ctx->po_args;
6666
struct pack_objects_args *cruft_po_args = repack_ctx->cruft_po_args;
6767
if (!strcmp(var, "repack.usedeltabaseoffset")) {
68-
delta_base_offset = git_config_bool(var, value);
68+
po_args->delta_base_offset = git_config_bool(var, value);
6969
return 0;
7070
}
7171
if (!strcmp(var, "repack.packkeptobjects")) {
@@ -315,7 +315,7 @@ static void prepare_pack_objects(struct child_process *cmd,
315315
strvec_push(&cmd->args, "--local");
316316
if (args->quiet)
317317
strvec_push(&cmd->args, "--quiet");
318-
if (delta_base_offset)
318+
if (args->delta_base_offset)
319319
strvec_push(&cmd->args, "--delta-base-offset");
320320
strvec_push(&cmd->args, out);
321321
cmd->git_cmd = 1;
@@ -1271,8 +1271,8 @@ int cmd_repack(int argc,
12711271
const char *unpack_unreachable = NULL;
12721272
int keep_unreachable = 0;
12731273
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
1274-
struct pack_objects_args po_args = { 0 };
1275-
struct pack_objects_args cruft_po_args = { 0 };
1274+
struct pack_objects_args po_args = PACK_OBJECTS_ARGS_INIT;
1275+
struct pack_objects_args cruft_po_args = PACK_OBJECTS_ARGS_INIT;
12761276
int write_midx = 0;
12771277
const char *cruft_expiration = NULL;
12781278
const char *expire_to = NULL;
@@ -1567,6 +1567,7 @@ int cmd_repack(int argc,
15671567

15681568
cruft_po_args.local = po_args.local;
15691569
cruft_po_args.quiet = po_args.quiet;
1570+
cruft_po_args.delta_base_offset = po_args.delta_base_offset;
15701571

15711572
ret = write_cruft_pack(&cruft_po_args, packtmp, pack_prefix,
15721573
cruft_expiration,

repack.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ struct pack_objects_args {
1515
int local;
1616
int name_hash_version;
1717
int path_walk;
18+
int delta_base_offset;
1819
struct list_objects_filter_options filter_options;
1920
};
2021

22+
#define PACK_OBJECTS_ARGS_INIT { .delta_base_offset = 1 }
23+
2124
void pack_objects_args_release(struct pack_objects_args *args);
2225

2326
#endif /* REPACK_H */

0 commit comments

Comments
 (0)