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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2018-06-08 13:42:16 +02:00
commit 618c1a49f1
3 changed files with 38 additions and 1 deletions

View File

@ -262,7 +262,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

View File

@ -1010,4 +1010,15 @@ test_expect_success GPG 'export and import of doubly signed commit' '
fi
'
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

View File

@ -22,6 +22,8 @@
#include "packfile.h"
static int debug;
/* TODO: put somewhere sensible, e.g. git_transport_options? */
static int auto_gc = 1;
struct helper_data {
char *name;
@ -499,10 +501,25 @@ static int get_exporter(struct transport *transport,
for (size_t i = 0; i < revlist_args->nr; i++)
strvec_push(&fastexport->args, revlist_args->items[i].string);
strvec_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)
{
@ -539,6 +556,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
@ -572,6 +590,13 @@ static int fetch_with_import(struct transport *transport,
}
}
strbuf_release(&buf);
if (auto_gc) {
struct child_process cmd = CHILD_PROCESS_INIT;
cmd.git_cmd = 1;
strvec_pushl(&cmd.args, "gc", "--auto", "--quiet", NULL);
run_command(&cmd);
}
return 0;
}
@ -1158,6 +1183,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;