Skip to content

Commit 54a7a8d

Browse files
author
nalla
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 cd7055b + c04176d commit 54a7a8d

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
@@ -962,7 +962,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
962962
}
963963

964964
if (!is_local && !complete_refs_before_fetch)
965-
transport_fetch_refs(transport, mapped_refs);
965+
if (transport_fetch_refs(transport, mapped_refs))
966+
die(_("could not fetch refs from %s"),
967+
transport->url);
966968

967969
remote_head = find_ref_by_name(refs, "HEAD");
968970
remote_head_points_at =

builtin/fast-export.c

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

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

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

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;
@@ -423,10 +425,25 @@ static int get_exporter(struct transport *transport,
423425
for (i = 0; i < revlist_args->nr; i++)
424426
argv_array_push(&fastexport->args, revlist_args->items[i].string);
425427

428+
argv_array_push(&fastexport->args, "--");
429+
426430
fastexport->git_cmd = 1;
427431
return start_command(fastexport);
428432
}
429433

434+
static void check_helper_status(struct helper_data *data)
435+
{
436+
int pid, status;
437+
438+
pid = waitpid(data->helper->pid, &status, WNOHANG);
439+
if (pid < 0)
440+
die("Could not retrieve status of remote helper '%s'",
441+
data->name);
442+
if (pid > 0 && WIFEXITED(status))
443+
die("Remote helper '%s' died with %d",
444+
data->name, WEXITSTATUS(status));
445+
}
446+
430447
static int fetch_with_import(struct transport *transport,
431448
int nr_heads, struct ref **to_fetch)
432449
{
@@ -463,6 +480,7 @@ static int fetch_with_import(struct transport *transport,
463480

464481
if (finish_command(&fastimport))
465482
die("Error while running fast-import");
483+
check_helper_status(data);
466484

467485
/*
468486
* The fast-import stream of a remote helper that advertises
@@ -495,6 +513,12 @@ static int fetch_with_import(struct transport *transport,
495513
}
496514
}
497515
strbuf_release(&buf);
516+
if (auto_gc) {
517+
const char *argv_gc_auto[] = {
518+
"gc", "--auto", "--quiet", NULL,
519+
};
520+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
521+
}
498522
return 0;
499523
}
500524

@@ -921,6 +945,7 @@ static int push_refs_with_export(struct transport *transport,
921945

922946
if (finish_command(&exporter))
923947
die("Error while running fast-export");
948+
check_helper_status(data);
924949
if (push_update_refs_status(data, remote_refs, flags))
925950
return 1;
926951

0 commit comments

Comments
 (0)