зеркало из https://github.com/microsoft/git.git
transport-helper: refactor process_connect_service
A future patch will need to take advantage of the logic which runs and processes the response of the connect command on a remote helper so factor out this logic from 'process_connect_service()' and place it into a helper function 'run_connect()'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
b1c2edfc18
Коммит
176e85c1b4
|
@ -545,14 +545,13 @@ static int fetch_with_import(struct transport *transport,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int process_connect_service(struct transport *transport,
|
||||
const char *name, const char *exec)
|
||||
static int run_connect(struct transport *transport, struct strbuf *cmdbuf)
|
||||
{
|
||||
struct helper_data *data = transport->data;
|
||||
struct strbuf cmdbuf = STRBUF_INIT;
|
||||
struct child_process *helper;
|
||||
int r, duped, ret = 0;
|
||||
int ret = 0;
|
||||
int duped;
|
||||
FILE *input;
|
||||
struct child_process *helper;
|
||||
|
||||
helper = get_helper(transport);
|
||||
|
||||
|
@ -568,44 +567,54 @@ static int process_connect_service(struct transport *transport,
|
|||
input = xfdopen(duped, "r");
|
||||
setvbuf(input, NULL, _IONBF, 0);
|
||||
|
||||
sendline(data, cmdbuf);
|
||||
if (recvline_fh(input, cmdbuf))
|
||||
exit(128);
|
||||
|
||||
if (!strcmp(cmdbuf->buf, "")) {
|
||||
data->no_disconnect_req = 1;
|
||||
if (debug)
|
||||
fprintf(stderr, "Debug: Smart transport connection "
|
||||
"ready.\n");
|
||||
ret = 1;
|
||||
} else if (!strcmp(cmdbuf->buf, "fallback")) {
|
||||
if (debug)
|
||||
fprintf(stderr, "Debug: Falling back to dumb "
|
||||
"transport.\n");
|
||||
} else {
|
||||
die("Unknown response to connect: %s",
|
||||
cmdbuf->buf);
|
||||
}
|
||||
|
||||
fclose(input);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int process_connect_service(struct transport *transport,
|
||||
const char *name, const char *exec)
|
||||
{
|
||||
struct helper_data *data = transport->data;
|
||||
struct strbuf cmdbuf = STRBUF_INIT;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Handle --upload-pack and friends. This is fire and forget...
|
||||
* just warn if it fails.
|
||||
*/
|
||||
if (strcmp(name, exec)) {
|
||||
r = set_helper_option(transport, "servpath", exec);
|
||||
int r = set_helper_option(transport, "servpath", exec);
|
||||
if (r > 0)
|
||||
warning("Setting remote service path not supported by protocol.");
|
||||
else if (r < 0)
|
||||
warning("Invalid remote service path.");
|
||||
}
|
||||
|
||||
if (data->connect)
|
||||
if (data->connect) {
|
||||
strbuf_addf(&cmdbuf, "connect %s\n", name);
|
||||
else
|
||||
goto exit;
|
||||
ret = run_connect(transport, &cmdbuf);
|
||||
}
|
||||
|
||||
sendline(data, &cmdbuf);
|
||||
if (recvline_fh(input, &cmdbuf))
|
||||
exit(128);
|
||||
|
||||
if (!strcmp(cmdbuf.buf, "")) {
|
||||
data->no_disconnect_req = 1;
|
||||
if (debug)
|
||||
fprintf(stderr, "Debug: Smart transport connection "
|
||||
"ready.\n");
|
||||
ret = 1;
|
||||
} else if (!strcmp(cmdbuf.buf, "fallback")) {
|
||||
if (debug)
|
||||
fprintf(stderr, "Debug: Falling back to dumb "
|
||||
"transport.\n");
|
||||
} else
|
||||
die("Unknown response to connect: %s",
|
||||
cmdbuf.buf);
|
||||
|
||||
exit:
|
||||
strbuf_release(&cmdbuf);
|
||||
fclose(input);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче