@@ -335,38 +335,68 @@ mod blocking_and_async_io {
335
335
async ( feature = "async-network-client-async-std" , async_std:: test)
336
336
) ]
337
337
async fn fetch_empty_pack ( ) -> crate :: Result {
338
- let daemon = spawn_git_daemon_if_async ( repo_path ( "base" ) ) ?;
339
- for ( fetch_tags, expected_ref_count) in [
340
- ( fetch:: Tags :: None , 1 ) ,
341
- ( fetch:: Tags :: Included , 7 ) ,
342
- ( fetch:: Tags :: All , 7 ) ,
338
+ for version in [
339
+ gix:: protocol:: transport:: Protocol :: V1 ,
340
+ gix:: protocol:: transport:: Protocol :: V2 ,
343
341
] {
344
- let ( repo, _tmp) = repo_rw ( "two-origins" ) ; // TODO: also try shallow clones
345
- let mut remote = into_daemon_remote_if_async (
346
- repo. head ( ) ?
347
- . into_remote ( Fetch )
348
- . expect ( "present" ) ?
349
- . with_fetch_tags ( fetch_tags) ,
350
- daemon. as_ref ( ) ,
351
- None ,
352
- ) ;
353
- remote. replace_refspecs ( Some ( "HEAD:refs/remotes/origin/does-not-yet-exist" ) , Fetch ) ?;
354
-
355
- let res = remote
356
- . connect ( Fetch )
357
- . await ?
358
- . prepare_fetch ( gix:: progress:: Discard , Default :: default ( ) )
359
- . await ?
360
- . receive ( gix:: progress:: Discard , & AtomicBool :: default ( ) )
361
- . await ?;
342
+ for ( shallow_args, expected) in [ ( None , [ 1 , 7 , 7 ] ) , ( Some ( "--depth=2" ) , [ 1 , 2 , 2 ] ) ] {
343
+ if version == gix:: protocol:: transport:: Protocol :: V1 && shallow_args. is_some ( ) {
344
+ // TODO: We cannot yet handle shallow mode for V1 as it will send shallow-info as part of the handshake :/.
345
+ // It's probaby not the most important thing to be able to clone from a shallow remote anyway.
346
+ continue ;
347
+ }
348
+ for ( fetch_tags, expected_ref_count) in [ fetch:: Tags :: None , fetch:: Tags :: Included , fetch:: Tags :: All ]
349
+ . into_iter ( )
350
+ . zip ( expected)
351
+ {
352
+ let ( mut repo, _tmp) = try_repo_rw_args (
353
+ "two-origins" ,
354
+ shallow_args,
355
+ if shallow_args. is_some ( ) {
356
+ Mode :: CloneWithShallowSupport
357
+ } else {
358
+ Mode :: FastClone
359
+ } ,
360
+ ) ?;
361
+ let daemon = spawn_git_daemon_if_async (
362
+ repo. work_dir ( )
363
+ . expect ( "non-bare" )
364
+ . ancestors ( )
365
+ . nth ( 1 )
366
+ . expect ( "parent" )
367
+ . join ( "base" ) ,
368
+ ) ?;
369
+ repo. config_snapshot_mut ( ) . set_value (
370
+ & gix:: config:: tree:: Protocol :: VERSION ,
371
+ ( version as u8 ) . to_string ( ) . as_str ( ) ,
372
+ ) ?;
373
+ let mut remote = into_daemon_remote_if_async (
374
+ repo. head ( ) ?
375
+ . into_remote ( Fetch )
376
+ . expect ( "present" ) ?
377
+ . with_fetch_tags ( fetch_tags) ,
378
+ daemon. as_ref ( ) ,
379
+ None ,
380
+ ) ;
381
+ remote. replace_refspecs ( Some ( "HEAD:refs/remotes/origin/does-not-yet-exist" ) , Fetch ) ?;
382
+
383
+ let res = remote
384
+ . connect ( Fetch )
385
+ . await ?
386
+ . prepare_fetch ( gix:: progress:: Discard , Default :: default ( ) )
387
+ . await ?
388
+ . receive ( gix:: progress:: Discard , & AtomicBool :: default ( ) )
389
+ . await ?;
362
390
363
- match res. status {
364
- fetch:: Status :: NoPackReceived { update_refs } => {
365
- assert_eq ! ( update_refs. edits. len( ) , expected_ref_count) ;
391
+ match res. status {
392
+ fetch:: Status :: NoPackReceived { update_refs } => {
393
+ assert_eq ! ( update_refs. edits. len( ) , expected_ref_count, "{shallow_args:?}|{fetch_tags:?}" ) ;
394
+ } ,
395
+ _ => unreachable ! (
396
+ "{shallow_args:?}|{fetch_tags:?}: default negotiation is able to realize nothing is required and doesn't get to receiving a pack"
397
+ ) ,
398
+ }
366
399
}
367
- _ => unreachable ! (
368
- "default negotiation is able to realize nothing is required and doesn't get to receiving a pack"
369
- ) ,
370
400
}
371
401
}
372
402
Ok ( ( ) )
0 commit comments