Skip to content

Commit 44d5d1e

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
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 2263664 + de8c531 commit 44d5d1e

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

t/t5801-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ test_expect_success 'push update refs failure' '
236236
echo "update fail" >>file &&
237237
git commit -a -m "update fail" &&
238238
git rev-parse --verify testgit/origin/heads/update >expect &&
239-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
239+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
240240
git push origin update &&
241241
git rev-parse --verify testgit/origin/heads/update >actual &&
242242
test_cmp expect actual

t/t9350-fast-export.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,4 +747,15 @@ test_expect_success 'merge commit gets exported with --import-marks' '
747747
)
748748
'
749749

750+
cat > expected << EOF
751+
reset refs/heads/master
752+
from $(git rev-parse master)
753+
754+
EOF
755+
756+
test_expect_failure 'refs are updated even if no commits need to be exported' '
757+
git fast-export master..master > actual &&
758+
test_cmp expected actual
759+
'
760+
750761
test_done

transport-helper.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "protocol.h"
1717

1818
static int debug;
19+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
20+
static int auto_gc = 1;
1921

2022
struct helper_data {
2123
const char *name;
@@ -478,10 +480,25 @@ static int get_exporter(struct transport *transport,
478480
for (i = 0; i < revlist_args->nr; i++)
479481
strvec_push(&fastexport->args, revlist_args->items[i].string);
480482

483+
strvec_push(&fastexport->args, "--");
484+
481485
fastexport->git_cmd = 1;
482486
return start_command(fastexport);
483487
}
484488

489+
static void check_helper_status(struct helper_data *data)
490+
{
491+
int pid, status;
492+
493+
pid = waitpid(data->helper->pid, &status, WNOHANG);
494+
if (pid < 0)
495+
die("Could not retrieve status of remote helper '%s'",
496+
data->name);
497+
if (pid > 0 && WIFEXITED(status))
498+
die("Remote helper '%s' died with %d",
499+
data->name, WEXITSTATUS(status));
500+
}
501+
485502
static int fetch_with_import(struct transport *transport,
486503
int nr_heads, struct ref **to_fetch)
487504
{
@@ -518,6 +535,7 @@ static int fetch_with_import(struct transport *transport,
518535

519536
if (finish_command(&fastimport))
520537
die(_("error while running fast-import"));
538+
check_helper_status(data);
521539

522540
/*
523541
* The fast-import stream of a remote helper that advertises
@@ -551,6 +569,12 @@ static int fetch_with_import(struct transport *transport,
551569
}
552570
}
553571
strbuf_release(&buf);
572+
if (auto_gc) {
573+
const char *argv_gc_auto[] = {
574+
"gc", "--auto", "--quiet", NULL,
575+
};
576+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
577+
}
554578
return 0;
555579
}
556580

@@ -1105,6 +1129,7 @@ static int push_refs_with_export(struct transport *transport,
11051129

11061130
if (finish_command(&exporter))
11071131
die(_("error while running fast-export"));
1132+
check_helper_status(data);
11081133
if (push_update_refs_status(data, remote_refs, flags))
11091134
return 1;
11101135

0 commit comments

Comments
 (0)