Skip to content

Commit 2432163

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 768c438 + 6126568 commit 2432163

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
@@ -1194,7 +1194,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11941194
}
11951195

11961196
if (!is_local && !complete_refs_before_fetch)
1197-
transport_fetch_refs(transport, mapped_refs);
1197+
if (transport_fetch_refs(transport, mapped_refs))
1198+
die(_("could not fetch refs from %s"),
1199+
transport->url);
11981200

11991201
remote_head = find_ref_by_name(refs, "HEAD");
12001202
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
@@ -690,4 +690,15 @@ test_expect_success 'merge commit gets exported with --import-marks' '
690690
)
691691
'
692692

693+
cat > expected << EOF
694+
reset refs/heads/master
695+
from $(git rev-parse master)
696+
697+
EOF
698+
699+
test_expect_failure 'refs are updated even if no commits need to be exported' '
700+
git fast-export master..master > actual &&
701+
test_cmp expected actual
702+
'
703+
693704
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;
@@ -469,10 +471,25 @@ static int get_exporter(struct transport *transport,
469471
for (i = 0; i < revlist_args->nr; i++)
470472
argv_array_push(&fastexport->args, revlist_args->items[i].string);
471473

474+
argv_array_push(&fastexport->args, "--");
475+
472476
fastexport->git_cmd = 1;
473477
return start_command(fastexport);
474478
}
475479

480+
static void check_helper_status(struct helper_data *data)
481+
{
482+
int pid, status;
483+
484+
pid = waitpid(data->helper->pid, &status, WNOHANG);
485+
if (pid < 0)
486+
die("Could not retrieve status of remote helper '%s'",
487+
data->name);
488+
if (pid > 0 && WIFEXITED(status))
489+
die("Remote helper '%s' died with %d",
490+
data->name, WEXITSTATUS(status));
491+
}
492+
476493
static int fetch_with_import(struct transport *transport,
477494
int nr_heads, struct ref **to_fetch)
478495
{
@@ -509,6 +526,7 @@ static int fetch_with_import(struct transport *transport,
509526

510527
if (finish_command(&fastimport))
511528
die(_("error while running fast-import"));
529+
check_helper_status(data);
512530

513531
/*
514532
* The fast-import stream of a remote helper that advertises
@@ -542,6 +560,12 @@ static int fetch_with_import(struct transport *transport,
542560
}
543561
}
544562
strbuf_release(&buf);
563+
if (auto_gc) {
564+
const char *argv_gc_auto[] = {
565+
"gc", "--auto", "--quiet", NULL,
566+
};
567+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
568+
}
545569
return 0;
546570
}
547571

@@ -1001,6 +1025,7 @@ static int push_refs_with_export(struct transport *transport,
10011025

10021026
if (finish_command(&exporter))
10031027
die(_("error while running fast-export"));
1028+
check_helper_status(data);
10041029
if (push_update_refs_status(data, remote_refs, flags))
10051030
return 1;
10061031

0 commit comments

Comments
 (0)