@@ -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 {
@@ -3714,20 +3712,17 @@ static void mark_bitmap_preferred_tips(void)
37143712 }
37153713}
37163714
3717- static void get_object_list (int ac , const char * * av )
3715+ static void get_object_list (struct rev_info * revs , int ac , const char * * av )
37183716{
3719- struct rev_info revs ;
37203717 struct setup_revision_opt s_r_opt = {
37213718 .allow_exclude_promisor_objects = 1 ,
37223719 };
37233720 char line [1000 ];
37243721 int flags = 0 ;
37253722 int save_warning ;
37263723
3727- repo_init_revisions (the_repository , & revs , NULL );
37283724 save_commit_buffer = 0 ;
3729- setup_revisions (ac , av , & revs , & s_r_opt );
3730- list_objects_filter_copy (& revs .filter , & filter_options );
3725+ setup_revisions (ac , av , revs , & s_r_opt );
37313726
37323727 /* make sure shallows are read */
37333728 is_repository_shallow (the_repository );
@@ -3757,13 +3752,13 @@ static void get_object_list(int ac, const char **av)
37573752 }
37583753 die (_ ("not a rev '%s'" ), line );
37593754 }
3760- if (handle_revision_arg (line , & revs , flags , REVARG_CANNOT_BE_FILENAME ))
3755+ if (handle_revision_arg (line , revs , flags , REVARG_CANNOT_BE_FILENAME ))
37613756 die (_ ("bad revision '%s'" ), line );
37623757 }
37633758
37643759 warn_on_object_refname_ambiguity = save_warning ;
37653760
3766- if (use_bitmap_index && !get_object_list_from_bitmap (& revs ))
3761+ if (use_bitmap_index && !get_object_list_from_bitmap (revs ))
37673762 return ;
37683763
37693764 if (use_delta_islands )
@@ -3772,24 +3767,24 @@ static void get_object_list(int ac, const char **av)
37723767 if (write_bitmap_index )
37733768 mark_bitmap_preferred_tips ();
37743769
3775- if (prepare_revision_walk (& revs ))
3770+ if (prepare_revision_walk (revs ))
37763771 die (_ ("revision walk setup failed" ));
3777- mark_edges_uninteresting (& revs , show_edge , sparse );
3772+ mark_edges_uninteresting (revs , show_edge , sparse );
37783773
37793774 if (!fn_show_object )
37803775 fn_show_object = show_object ;
3781- traverse_commit_list (& revs ,
3776+ traverse_commit_list (revs ,
37823777 show_commit , fn_show_object ,
37833778 NULL );
37843779
37853780 if (unpack_unreachable_expiration ) {
3786- revs . ignore_missing_links = 1 ;
3787- if (add_unseen_recent_objects_to_traversal (& revs ,
3781+ revs -> ignore_missing_links = 1 ;
3782+ if (add_unseen_recent_objects_to_traversal (revs ,
37883783 unpack_unreachable_expiration ))
37893784 die (_ ("unable to add recent objects" ));
3790- if (prepare_revision_walk (& revs ))
3785+ if (prepare_revision_walk (revs ))
37913786 die (_ ("revision walk setup failed" ));
3792- traverse_commit_list (& revs , record_recent_commit ,
3787+ traverse_commit_list (revs , record_recent_commit ,
37933788 record_recent_object , NULL );
37943789 }
37953790
@@ -3862,6 +3857,21 @@ static int option_parse_unpack_unreachable(const struct option *opt,
38623857 return 0 ;
38633858}
38643859
3860+ struct po_filter_data {
3861+ unsigned have_revs :1 ;
3862+ struct rev_info revs ;
3863+ };
3864+
3865+ static struct list_objects_filter_options * po_filter_revs_init (void * value )
3866+ {
3867+ struct po_filter_data * data = value ;
3868+
3869+ repo_init_revisions (the_repository , & data -> revs , NULL );
3870+ data -> have_revs = 1 ;
3871+
3872+ return & data -> revs .filter ;
3873+ }
3874+
38653875int cmd_pack_objects (int argc , const char * * argv , const char * prefix )
38663876{
38673877 int use_internal_rev_list = 0 ;
@@ -3872,6 +3882,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
38723882 int rev_list_index = 0 ;
38733883 int stdin_packs = 0 ;
38743884 struct string_list keep_pack_list = STRING_LIST_INIT_NODUP ;
3885+ struct po_filter_data pfd = { .have_revs = 0 };
3886+
38753887 struct option pack_objects_options [] = {
38763888 OPT_SET_INT ('q' , "quiet" , & progress ,
38773889 N_ ("do not show progress meter" ), 0 ),
@@ -3957,7 +3969,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
39573969 & write_bitmap_index ,
39583970 N_ ("write a bitmap index if possible" ),
39593971 WRITE_BITMAP_QUIET , PARSE_OPT_HIDDEN ),
3960- OPT_PARSE_LIST_OBJECTS_FILTER ( & filter_options ),
3972+ OPT_PARSE_LIST_OBJECTS_FILTER_INIT ( & pfd , po_filter_revs_init ),
39613973 OPT_CALLBACK_F (0 , "missing" , NULL , N_ ("action" ),
39623974 N_ ("handling for missing objects" ), PARSE_OPT_NONEG ,
39633975 option_parse_missing_action ),
@@ -4077,7 +4089,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
40774089 if (!rev_list_all || !rev_list_reflog || !rev_list_index )
40784090 unpack_unreachable_expiration = 0 ;
40794091
4080- if (filter_options .choice ) {
4092+ if (pfd . have_revs && pfd . revs . filter .choice ) {
40814093 if (!pack_to_stdout )
40824094 die (_ ("cannot use --filter without --stdout" ));
40834095 if (stdin_packs )
@@ -4153,8 +4165,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
41534165 add_unreachable_loose_objects ();
41544166 } else if (!use_internal_rev_list ) {
41554167 read_object_list_from_stdin ();
4168+ } else if (pfd .have_revs ) {
4169+ get_object_list (& pfd .revs , rp .nr , rp .v );
41564170 } else {
4157- get_object_list (rp .nr , rp .v );
4171+ struct rev_info revs ;
4172+
4173+ repo_init_revisions (the_repository , & revs , NULL );
4174+ get_object_list (& revs , rp .nr , rp .v );
41584175 }
41594176 cleanup_preferred_base ();
41604177 if (include_tag && nr_result )
0 commit comments