@@ -499,17 +499,42 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
499
499
& "clone" ,
500
500
& "https://github.com/rust-lang/rust.git" ,
501
501
& rust_dir_path,
502
+ & "--depth" ,
503
+ & "1" ,
502
504
] ,
503
505
None ,
504
506
Some ( env) ,
505
507
) ;
506
508
let rust_dir: Option < & Path > = Some ( & rust_dir_path) ;
507
509
run_command ( & [ & "git" , & "checkout" , & "--" , & "tests/" ] , rust_dir) ?;
508
- run_command_with_output_and_env ( & [ & "git" , & "fetch" ] , rust_dir, Some ( env) ) ?;
509
510
let rustc_commit = match rustc_version_info ( env. get ( "RUSTC" ) . map ( |s| s. as_str ( ) ) ) ?. commit_hash {
510
511
Some ( commit_hash) => commit_hash,
511
512
None => return Err ( "Couldn't retrieve rustc commit hash" . to_string ( ) ) ,
512
513
} ;
514
+ let has_commit = {
515
+ if let Ok ( ty) = run_command_with_env (
516
+ & [ & "git" , & "cat-file" , & "-t" , & rustc_commit. as_str ( ) ] ,
517
+ rust_dir,
518
+ Some ( env) ,
519
+ ) {
520
+ String :: from_utf8_lossy ( & ty. stdout ) . to_string ( ) == "commit"
521
+ } else {
522
+ false
523
+ }
524
+ } ;
525
+ if !has_commit {
526
+ run_command_with_output_and_env (
527
+ & [
528
+ & "git" ,
529
+ & "fetch" ,
530
+ & "https://github.com/rust-lang/rust.git" ,
531
+ & rustc_commit. as_str ( ) ,
532
+ & "--depth=1" ,
533
+ ] ,
534
+ rust_dir,
535
+ Some ( env) ,
536
+ ) ?
537
+ } ;
513
538
if rustc_commit != "unknown" {
514
539
run_command_with_output_and_env (
515
540
& [ & "git" , & "checkout" , & rustc_commit] ,
0 commit comments