Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 96af4a2

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 1b38b9a + 68cfd0b commit 96af4a2

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

builtin/clone.c

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

945945
if (!is_local && !complete_refs_before_fetch)
946-
transport_fetch_refs(transport, mapped_refs);
946+
if (transport_fetch_refs(transport, mapped_refs))
947+
die(_("could not fetch refs from %s"),
948+
transport->url);
947949

948950
remote_head = find_ref_by_name(refs, "HEAD");
949951
remote_head_points_at =

builtin/fast-export.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
556556
}
557557
}
558558

559+
static void handle_reset(const char *name, struct object *object)
560+
{
561+
int mark = get_object_mark(object);
562+
563+
if (mark)
564+
printf("reset %s\nfrom :%d\n\n", name,
565+
get_object_mark(object));
566+
else
567+
printf("reset %s\nfrom %s\n\n", name,
568+
sha1_to_hex(object->sha1));
569+
}
570+
559571
static void handle_tags_and_duplicates(void)
560572
{
561-
struct commit *commit;
562573
int i;
563574

564575
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -570,9 +581,7 @@ static void handle_tags_and_duplicates(void)
570581
break;
571582
case OBJ_COMMIT:
572583
/* create refs pointing to already seen commits */
573-
commit = (struct commit *)object;
574-
printf("reset %s\nfrom :%d\n\n", name,
575-
get_object_mark(&commit->object));
584+
handle_reset(name, object);
576585
show_progress();
577586
break;
578587
}

transport-helper.c

Lines changed: 26 additions & 1 deletion
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,7 +437,7 @@ static int get_exporter(struct transport *transport,
435437
/* we need to duplicate helper->in because we want to use it after
436438
* fastexport is done with it. */
437439
fastexport->out = dup(helper->in);
438-
fastexport->argv = xcalloc(6 + revlist_args->nr, sizeof(*fastexport->argv));
440+
fastexport->argv = xcalloc(7 + revlist_args->nr, sizeof(*fastexport->argv));
439441
fastexport->argv[argc++] = "fast-export";
440442
fastexport->argv[argc++] = "--use-done-feature";
441443
fastexport->argv[argc++] = data->signed_tags ?
@@ -448,10 +450,25 @@ static int get_exporter(struct transport *transport,
448450
for (i = 0; i < revlist_args->nr; i++)
449451
fastexport->argv[argc++] = revlist_args->items[i].string;
450452

453+
fastexport->argv[argc++] = "--";
454+
451455
fastexport->git_cmd = 1;
452456
return start_command(fastexport);
453457
}
454458

459+
static void check_helper_status(struct helper_data *data)
460+
{
461+
int pid, status;
462+
463+
pid = waitpid(data->helper->pid, &status, WNOHANG);
464+
if (pid < 0)
465+
die("Could not retrieve status of remote helper '%s'",
466+
data->name);
467+
if (pid > 0 && WIFEXITED(status))
468+
die("Remote helper '%s' died with %d",
469+
data->name, WEXITSTATUS(status));
470+
}
471+
455472
static int fetch_with_import(struct transport *transport,
456473
int nr_heads, struct ref **to_fetch)
457474
{
@@ -488,6 +505,7 @@ static int fetch_with_import(struct transport *transport,
488505
if (finish_command(&fastimport))
489506
die("Error while running fast-import");
490507
argv_array_free_detached(fastimport.argv);
508+
check_helper_status(data);
491509

492510
/*
493511
* The fast-import stream of a remote helper that advertises
@@ -519,6 +537,12 @@ static int fetch_with_import(struct transport *transport,
519537
}
520538
}
521539
strbuf_release(&buf);
540+
if (auto_gc) {
541+
const char *argv_gc_auto[] = {
542+
"gc", "--auto", "--quiet", NULL,
543+
};
544+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
545+
}
522546
return 0;
523547
}
524548

@@ -896,6 +920,7 @@ static int push_refs_with_export(struct transport *transport,
896920

897921
if (finish_command(&exporter))
898922
die("Error while running fast-export");
923+
check_helper_status(data);
899924
push_update_refs_status(data, remote_refs);
900925
return 0;
901926
}

0 commit comments

Comments
 (0)