@@ -85,6 +85,68 @@ mod blocking_and_async_io {
8585 try_repo_rw ( name) . unwrap ( )
8686 }
8787
88+ #[ test]
89+ #[ cfg( feature = "blocking-network-client" ) ]
90+ fn fetch_more_packs_than_can_be_handled ( ) -> gix_testtools:: Result {
91+ use gix:: interrupt:: IS_INTERRUPTED ;
92+ use gix_odb:: store:: init:: Slots ;
93+ use gix_testtools:: tempfile;
94+ fn create_empty_commit ( repo : & gix:: Repository ) -> anyhow:: Result < ( ) > {
95+ let name = repo. head_name ( ) ?. expect ( "no detached head" ) ;
96+ repo. commit (
97+ name. as_bstr ( ) ,
98+ "empty" ,
99+ gix:: hash:: ObjectId :: empty_tree ( repo. object_hash ( ) ) ,
100+ repo. try_find_reference ( name. as_ref ( ) ) ?. map ( |r| r. id ( ) ) ,
101+ ) ?;
102+ Ok ( ( ) )
103+ }
104+ for max_packs in 1 ..=3 {
105+ let remote_dir = tempfile:: tempdir ( ) ?;
106+ let remote_repo = gix:: init_bare ( remote_dir. path ( ) ) ?;
107+ create_empty_commit ( & remote_repo) ?;
108+
109+ let local_dir = tempfile:: tempdir ( ) ?;
110+ let ( local_repo, _) = gix:: clone:: PrepareFetch :: new (
111+ remote_repo. path ( ) ,
112+ local_dir. path ( ) ,
113+ gix:: create:: Kind :: Bare ,
114+ Default :: default ( ) ,
115+ gix:: open:: Options :: isolated ( ) . object_store_slots ( Slots :: Given ( max_packs) ) ,
116+ ) ?
117+ . fetch_only ( gix:: progress:: Discard , & IS_INTERRUPTED ) ?;
118+
119+ let remote = local_repo
120+ . branch_remote (
121+ local_repo. head_ref ( ) ?. expect ( "branch available" ) . name ( ) . shorten ( ) ,
122+ Fetch ,
123+ )
124+ . expect ( "remote is configured after clone" ) ?;
125+ for _round_to_create_pack in 1 ..12 {
126+ create_empty_commit ( & remote_repo) ?;
127+ match remote
128+ . connect ( Fetch ) ?
129+ . prepare_fetch ( gix:: progress:: Discard , Default :: default ( ) ) ?
130+ . receive ( gix:: progress:: Discard , & IS_INTERRUPTED )
131+ {
132+ Ok ( out) => {
133+ for local_tracking_branch_name in out. ref_map . mappings . into_iter ( ) . filter_map ( |m| m. local ) {
134+ let r = local_repo. find_reference ( & local_tracking_branch_name) ?;
135+ r. id ( )
136+ . object ( )
137+ . expect ( "object should be present after fetching, triggering pack refreshes works" ) ;
138+ local_repo. head_ref ( ) ?. unwrap ( ) . set_target_id ( r. id ( ) , "post fetch" ) ?;
139+ }
140+ }
141+ Err ( err) => assert ! ( err
142+ . to_string( )
143+ . starts_with( "The slotmap turned out to be too small with " ) ) ,
144+ }
145+ }
146+ }
147+ Ok ( ( ) )
148+ }
149+
88150 #[ test]
89151 #[ cfg( feature = "blocking-network-client" ) ]
90152 #[ allow( clippy:: result_large_err) ]
0 commit comments