@ -237,8 +237,6 @@ static unsigned long cache_max_small_delta_size = 1000;
@@ -237,8 +237,6 @@ static unsigned long cache_max_small_delta_size = 1000;
static unsigned long window_memory_limit = 0;
static struct list_objects_filter_options filter_options;
static struct string_list uri_protocols = STRING_LIST_INIT_NODUP;
enum missing_action {
@ -3724,9 +3722,8 @@ static void mark_bitmap_preferred_tips(void)
@@ -3724,9 +3722,8 @@ static void mark_bitmap_preferred_tips(void)
}
}
static void get_object_list(int ac, const char **av)
static void get_object_list(struct rev_info *revs, int ac, const char **av)
{
struct rev_info revs;
struct setup_revision_opt s_r_opt = {
.allow_exclude_promisor_objects = 1,
};
@ -3734,10 +3731,8 @@ static void get_object_list(int ac, const char **av)
@@ -3734,10 +3731,8 @@ static void get_object_list(int ac, const char **av)
int flags = 0;
int save_warning;
repo_init_revisions(the_repository, &revs, NULL);
save_commit_buffer = 0;
setup_revisions(ac, av, &revs, &s_r_opt);
list_objects_filter_copy(&revs.filter, &filter_options);
setup_revisions(ac, av, revs, &s_r_opt);
/* make sure shallows are read */
is_repository_shallow(the_repository);
@ -3767,13 +3762,13 @@ static void get_object_list(int ac, const char **av)
@@ -3767,13 +3762,13 @@ static void get_object_list(int ac, const char **av)
}
die(_("not a rev '%s'"), line);
}
if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME))
if (handle_revision_arg(line, revs, flags, REVARG_CANNOT_BE_FILENAME))
die(_("bad revision '%s'"), line);
}
warn_on_object_refname_ambiguity = save_warning;
if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
if (use_bitmap_index && !get_object_list_from_bitmap(revs))
return;
if (use_delta_islands)
@ -3782,24 +3777,24 @@ static void get_object_list(int ac, const char **av)
@@ -3782,24 +3777,24 @@ static void get_object_list(int ac, const char **av)
if (write_bitmap_index)
mark_bitmap_preferred_tips();
if (prepare_revision_walk(&revs))
if (prepare_revision_walk(revs))
die(_("revision walk setup failed"));
mark_edges_uninteresting(&revs, show_edge, sparse);
mark_edges_uninteresting(revs, show_edge, sparse);
if (!fn_show_object)
fn_show_object = show_object;
traverse_commit_list(&revs,
traverse_commit_list(revs,
show_commit, fn_show_object,
NULL);
if (unpack_unreachable_expiration) {
revs.ignore_missing_links = 1;
if (add_unseen_recent_objects_to_traversal(&revs,
revs->ignore_missing_links = 1;
if (add_unseen_recent_objects_to_traversal(revs,
unpack_unreachable_expiration))
die(_("unable to add recent objects"));
if (prepare_revision_walk(&revs))
if (prepare_revision_walk(revs))
die(_("revision walk setup failed"));
traverse_commit_list(&revs, record_recent_commit,
traverse_commit_list(revs, record_recent_commit,
record_recent_object, NULL);
}
@ -3872,6 +3867,21 @@ static int option_parse_unpack_unreachable(const struct option *opt,
@@ -3872,6 +3867,21 @@ static int option_parse_unpack_unreachable(const struct option *opt,
return 0;
}
struct po_filter_data {
unsigned have_revs:1;
struct rev_info revs;
};
static struct list_objects_filter_options *po_filter_revs_init(void *value)
{
struct po_filter_data *data = value;
repo_init_revisions(the_repository, &data->revs, NULL);
data->have_revs = 1;
return &data->revs.filter;
}
int cmd_pack_objects(int argc, const char **argv, const char *prefix)
{
int use_internal_rev_list = 0;
@ -3882,6 +3892,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
@@ -3882,6 +3892,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
int rev_list_index = 0;
int stdin_packs = 0;
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
struct po_filter_data pfd = { .have_revs = 0 };
struct option pack_objects_options[] = {
OPT_SET_INT('q', "quiet", &progress,
N_("do not show progress meter"), 0),
@ -3967,7 +3979,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
@@ -3967,7 +3979,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
&write_bitmap_index,
N_("write a bitmap index if possible"),
WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN),
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
OPT_PARSE_LIST_OBJECTS_FILTER_INIT(&pfd, po_filter_revs_init),
OPT_CALLBACK_F(0, "missing", NULL, N_("action"),
N_("handling for missing objects"), PARSE_OPT_NONEG,
option_parse_missing_action),
@ -4087,7 +4099,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
@@ -4087,7 +4099,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
unpack_unreachable_expiration = 0;
if (filter_options.choice) {
if (pfd.have_revs && pfd.revs.filter.choice) {
if (!pack_to_stdout)
die(_("cannot use --filter without --stdout"));
if (stdin_packs)
@ -4163,8 +4175,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
@@ -4163,8 +4175,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
add_unreachable_loose_objects();
} else if (!use_internal_rev_list) {
read_object_list_from_stdin();
} else if (pfd.have_revs) {
get_object_list(&pfd.revs, rp.nr, rp.v);
} else {
get_object_list(rp.nr, rp.v);
struct rev_info revs;
repo_init_revisions(the_repository, &revs, NULL);
get_object_list(&revs, rp.nr, rp.v);
}
cleanup_preferred_base();
if (include_tag && nr_result)