14
14
#include "refs.h"
15
15
16
16
static int debug ;
17
+ /* TODO: put somewhere sensible, e.g. git_transport_options? */
18
+ static int auto_gc = 1 ;
17
19
18
20
struct helper_data {
19
21
const char * name ;
@@ -435,7 +437,7 @@ static int get_exporter(struct transport *transport,
435
437
/* we need to duplicate helper->in because we want to use it after
436
438
* fastexport is done with it. */
437
439
fastexport -> out = dup (helper -> in );
438
- fastexport -> argv = xcalloc (6 + revlist_args -> nr , sizeof (* fastexport -> argv ));
440
+ fastexport -> argv = xcalloc (7 + revlist_args -> nr , sizeof (* fastexport -> argv ));
439
441
fastexport -> argv [argc ++ ] = "fast-export" ;
440
442
fastexport -> argv [argc ++ ] = "--use-done-feature" ;
441
443
fastexport -> argv [argc ++ ] = data -> signed_tags ?
@@ -448,10 +450,25 @@ static int get_exporter(struct transport *transport,
448
450
for (i = 0 ; i < revlist_args -> nr ; i ++ )
449
451
fastexport -> argv [argc ++ ] = revlist_args -> items [i ].string ;
450
452
453
+ fastexport -> argv [argc ++ ] = "--" ;
454
+
451
455
fastexport -> git_cmd = 1 ;
452
456
return start_command (fastexport );
453
457
}
454
458
459
+ static void check_helper_status (struct helper_data * data )
460
+ {
461
+ int pid , status ;
462
+
463
+ pid = waitpid (data -> helper -> pid , & status , WNOHANG );
464
+ if (pid < 0 )
465
+ die ("Could not retrieve status of remote helper '%s'" ,
466
+ data -> name );
467
+ if (pid > 0 && WIFEXITED (status ))
468
+ die ("Remote helper '%s' died with %d" ,
469
+ data -> name , WEXITSTATUS (status ));
470
+ }
471
+
455
472
static int fetch_with_import (struct transport * transport ,
456
473
int nr_heads , struct ref * * to_fetch )
457
474
{
@@ -488,6 +505,7 @@ static int fetch_with_import(struct transport *transport,
488
505
if (finish_command (& fastimport ))
489
506
die ("Error while running fast-import" );
490
507
argv_array_free_detached (fastimport .argv );
508
+ check_helper_status (data );
491
509
492
510
/*
493
511
* The fast-import stream of a remote helper that advertises
@@ -519,6 +537,12 @@ static int fetch_with_import(struct transport *transport,
519
537
}
520
538
}
521
539
strbuf_release (& buf );
540
+ if (auto_gc ) {
541
+ const char * argv_gc_auto [] = {
542
+ "gc" , "--auto" , "--quiet" , NULL ,
543
+ };
544
+ run_command_v_opt (argv_gc_auto , RUN_GIT_CMD );
545
+ }
522
546
return 0 ;
523
547
}
524
548
@@ -896,6 +920,7 @@ static int push_refs_with_export(struct transport *transport,
896
920
897
921
if (finish_command (& exporter ))
898
922
die ("Error while running fast-export" );
923
+ check_helper_status (data );
899
924
push_update_refs_status (data , remote_refs );
900
925
return 0 ;
901
926
}
0 commit comments