|
13 | 13 | #include "refs.h"
|
14 | 14 |
|
15 | 15 | static int debug;
|
| 16 | +/* TODO: put somewhere sensible, e.g. git_transport_options? */ |
| 17 | +static int auto_gc = 1; |
16 | 18 |
|
17 | 19 | struct helper_data {
|
18 | 20 | const char *name;
|
@@ -468,10 +470,25 @@ static int get_exporter(struct transport *transport,
|
468 | 470 | for (i = 0; i < revlist_args->nr; i++)
|
469 | 471 | argv_array_push(&fastexport->args, revlist_args->items[i].string);
|
470 | 472 |
|
| 473 | + argv_array_push(&fastexport->args, "--"); |
| 474 | + |
471 | 475 | fastexport->git_cmd = 1;
|
472 | 476 | return start_command(fastexport);
|
473 | 477 | }
|
474 | 478 |
|
| 479 | +static void check_helper_status(struct helper_data *data) |
| 480 | +{ |
| 481 | + int pid, status; |
| 482 | + |
| 483 | + pid = waitpid(data->helper->pid, &status, WNOHANG); |
| 484 | + if (pid < 0) |
| 485 | + die("Could not retrieve status of remote helper '%s'", |
| 486 | + data->name); |
| 487 | + if (pid > 0 && WIFEXITED(status)) |
| 488 | + die("Remote helper '%s' died with %d", |
| 489 | + data->name, WEXITSTATUS(status)); |
| 490 | +} |
| 491 | + |
475 | 492 | static int fetch_with_import(struct transport *transport,
|
476 | 493 | int nr_heads, struct ref **to_fetch)
|
477 | 494 | {
|
@@ -508,6 +525,7 @@ static int fetch_with_import(struct transport *transport,
|
508 | 525 |
|
509 | 526 | if (finish_command(&fastimport))
|
510 | 527 | die("Error while running fast-import");
|
| 528 | + check_helper_status(data); |
511 | 529 |
|
512 | 530 | /*
|
513 | 531 | * The fast-import stream of a remote helper that advertises
|
@@ -541,6 +559,12 @@ static int fetch_with_import(struct transport *transport,
|
541 | 559 | }
|
542 | 560 | }
|
543 | 561 | strbuf_release(&buf);
|
| 562 | + if (auto_gc) { |
| 563 | + const char *argv_gc_auto[] = { |
| 564 | + "gc", "--auto", "--quiet", NULL, |
| 565 | + }; |
| 566 | + run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); |
| 567 | + } |
544 | 568 | return 0;
|
545 | 569 | }
|
546 | 570 |
|
@@ -972,6 +996,7 @@ static int push_refs_with_export(struct transport *transport,
|
972 | 996 |
|
973 | 997 | if (finish_command(&exporter))
|
974 | 998 | die("Error while running fast-export");
|
| 999 | + check_helper_status(data); |
975 | 1000 | if (push_update_refs_status(data, remote_refs, flags))
|
976 | 1001 | return 1;
|
977 | 1002 |
|
|
0 commit comments