Skip to content

Commit d2fdfb4

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 bddad1a + c91d47a commit d2fdfb4

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

builtin/clone.c

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

949949
if (!is_local && !complete_refs_before_fetch)
950-
transport_fetch_refs(transport, mapped_refs);
950+
if (transport_fetch_refs(transport, mapped_refs))
951+
die(_("could not fetch refs from %s"),
952+
transport->url);
951953

952954
remote_head = find_ref_by_name(refs, "HEAD");
953955
remote_head_points_at =

builtin/fast-export.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
571571
}
572572
}
573573

574+
static void handle_reset(const char *name, struct object *object)
575+
{
576+
int mark = get_object_mark(object);
577+
578+
if (mark)
579+
printf("reset %s\nfrom :%d\n\n", name,
580+
get_object_mark(object));
581+
else
582+
printf("reset %s\nfrom %s\n\n", name,
583+
sha1_to_hex(object->sha1));
584+
}
585+
574586
static void handle_tags_and_duplicates(void)
575587
{
576-
struct commit *commit;
577588
int i;
578589

579590
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -585,9 +596,7 @@ static void handle_tags_and_duplicates(void)
585596
break;
586597
case OBJ_COMMIT:
587598
/* create refs pointing to already seen commits */
588-
commit = (struct commit *)object;
589-
printf("reset %s\nfrom :%d\n\n", name,
590-
get_object_mark(&commit->object));
599+
handle_reset(name, object);
591600
show_progress();
592601
break;
593602
}

transport-helper.c

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

1616
static int debug;
17+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
18+
static int auto_gc = 1;
1719

1820
struct helper_data {
1921
const char *name;
@@ -435,10 +437,25 @@ static int get_exporter(struct transport *transport,
435437
for (i = 0; i < revlist_args->nr; i++)
436438
argv_array_push(&fastexport->args, revlist_args->items[i].string);
437439

440+
argv_array_push(&fastexport->args, "--");
441+
438442
fastexport->git_cmd = 1;
439443
return start_command(fastexport);
440444
}
441445

446+
static void check_helper_status(struct helper_data *data)
447+
{
448+
int pid, status;
449+
450+
pid = waitpid(data->helper->pid, &status, WNOHANG);
451+
if (pid < 0)
452+
die("Could not retrieve status of remote helper '%s'",
453+
data->name);
454+
if (pid > 0 && WIFEXITED(status))
455+
die("Remote helper '%s' died with %d",
456+
data->name, WEXITSTATUS(status));
457+
}
458+
442459
static int fetch_with_import(struct transport *transport,
443460
int nr_heads, struct ref **to_fetch)
444461
{
@@ -474,6 +491,7 @@ static int fetch_with_import(struct transport *transport,
474491

475492
if (finish_command(&fastimport))
476493
die("Error while running fast-import");
494+
check_helper_status(data);
477495

478496
/*
479497
* The fast-import stream of a remote helper that advertises
@@ -505,6 +523,12 @@ static int fetch_with_import(struct transport *transport,
505523
}
506524
}
507525
strbuf_release(&buf);
526+
if (auto_gc) {
527+
const char *argv_gc_auto[] = {
528+
"gc", "--auto", "--quiet", NULL,
529+
};
530+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
531+
}
508532
return 0;
509533
}
510534

@@ -913,6 +937,7 @@ static int push_refs_with_export(struct transport *transport,
913937

914938
if (finish_command(&exporter))
915939
die("Error while running fast-export");
940+
check_helper_status(data);
916941
if (push_update_refs_status(data, remote_refs, flags))
917942
return 1;
918943

0 commit comments

Comments
 (0)