@@ -237,8 +237,6 @@ static unsigned long cache_max_small_delta_size = 1000;
237237
238238static unsigned long window_memory_limit = 0 ;
239239
240- static struct list_objects_filter_options filter_options ;
241-
242240static struct string_list uri_protocols = STRING_LIST_INIT_NODUP ;
243241
244242enum missing_action {
@@ -3724,20 +3722,17 @@ static void mark_bitmap_preferred_tips(void)
37243722 }
37253723}
37263724
3727- static void get_object_list (int ac , const char * * av )
3725+ static void get_object_list (struct rev_info * revs , int ac , const char * * av )
37283726{
3729- struct rev_info revs ;
37303727 struct setup_revision_opt s_r_opt = {
37313728 .allow_exclude_promisor_objects = 1 ,
37323729 };
37333730 char line [1000 ];
37343731 int flags = 0 ;
37353732 int save_warning ;
37363733
3737- repo_init_revisions (the_repository , & revs , NULL );
37383734 save_commit_buffer = 0 ;
3739- setup_revisions (ac , av , & revs , & s_r_opt );
3740- list_objects_filter_copy (& revs .filter , & filter_options );
3735+ setup_revisions (ac , av , revs , & s_r_opt );
37413736
37423737 /* make sure shallows are read */
37433738 is_repository_shallow (the_repository );
@@ -3767,13 +3762,13 @@ static void get_object_list(int ac, const char **av)
37673762 }
37683763 die (_ ("not a rev '%s'" ), line );
37693764 }
3770- if (handle_revision_arg (line , & revs , flags , REVARG_CANNOT_BE_FILENAME ))
3765+ if (handle_revision_arg (line , revs , flags , REVARG_CANNOT_BE_FILENAME ))
37713766 die (_ ("bad revision '%s'" ), line );
37723767 }
37733768
37743769 warn_on_object_refname_ambiguity = save_warning ;
37753770
3776- if (use_bitmap_index && !get_object_list_from_bitmap (& revs ))
3771+ if (use_bitmap_index && !get_object_list_from_bitmap (revs ))
37773772 return ;
37783773
37793774 if (use_delta_islands )
@@ -3782,24 +3777,24 @@ static void get_object_list(int ac, const char **av)
37823777 if (write_bitmap_index )
37833778 mark_bitmap_preferred_tips ();
37843779
3785- if (prepare_revision_walk (& revs ))
3780+ if (prepare_revision_walk (revs ))
37863781 die (_ ("revision walk setup failed" ));
3787- mark_edges_uninteresting (& revs , show_edge , sparse );
3782+ mark_edges_uninteresting (revs , show_edge , sparse );
37883783
37893784 if (!fn_show_object )
37903785 fn_show_object = show_object ;
3791- traverse_commit_list (& revs ,
3786+ traverse_commit_list (revs ,
37923787 show_commit , fn_show_object ,
37933788 NULL );
37943789
37953790 if (unpack_unreachable_expiration ) {
3796- revs . ignore_missing_links = 1 ;
3797- if (add_unseen_recent_objects_to_traversal (& revs ,
3791+ revs -> ignore_missing_links = 1 ;
3792+ if (add_unseen_recent_objects_to_traversal (revs ,
37983793 unpack_unreachable_expiration ))
37993794 die (_ ("unable to add recent objects" ));
3800- if (prepare_revision_walk (& revs ))
3795+ if (prepare_revision_walk (revs ))
38013796 die (_ ("revision walk setup failed" ));
3802- traverse_commit_list (& revs , record_recent_commit ,
3797+ traverse_commit_list (revs , record_recent_commit ,
38033798 record_recent_object , NULL );
38043799 }
38053800
@@ -3872,6 +3867,21 @@ static int option_parse_unpack_unreachable(const struct option *opt,
38723867 return 0 ;
38733868}
38743869
3870+ struct po_filter_data {
3871+ unsigned have_revs :1 ;
3872+ struct rev_info revs ;
3873+ };
3874+
3875+ static struct list_objects_filter_options * po_filter_revs_init (void * value )
3876+ {
3877+ struct po_filter_data * data = value ;
3878+
3879+ repo_init_revisions (the_repository , & data -> revs , NULL );
3880+ data -> have_revs = 1 ;
3881+
3882+ return & data -> revs .filter ;
3883+ }
3884+
38753885int cmd_pack_objects (int argc , const char * * argv , const char * prefix )
38763886{
38773887 int use_internal_rev_list = 0 ;
@@ -3882,6 +3892,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
38823892 int rev_list_index = 0 ;
38833893 int stdin_packs = 0 ;
38843894 struct string_list keep_pack_list = STRING_LIST_INIT_NODUP ;
3895+ struct po_filter_data pfd = { .have_revs = 0 };
3896+
38853897 struct option pack_objects_options [] = {
38863898 OPT_SET_INT ('q' , "quiet" , & progress ,
38873899 N_ ("do not show progress meter" ), 0 ),
@@ -3967,7 +3979,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
39673979 & write_bitmap_index ,
39683980 N_ ("write a bitmap index if possible" ),
39693981 WRITE_BITMAP_QUIET , PARSE_OPT_HIDDEN ),
3970- OPT_PARSE_LIST_OBJECTS_FILTER ( & filter_options ),
3982+ OPT_PARSE_LIST_OBJECTS_FILTER_INIT ( & pfd , po_filter_revs_init ),
39713983 OPT_CALLBACK_F (0 , "missing" , NULL , N_ ("action" ),
39723984 N_ ("handling for missing objects" ), PARSE_OPT_NONEG ,
39733985 option_parse_missing_action ),
@@ -4087,7 +4099,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
40874099 if (!rev_list_all || !rev_list_reflog || !rev_list_index )
40884100 unpack_unreachable_expiration = 0 ;
40894101
4090- if (filter_options .choice ) {
4102+ if (pfd . have_revs && pfd . revs . filter .choice ) {
40914103 if (!pack_to_stdout )
40924104 die (_ ("cannot use --filter without --stdout" ));
40934105 if (stdin_packs )
@@ -4163,8 +4175,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
41634175 add_unreachable_loose_objects ();
41644176 } else if (!use_internal_rev_list ) {
41654177 read_object_list_from_stdin ();
4178+ } else if (pfd .have_revs ) {
4179+ get_object_list (& pfd .revs , rp .nr , rp .v );
41664180 } else {
4167- get_object_list (rp .nr , rp .v );
4181+ struct rev_info revs ;
4182+
4183+ repo_init_revisions (the_repository , & revs , NULL );
4184+ get_object_list (& revs , rp .nr , rp .v );
41684185 }
41694186 cleanup_preferred_base ();
41704187 if (include_tag && nr_result )
0 commit comments