Skip to content

Commit 962d179

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 2f5028c + 1db44fa commit 962d179

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12231223
}
12241224

12251225
if (!is_local && !complete_refs_before_fetch)
1226-
transport_fetch_refs(transport, mapped_refs);
1226+
if (transport_fetch_refs(transport, mapped_refs))
1227+
die(_("could not fetch refs from %s"),
1228+
transport->url);
12271229

12281230
remote_head = find_ref_by_name(refs, "HEAD");
12291231
remote_head_points_at =

t/t5801-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ test_expect_success 'push update refs failure' '
230230
echo "update fail" >>file &&
231231
git commit -a -m "update fail" &&
232232
git rev-parse --verify testgit/origin/heads/update >expect &&
233-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
233+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
234234
git push origin update &&
235235
git rev-parse --verify testgit/origin/heads/update >actual &&
236236
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;
@@ -473,10 +475,25 @@ static int get_exporter(struct transport *transport,
473475
for (i = 0; i < revlist_args->nr; i++)
474476
argv_array_push(&fastexport->args, revlist_args->items[i].string);
475477

478+
argv_array_push(&fastexport->args, "--");
479+
476480
fastexport->git_cmd = 1;
477481
return start_command(fastexport);
478482
}
479483

484+
static void check_helper_status(struct helper_data *data)
485+
{
486+
int pid, status;
487+
488+
pid = waitpid(data->helper->pid, &status, WNOHANG);
489+
if (pid < 0)
490+
die("Could not retrieve status of remote helper '%s'",
491+
data->name);
492+
if (pid > 0 && WIFEXITED(status))
493+
die("Remote helper '%s' died with %d",
494+
data->name, WEXITSTATUS(status));
495+
}
496+
480497
static int fetch_with_import(struct transport *transport,
481498
int nr_heads, struct ref **to_fetch)
482499
{
@@ -513,6 +530,7 @@ static int fetch_with_import(struct transport *transport,
513530

514531
if (finish_command(&fastimport))
515532
die(_("error while running fast-import"));
533+
check_helper_status(data);
516534

517535
/*
518536
* The fast-import stream of a remote helper that advertises
@@ -546,6 +564,12 @@ static int fetch_with_import(struct transport *transport,
546564
}
547565
}
548566
strbuf_release(&buf);
567+
if (auto_gc) {
568+
const char *argv_gc_auto[] = {
569+
"gc", "--auto", "--quiet", NULL,
570+
};
571+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
572+
}
549573
return 0;
550574
}
551575

@@ -1019,6 +1043,7 @@ static int push_refs_with_export(struct transport *transport,
10191043

10201044
if (finish_command(&exporter))
10211045
die(_("error while running fast-export"));
1046+
check_helper_status(data);
10221047
if (push_update_refs_status(data, remote_refs, flags))
10231048
return 1;
10241049

0 commit comments

Comments
 (0)