Skip to content

Commit 753e092

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 cb426a0 + fe89d82 commit 753e092

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
@@ -1178,7 +1178,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11781178
}
11791179

11801180
if (!is_local && !complete_refs_before_fetch)
1181-
transport_fetch_refs(transport, mapped_refs);
1181+
if (transport_fetch_refs(transport, mapped_refs))
1182+
die(_("could not fetch refs from %s"),
1183+
transport->url);
11821184

11831185
remote_head = find_ref_by_name(refs, "HEAD");
11841186
remote_head_points_at =

t/t5801-remote-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ test_expect_success 'push update refs failure' '
228228
echo "update fail" >>file &&
229229
git commit -a -m "update fail" &&
230230
git rev-parse --verify testgit/origin/heads/update >expect &&
231-
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
231+
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
232232
git push origin update &&
233233
git rev-parse --verify testgit/origin/heads/update >actual &&
234234
test_cmp expect actual

t/t9350-fast-export.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,15 @@ test_expect_success 'merge commit gets exported with --import-marks' '
630630
)
631631
'
632632

633+
cat > expected << EOF
634+
reset refs/heads/master
635+
from $(git rev-parse master)
636+
637+
EOF
638+
639+
test_expect_failure 'refs are updated even if no commits need to be exported' '
640+
git fast-export master..master > actual &&
641+
test_cmp expected actual
642+
'
643+
633644
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;
@@ -462,10 +464,25 @@ static int get_exporter(struct transport *transport,
462464
for (i = 0; i < revlist_args->nr; i++)
463465
argv_array_push(&fastexport->args, revlist_args->items[i].string);
464466

467+
argv_array_push(&fastexport->args, "--");
468+
465469
fastexport->git_cmd = 1;
466470
return start_command(fastexport);
467471
}
468472

473+
static void check_helper_status(struct helper_data *data)
474+
{
475+
int pid, status;
476+
477+
pid = waitpid(data->helper->pid, &status, WNOHANG);
478+
if (pid < 0)
479+
die("Could not retrieve status of remote helper '%s'",
480+
data->name);
481+
if (pid > 0 && WIFEXITED(status))
482+
die("Remote helper '%s' died with %d",
483+
data->name, WEXITSTATUS(status));
484+
}
485+
469486
static int fetch_with_import(struct transport *transport,
470487
int nr_heads, struct ref **to_fetch)
471488
{
@@ -502,6 +519,7 @@ static int fetch_with_import(struct transport *transport,
502519

503520
if (finish_command(&fastimport))
504521
die(_("error while running fast-import"));
522+
check_helper_status(data);
505523

506524
/*
507525
* The fast-import stream of a remote helper that advertises
@@ -535,6 +553,12 @@ static int fetch_with_import(struct transport *transport,
535553
}
536554
}
537555
strbuf_release(&buf);
556+
if (auto_gc) {
557+
const char *argv_gc_auto[] = {
558+
"gc", "--auto", "--quiet", NULL,
559+
};
560+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
561+
}
538562
return 0;
539563
}
540564

@@ -994,6 +1018,7 @@ static int push_refs_with_export(struct transport *transport,
9941018

9951019
if (finish_command(&exporter))
9961020
die(_("error while running fast-export"));
1021+
check_helper_status(data);
9971022
if (push_update_refs_status(data, remote_refs, flags))
9981023
return 1;
9991024

0 commit comments

Comments
 (0)