pack-objects: move revs out of get_object_list()
We intend to parse the --filter option directly into revs.filter, but we first need to move the 'revs' variable out of get_object_list() and pass it as a pointer instead. This change only deals with the issues of making that work. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Mar 22, 2022 at 17:28 UTC
80f6de4f5bd43631a9dabc9112bf80c987763035
1 file changed
+18
-15
builtin/pack-objects.c
+18
-15
@@ -3714,9 +3714,8 @@ static void mark_bitmap_preferred_tips(void)
3714
}
3715
}
3716
3717
-static void get_object_list(int ac, const char **av)
3717
+static void get_object_list(struct rev_info *revs, int ac, const char **av)
3718
{
3719
- struct rev_info revs;
3719
struct setup_revision_opt s_r_opt = {
3720
.allow_exclude_promisor_objects = 1,
3721
};
@@ -3724,10 +3723,10 @@ static void get_object_list(int ac, const char **av)
3723
int flags = 0;
3724
int save_warning;
3725
3727
- repo_init_revisions(the_repository, &revs, NULL);
3726
+ repo_init_revisions(the_repository, revs, NULL);
3727
save_commit_buffer = 0;
3729
- setup_revisions(ac, av, &revs, &s_r_opt);
3730
- list_objects_filter_copy(&revs.filter, &filter_options);
3728
+ setup_revisions(ac, av, revs, &s_r_opt);
3729
+ list_objects_filter_copy(&revs->filter, &filter_options);
3730
3731
/* make sure shallows are read */
3732
is_repository_shallow(the_repository);
@@ -3757,13 +3756,13 @@ static void get_object_list(int ac, const char **av)
3756
}
3757
die(_("not a rev '%s'"), line);
3758
}
3760
- if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME))
3759
+ if (handle_revision_arg(line, revs, flags, REVARG_CANNOT_BE_FILENAME))
3760
die(_("bad revision '%s'"), line);
3761
}
3762
3763
warn_on_object_refname_ambiguity = save_warning;
3764
3766
- if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
3765
+ if (use_bitmap_index && !get_object_list_from_bitmap(revs))
3766
return;
3767
3768
if (use_delta_islands)
@@ -3772,24 +3771,24 @@ static void get_object_list(int ac, const char **av)
3771
if (write_bitmap_index)
3772
mark_bitmap_preferred_tips();
3773
3775
- if (prepare_revision_walk(&revs))
3774
+ if (prepare_revision_walk(revs))
3775
die(_("revision walk setup failed"));
3777
- mark_edges_uninteresting(&revs, show_edge, sparse);
3776
+ mark_edges_uninteresting(revs, show_edge, sparse);
3777
3778
if (!fn_show_object)
3779
fn_show_object = show_object;
3781
- traverse_commit_list(&revs,
3780
+ traverse_commit_list(revs,
3781
show_commit, fn_show_object,
3782
NULL);
3783
3784
if (unpack_unreachable_expiration) {
3786
- revs.ignore_missing_links = 1;
3787
- if (add_unseen_recent_objects_to_traversal(&revs,
3785
+ revs->ignore_missing_links = 1;
3786
+ if (add_unseen_recent_objects_to_traversal(revs,
3787
unpack_unreachable_expiration))
3788
die(_("unable to add recent objects"));
3790
- if (prepare_revision_walk(&revs))
3789
+ if (prepare_revision_walk(revs))
3790
die(_("revision walk setup failed"));
3792
- traverse_commit_list(&revs, record_recent_commit,
3791
+ traverse_commit_list(revs, record_recent_commit,
3792
record_recent_object, NULL);
3793
}
3794
@@ -3872,6 +3871,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3871
int rev_list_index = 0;
3872
int stdin_packs = 0;
3873
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
3874
+ struct rev_info revs;
3875
+
3876
struct option pack_objects_options[] = {
3877
OPT_SET_INT('q', "quiet", &progress,
3878
N_("do not show progress meter"), 0),
@@ -3976,6 +3977,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3977
3978
read_replace_refs = 0;
3979
3980
+ repo_init_revisions(the_repository, &revs, NULL);
3981
+
3982
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
3983
if (the_repository->gitdir) {
3984
prepare_repo_settings(the_repository);
@@ -4154,7 +4157,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
4157
} else if (!use_internal_rev_list) {
4158
read_object_list_from_stdin();
4159
} else {
4157
- get_object_list(rp.nr, rp.v);
4160
+ get_object_list(&revs, rp.nr, rp.v);
4161
}
4162
cleanup_preferred_base();
4163
if (include_tag && nr_result)