Skip to content

Commit 90aaa6b

Browse files
committed
Merge 'remote-hg-prerequisites' into HEAD
These fixes were necessary for Sverre Rabbelier's remote-hg to work, but for some magic reason they are not necessary for the current remote-hg. Makes you wonder how that one gets away with it. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 4c45df7 + 47dc063 commit 90aaa6b

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

t/t5801-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ test_expect_success 'push update refs failure' '
262262
echo "update fail" >>file &&
263263
git commit -a -m "update fail" &&
264264
git rev-parse --verify testgit/origin/heads/update >expect &&
265-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
265+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
266266
git push origin update &&
267267
git rev-parse --verify testgit/origin/heads/update >actual &&
268268
test_cmp expect actual

t/t9350-fast-export.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,4 +801,15 @@ test_expect_success 'fast-export handles --end-of-options' '
801801
test_cmp expect actual
802802
'
803803

804+
cat > expected << EOF
805+
reset refs/heads/master
806+
from $(git rev-parse master)
807+
808+
EOF
809+
810+
test_expect_failure 'refs are updated even if no commits need to be exported' '
811+
git fast-export master..master > actual &&
812+
test_cmp expected actual
813+
'
814+
804815
test_done

transport-helper.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "packfile.h"
2323

2424
static int debug;
25+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
26+
static int auto_gc = 1;
2527

2628
struct helper_data {
2729
char *name;
@@ -499,10 +501,25 @@ static int get_exporter(struct transport *transport,
499501
for (size_t i = 0; i < revlist_args->nr; i++)
500502
strvec_push(&fastexport->args, revlist_args->items[i].string);
501503

504+
strvec_push(&fastexport->args, "--");
505+
502506
fastexport->git_cmd = 1;
503507
return start_command(fastexport);
504508
}
505509

510+
static void check_helper_status(struct helper_data *data)
511+
{
512+
int pid, status;
513+
514+
pid = waitpid(data->helper->pid, &status, WNOHANG);
515+
if (pid < 0)
516+
die("Could not retrieve status of remote helper '%s'",
517+
data->name);
518+
if (pid > 0 && WIFEXITED(status))
519+
die("Remote helper '%s' died with %d",
520+
data->name, WEXITSTATUS(status));
521+
}
522+
506523
static int fetch_with_import(struct transport *transport,
507524
int nr_heads, struct ref **to_fetch)
508525
{
@@ -539,6 +556,7 @@ static int fetch_with_import(struct transport *transport,
539556

540557
if (finish_command(&fastimport))
541558
die(_("error while running fast-import"));
559+
check_helper_status(data);
542560

543561
/*
544562
* The fast-import stream of a remote helper that advertises
@@ -572,6 +590,13 @@ static int fetch_with_import(struct transport *transport,
572590
}
573591
}
574592
strbuf_release(&buf);
593+
if (auto_gc) {
594+
struct child_process cmd = CHILD_PROCESS_INIT;
595+
596+
cmd.git_cmd = 1;
597+
strvec_pushl(&cmd.args, "gc", "--auto", "--quiet", NULL);
598+
run_command(&cmd);
599+
}
575600
return 0;
576601
}
577602

@@ -1158,6 +1183,7 @@ static int push_refs_with_export(struct transport *transport,
11581183

11591184
if (finish_command(&exporter))
11601185
die(_("error while running fast-export"));
1186+
check_helper_status(data);
11611187
if (push_update_refs_status(data, remote_refs, flags))
11621188
return 1;
11631189

0 commit comments

Comments
 (0)