Skip to content

Commit 05ccd0a

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 86c65b5 + 773fbcf commit 05ccd0a

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;
@@ -500,10 +502,25 @@ static int get_exporter(struct transport *transport,
500502
for (i = 0; i < revlist_args->nr; i++)
501503
strvec_push(&fastexport->args, revlist_args->items[i].string);
502504

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

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

541558
if (finish_command(&fastimport))
542559
die(_("error while running fast-import"));
560+
check_helper_status(data);
543561

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

@@ -1159,6 +1184,7 @@ static int push_refs_with_export(struct transport *transport,
11591184

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

0 commit comments

Comments
 (0)