Skip to content

Commit 68c2a23

Browse files
author
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 874f9cf + b065a31 commit 68c2a23

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

builtin/clone.c

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

10751075
if (!is_local && !complete_refs_before_fetch)
1076-
transport_fetch_refs(transport, mapped_refs);
1076+
if (transport_fetch_refs(transport, mapped_refs))
1077+
die(_("could not fetch refs from %s"),
1078+
transport->url);
10771079

10781080
remote_head = find_ref_by_name(refs, "HEAD");
10791081
remote_head_points_at =

builtin/fast-export.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
847847
}
848848
}
849849

850+
static void handle_reset(const char *name, struct object *object)
851+
{
852+
int mark = get_object_mark(object);
853+
854+
if (mark)
855+
printf("reset %s\nfrom :%d\n\n", name,
856+
get_object_mark(object));
857+
else
858+
printf("reset %s\nfrom %s\n\n", name,
859+
oid_to_hex(&object->oid));
860+
}
861+
850862
static void handle_tags_and_duplicates(void)
851863
{
852-
struct commit *commit;
853864
int i;
854865

855866
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -863,9 +874,7 @@ static void handle_tags_and_duplicates(void)
863874
if (anonymize)
864875
name = anonymize_refname(name);
865876
/* create refs pointing to already seen commits */
866-
commit = (struct commit *)object;
867-
printf("reset %s\nfrom :%d\n\n", name,
868-
get_object_mark(&commit->object));
877+
handle_reset(name, object);
869878
show_progress();
870879
break;
871880
}

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

transport-helper.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "refs.h"
1414

1515
static int debug;
16+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
17+
static int auto_gc = 1;
1618

1719
struct helper_data {
1820
const char *name;
@@ -472,10 +474,25 @@ static int get_exporter(struct transport *transport,
472474
for (i = 0; i < revlist_args->nr; i++)
473475
argv_array_push(&fastexport->args, revlist_args->items[i].string);
474476

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

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

513530
if (finish_command(&fastimport))
514531
die("Error while running fast-import");
532+
check_helper_status(data);
515533

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

@@ -972,6 +996,7 @@ static int push_refs_with_export(struct transport *transport,
972996

973997
if (finish_command(&exporter))
974998
die("Error while running fast-export");
999+
check_helper_status(data);
9751000
if (push_update_refs_status(data, remote_refs, flags))
9761001
return 1;
9771002

0 commit comments

Comments
 (0)