Skip to content

Commit

Permalink
Merge 'remote-hg-prerequisites' into HEAD
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed May 13, 2019
2 parents bdbb612 + c73e215 commit a0359f7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}

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

remote_head = find_ref_by_name(refs, "HEAD");
remote_head_points_at =
Expand Down
2 changes: 1 addition & 1 deletion t/t5801-remote-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ test_expect_success 'push update refs failure' '
echo "update fail" >>file &&
git commit -a -m "update fail" &&
git rev-parse --verify testgit/origin/heads/update >expect &&
test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
git push origin update &&
git rev-parse --verify testgit/origin/heads/update >actual &&
test_cmp expect actual
Expand Down
11 changes: 11 additions & 0 deletions t/t9350-fast-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,15 @@ test_expect_success 'merge commit gets exported with --import-marks' '
)
'

cat > expected << EOF
reset refs/heads/master
from $(git rev-parse master)
EOF

test_expect_failure 'refs are updated even if no commits need to be exported' '
git fast-export master..master > actual &&
test_cmp expected actual
'

test_done
25 changes: 25 additions & 0 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "protocol.h"

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

struct helper_data {
const char *name;
Expand Down Expand Up @@ -462,10 +464,25 @@ static int get_exporter(struct transport *transport,
for (i = 0; i < revlist_args->nr; i++)
argv_array_push(&fastexport->args, revlist_args->items[i].string);

argv_array_push(&fastexport->args, "--");

fastexport->git_cmd = 1;
return start_command(fastexport);
}

static void check_helper_status(struct helper_data *data)
{
int pid, status;

pid = waitpid(data->helper->pid, &status, WNOHANG);
if (pid < 0)
die("Could not retrieve status of remote helper '%s'",
data->name);
if (pid > 0 && WIFEXITED(status))
die("Remote helper '%s' died with %d",
data->name, WEXITSTATUS(status));
}

static int fetch_with_import(struct transport *transport,
int nr_heads, struct ref **to_fetch)
{
Expand Down Expand Up @@ -502,6 +519,7 @@ static int fetch_with_import(struct transport *transport,

if (finish_command(&fastimport))
die(_("error while running fast-import"));
check_helper_status(data);

/*
* The fast-import stream of a remote helper that advertises
Expand Down Expand Up @@ -535,6 +553,12 @@ static int fetch_with_import(struct transport *transport,
}
}
strbuf_release(&buf);
if (auto_gc) {
const char *argv_gc_auto[] = {
"gc", "--auto", "--quiet", NULL,
};
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
}
return 0;
}

Expand Down Expand Up @@ -994,6 +1018,7 @@ static int push_refs_with_export(struct transport *transport,

if (finish_command(&exporter))
die(_("error while running fast-export"));
check_helper_status(data);
if (push_update_refs_status(data, remote_refs, flags))
return 1;

Expand Down

0 comments on commit a0359f7

Please sign in to comment.