summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/repack.c20
-rw-r--r--repack-geometry.c5
-rw-r--r--repack.c2
-rw-r--r--repack.h9
4 files changed, 17 insertions, 19 deletions
diff --git a/builtin/repack.c b/builtin/repack.c
index 71abcfa0b7..3c6d7e91fd 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -33,7 +33,6 @@
#define RETAIN_PACK 2
static int pack_everything;
-static int pack_kept_objects = -1;
static int write_bitmaps = -1;
static int use_delta_islands;
static int run_update_server_info = 1;
@@ -68,7 +67,7 @@ static int repack_config(const char *var, const char *value,
return 0;
}
if (!strcmp(var, "repack.packkeptobjects")) {
- pack_kept_objects = git_config_bool(var, value);
+ po_args->pack_kept_objects = git_config_bool(var, value);
return 0;
}
if (!strcmp(var, "repack.writebitmaps") ||
@@ -122,8 +121,6 @@ static int write_filtered_pack(const struct write_pack_opts *opts,
strvec_push(&cmd.args, "--stdin-packs");
- if (!pack_kept_objects)
- strvec_push(&cmd.args, "--honor-pack-keep");
for_each_string_list_item(item, &existing->kept_packs)
strvec_pushf(&cmd.args, "--keep-pack=%s", item->string);
@@ -146,7 +143,7 @@ static int write_filtered_pack(const struct write_pack_opts *opts,
fprintf(in, "%s.pack\n", item->string);
for_each_string_list_item(item, &existing->cruft_packs)
fprintf(in, "%s.pack\n", item->string);
- caret = pack_kept_objects ? "" : "^";
+ caret = opts->po_args->pack_kept_objects ? "" : "^";
for_each_string_list_item(item, &existing->kept_packs)
fprintf(in, "%s%s.pack\n", caret, item->string);
fclose(in);
@@ -208,7 +205,6 @@ static int write_cruft_pack(const struct write_pack_opts *opts,
strvec_pushf(&cmd.args, "--cruft-expiration=%s",
cruft_expiration);
- strvec_push(&cmd.args, "--honor-pack-keep");
strvec_push(&cmd.args, "--non-empty");
cmd.in = -1;
@@ -332,7 +328,7 @@ int cmd_repack(int argc,
OPT_UNSIGNED(0, "max-pack-size", &po_args.max_pack_size,
N_("maximum size of each packfile")),
OPT_PARSE_LIST_OBJECTS_FILTER(&po_args.filter_options),
- OPT_BOOL(0, "pack-kept-objects", &pack_kept_objects,
+ OPT_BOOL(0, "pack-kept-objects", &po_args.pack_kept_objects,
N_("repack objects in packs marked with .keep")),
OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
N_("do not repack this pack")),
@@ -378,8 +374,8 @@ int cmd_repack(int argc,
(!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))
write_bitmaps = 0;
}
- if (pack_kept_objects < 0)
- pack_kept_objects = write_bitmaps > 0 && !write_midx;
+ if (po_args.pack_kept_objects < 0)
+ po_args.pack_kept_objects = write_bitmaps > 0 && !write_midx;
if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)
die(_(incremental_bitmap_conflict_error));
@@ -420,8 +416,7 @@ int cmd_repack(int argc,
if (geometry.split_factor) {
if (pack_everything)
die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
- pack_geometry_init(&geometry, &existing, &po_args,
- pack_kept_objects);
+ pack_geometry_init(&geometry, &existing, &po_args);
pack_geometry_split(&geometry);
}
@@ -430,8 +425,6 @@ int cmd_repack(int argc,
show_progress = !po_args.quiet && isatty(2);
strvec_push(&cmd.args, "--keep-true-parents");
- if (!pack_kept_objects)
- strvec_push(&cmd.args, "--honor-pack-keep");
for (i = 0; i < keep_pack_list.nr; i++)
strvec_pushf(&cmd.args, "--keep-pack=%s",
keep_pack_list.items[i].string);
@@ -581,6 +574,7 @@ int cmd_repack(int argc,
cruft_po_args.local = po_args.local;
cruft_po_args.quiet = po_args.quiet;
cruft_po_args.delta_base_offset = po_args.delta_base_offset;
+ cruft_po_args.pack_kept_objects = 0;
ret = write_cruft_pack(&opts, cruft_expiration,
combine_cruft_below_size, &names,
diff --git a/repack-geometry.c b/repack-geometry.c
index f58f1fc7f0..e2f9794d7d 100644
--- a/repack-geometry.c
+++ b/repack-geometry.c
@@ -27,8 +27,7 @@ static int pack_geometry_cmp(const void *va, const void *vb)
void pack_geometry_init(struct pack_geometry *geometry,
struct existing_packs *existing,
- const struct pack_objects_args *args,
- int pack_kept_objects)
+ const struct pack_objects_args *args)
{
struct packfile_store *packs = existing->repo->objects->packfiles;
struct packed_git *p;
@@ -43,7 +42,7 @@ void pack_geometry_init(struct pack_geometry *geometry,
*/
continue;
- if (!pack_kept_objects) {
+ if (!args->pack_kept_objects) {
/*
* Any pack that has its pack_keep bit set will
* appear in existing->kept_packs below, but
diff --git a/repack.c b/repack.c
index 2c478970f3..2ab33c665a 100644
--- a/repack.c
+++ b/repack.c
@@ -38,6 +38,8 @@ void prepare_pack_objects(struct child_process *cmd,
strvec_push(&cmd->args, "--quiet");
if (args->delta_base_offset)
strvec_push(&cmd->args, "--delta-base-offset");
+ if (!args->pack_kept_objects)
+ strvec_push(&cmd->args, "--honor-pack-keep");
strvec_push(&cmd->args, out);
cmd->git_cmd = 1;
cmd->out = -1;
diff --git a/repack.h b/repack.h
index 3244f601e2..0432379815 100644
--- a/repack.h
+++ b/repack.h
@@ -17,10 +17,14 @@ struct pack_objects_args {
int name_hash_version;
int path_walk;
int delta_base_offset;
+ int pack_kept_objects;
struct list_objects_filter_options filter_options;
};
-#define PACK_OBJECTS_ARGS_INIT { .delta_base_offset = 1 }
+#define PACK_OBJECTS_ARGS_INIT { \
+ .delta_base_offset = 1, \
+ .pack_kept_objects = -1, \
+}
struct child_process;
@@ -104,8 +108,7 @@ struct pack_geometry {
void pack_geometry_init(struct pack_geometry *geometry,
struct existing_packs *existing,
- const struct pack_objects_args *args,
- int pack_kept_objects);
+ const struct pack_objects_args *args);
void pack_geometry_split(struct pack_geometry *geometry);
struct packed_git *pack_geometry_preferred_pack(struct pack_geometry *geometry);
void pack_geometry_remove_redundant(struct pack_geometry *geometry,