Skip to content

Commit 1823086

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 3088b34 + 52ee51f commit 1823086

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
@@ -239,7 +239,7 @@ test_expect_success 'push update refs failure' '
239239
echo "update fail" >>file &&
240240
git commit -a -m "update fail" &&
241241
git rev-parse --verify testgit/origin/heads/update >expect &&
242-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
242+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
243243
git push origin update &&
244244
git rev-parse --verify testgit/origin/heads/update >actual &&
245245
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
@@ -20,6 +20,8 @@
2020
#include "packfile.h"
2121

2222
static int debug;
23+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
24+
static int auto_gc = 1;
2325

2426
struct helper_data {
2527
const char *name;
@@ -484,10 +486,25 @@ static int get_exporter(struct transport *transport,
484486
for (i = 0; i < revlist_args->nr; i++)
485487
strvec_push(&fastexport->args, revlist_args->items[i].string);
486488

489+
strvec_push(&fastexport->args, "--");
490+
487491
fastexport->git_cmd = 1;
488492
return start_command(fastexport);
489493
}
490494

495+
static void check_helper_status(struct helper_data *data)
496+
{
497+
int pid, status;
498+
499+
pid = waitpid(data->helper->pid, &status, WNOHANG);
500+
if (pid < 0)
501+
die("Could not retrieve status of remote helper '%s'",
502+
data->name);
503+
if (pid > 0 && WIFEXITED(status))
504+
die("Remote helper '%s' died with %d",
505+
data->name, WEXITSTATUS(status));
506+
}
507+
491508
static int fetch_with_import(struct transport *transport,
492509
int nr_heads, struct ref **to_fetch)
493510
{
@@ -524,6 +541,7 @@ static int fetch_with_import(struct transport *transport,
524541

525542
if (finish_command(&fastimport))
526543
die(_("error while running fast-import"));
544+
check_helper_status(data);
527545

528546
/*
529547
* The fast-import stream of a remote helper that advertises
@@ -557,6 +575,13 @@ static int fetch_with_import(struct transport *transport,
557575
}
558576
}
559577
strbuf_release(&buf);
578+
if (auto_gc) {
579+
struct child_process cmd = CHILD_PROCESS_INIT;
580+
581+
cmd.git_cmd = 1;
582+
strvec_pushl(&cmd.args, "gc", "--auto", "--quiet", NULL);
583+
run_command(&cmd);
584+
}
560585
return 0;
561586
}
562587

@@ -1131,6 +1156,7 @@ static int push_refs_with_export(struct transport *transport,
11311156

11321157
if (finish_command(&exporter))
11331158
die(_("error while running fast-export"));
1159+
check_helper_status(data);
11341160
if (push_update_refs_status(data, remote_refs, flags))
11351161
return 1;
11361162

0 commit comments

Comments
 (0)