@@ -97,7 +97,6 @@ static struct strbuf default_rla = STRBUF_INIT;
9797static struct transport * gtransport ;
9898static struct transport * gsecondary ;
9999static struct refspec refmap = REFSPEC_INIT_FETCH ;
100- static struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT ;
101100static struct string_list server_options = STRING_LIST_INIT_DUP ;
102101static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP ;
103102
@@ -1562,7 +1561,8 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
15621561 smart_options -> negotiation_tips = oids ;
15631562}
15641563
1565- static struct transport * prepare_transport (struct remote * remote , int deepen )
1564+ static struct transport * prepare_transport (struct remote * remote , int deepen ,
1565+ struct list_objects_filter_options * filter_options )
15661566{
15671567 struct transport * transport ;
15681568
@@ -1586,9 +1586,9 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
15861586 set_option (transport , TRANS_OPT_UPDATE_SHALLOW , "yes" );
15871587 if (refetch )
15881588 set_option (transport , TRANS_OPT_REFETCH , "yes" );
1589- if (filter_options . choice ) {
1589+ if (filter_options -> choice ) {
15901590 const char * spec =
1591- expand_list_objects_filter_spec (& filter_options );
1591+ expand_list_objects_filter_spec (filter_options );
15921592 set_option (transport , TRANS_OPT_LIST_OBJECTS_FILTER , spec );
15931593 set_option (transport , TRANS_OPT_FROM_PROMISOR , "1" );
15941594 }
@@ -1607,7 +1607,8 @@ static int backfill_tags(struct display_state *display_state,
16071607 struct ref * ref_map ,
16081608 struct fetch_head * fetch_head ,
16091609 const struct fetch_config * config ,
1610- struct ref_update_display_info_array * display_array )
1610+ struct ref_update_display_info_array * display_array ,
1611+ struct list_objects_filter_options * filter_options )
16111612{
16121613 int retcode , cannot_reuse ;
16131614
@@ -1621,7 +1622,7 @@ static int backfill_tags(struct display_state *display_state,
16211622 cannot_reuse = transport -> cannot_reuse ||
16221623 deepen_since || deepen_not .nr ;
16231624 if (cannot_reuse ) {
1624- gsecondary = prepare_transport (transport -> remote , 0 );
1625+ gsecondary = prepare_transport (transport -> remote , 0 , filter_options );
16251626 transport = gsecondary ;
16261627 }
16271628
@@ -1834,7 +1835,8 @@ static int commit_ref_transaction(struct ref_transaction **transaction,
18341835
18351836static int do_fetch (struct transport * transport ,
18361837 struct refspec * rs ,
1837- const struct fetch_config * config )
1838+ const struct fetch_config * config ,
1839+ struct list_objects_filter_options * filter_options )
18381840{
18391841 struct ref_transaction * transaction = NULL ;
18401842 struct ref * ref_map = NULL ;
@@ -1997,7 +1999,7 @@ static int do_fetch(struct transport *transport,
19971999 * the transaction and don't commit anything.
19982000 */
19992001 if (backfill_tags (& display_state , transport , transaction , tags_ref_map ,
2000- & fetch_head , config , & display_array ))
2002+ & fetch_head , config , & display_array , filter_options ))
20012003 retcode = 1 ;
20022004 }
20032005
@@ -2339,20 +2341,21 @@ static int fetch_multiple(struct string_list *list, int max_children,
23392341 * Fetching from the promisor remote should use the given filter-spec
23402342 * or inherit the default filter-spec from the config.
23412343 */
2342- static inline void fetch_one_setup_partial (struct remote * remote )
2344+ static inline void fetch_one_setup_partial (struct remote * remote ,
2345+ struct list_objects_filter_options * filter_options )
23432346{
23442347 /*
23452348 * Explicit --no-filter argument overrides everything, regardless
23462349 * of any prior partial clones and fetches.
23472350 */
2348- if (filter_options . no_filter )
2351+ if (filter_options -> no_filter )
23492352 return ;
23502353
23512354 /*
23522355 * If no prior partial clone/fetch and the current fetch DID NOT
23532356 * request a partial-fetch, do a normal fetch.
23542357 */
2355- if (!repo_has_promisor_remote (the_repository ) && !filter_options . choice )
2358+ if (!repo_has_promisor_remote (the_repository ) && !filter_options -> choice )
23562359 return ;
23572360
23582361 /*
@@ -2361,8 +2364,8 @@ static inline void fetch_one_setup_partial(struct remote *remote)
23612364 * filter-spec as the default for subsequent fetches to this
23622365 * remote if there is currently no default filter-spec.
23632366 */
2364- if (filter_options . choice ) {
2365- partial_clone_register (remote -> name , & filter_options );
2367+ if (filter_options -> choice ) {
2368+ partial_clone_register (remote -> name , filter_options );
23662369 return ;
23672370 }
23682371
@@ -2371,14 +2374,15 @@ static inline void fetch_one_setup_partial(struct remote *remote)
23712374 * explicitly given filter-spec or inherit the filter-spec from
23722375 * the config.
23732376 */
2374- if (!filter_options . choice )
2375- partial_clone_get_default_filter_spec (& filter_options , remote -> name );
2377+ if (!filter_options -> choice )
2378+ partial_clone_get_default_filter_spec (filter_options , remote -> name );
23762379 return ;
23772380}
23782381
23792382static int fetch_one (struct remote * remote , int argc , const char * * argv ,
23802383 int prune_tags_ok , int use_stdin_refspecs ,
2381- const struct fetch_config * config )
2384+ const struct fetch_config * config ,
2385+ struct list_objects_filter_options * filter_options )
23822386{
23832387 struct refspec rs = REFSPEC_INIT_FETCH ;
23842388 int i ;
@@ -2390,7 +2394,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
23902394 die (_ ("no remote repository specified; please specify either a URL or a\n"
23912395 "remote name from which new revisions should be fetched" ));
23922396
2393- gtransport = prepare_transport (remote , 1 );
2397+ gtransport = prepare_transport (remote , 1 , filter_options );
23942398
23952399 if (prune < 0 ) {
23962400 /* no command line request */
@@ -2445,7 +2449,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
24452449 sigchain_push_common (unlock_pack_on_signal );
24462450 atexit (unlock_pack_atexit );
24472451 sigchain_push (SIGPIPE , SIG_IGN );
2448- exit_code = do_fetch (gtransport , & rs , config );
2452+ exit_code = do_fetch (gtransport , & rs , config , filter_options );
24492453 sigchain_pop (SIGPIPE );
24502454 refspec_clear (& rs );
24512455 transport_disconnect (gtransport );
@@ -2470,6 +2474,7 @@ int cmd_fetch(int argc,
24702474 const char * submodule_prefix = "" ;
24712475 const char * bundle_uri ;
24722476 struct string_list list = STRING_LIST_INIT_DUP ;
2477+ struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT ;
24732478 struct remote * remote = NULL ;
24742479 int all = -1 , multiple = 0 ;
24752480 int result = 0 ;
@@ -2735,7 +2740,7 @@ int cmd_fetch(int argc,
27352740 trace2_region_enter ("fetch" , "negotiate-only" , the_repository );
27362741 if (!remote )
27372742 die (_ ("must supply remote when using --negotiate-only" ));
2738- gtransport = prepare_transport (remote , 1 );
2743+ gtransport = prepare_transport (remote , 1 , & filter_options );
27392744 if (gtransport -> smart_options ) {
27402745 gtransport -> smart_options -> acked_commits = & acked_commits ;
27412746 } else {
@@ -2757,12 +2762,12 @@ int cmd_fetch(int argc,
27572762 } else if (remote ) {
27582763 if (filter_options .choice || repo_has_promisor_remote (the_repository )) {
27592764 trace2_region_enter ("fetch" , "setup-partial" , the_repository );
2760- fetch_one_setup_partial (remote );
2765+ fetch_one_setup_partial (remote , & filter_options );
27612766 trace2_region_leave ("fetch" , "setup-partial" , the_repository );
27622767 }
27632768 trace2_region_enter ("fetch" , "fetch-one" , the_repository );
27642769 result = fetch_one (remote , argc , argv , prune_tags_ok , stdin_refspecs ,
2765- & config );
2770+ & config , & filter_options );
27662771 trace2_region_leave ("fetch" , "fetch-one" , the_repository );
27672772 } else {
27682773 int max_children = max_jobs ;
@@ -2868,5 +2873,6 @@ int cmd_fetch(int argc,
28682873
28692874 cleanup :
28702875 string_list_clear (& list , 0 );
2876+ list_objects_filter_release (& filter_options );
28712877 return result ;
28722878}
0 commit comments