Skip to content

Commit 1b335d0

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 2f71324 + c254b7e commit 1b335d0

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
@@ -791,4 +791,15 @@ test_expect_success 'fast-export --first-parent outputs all revisions output by
791791
)
792792
'
793793

794+
cat > expected << EOF
795+
reset refs/heads/master
796+
from $(git rev-parse master)
797+
798+
EOF
799+
800+
test_expect_failure 'refs are updated even if no commits need to be exported' '
801+
git fast-export master..master > actual &&
802+
test_cmp expected actual
803+
'
804+
794805
test_done

transport-helper.c

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

2323
static int debug;
24+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
25+
static int auto_gc = 1;
2426

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

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

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

524541
if (finish_command(&fastimport))
525542
die(_("error while running fast-import"));
543+
check_helper_status(data);
526544

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

@@ -1127,6 +1152,7 @@ static int push_refs_with_export(struct transport *transport,
11271152

11281153
if (finish_command(&exporter))
11291154
die(_("error while running fast-export"));
1155+
check_helper_status(data);
11301156
if (push_update_refs_status(data, remote_refs, flags))
11311157
return 1;
11321158

0 commit comments

Comments
 (0)