diff options
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/transport-helper.c b/transport-helper.c index 4be035e..8d284b2 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -1,10 +1,13 @@ -#include "cache.h" +#include "git-compat-util.h" #include "transport.h" #include "quote.h" #include "run-command.h" #include "commit.h" -#include "diff.h" -#include "revision.h" +#include "environment.h" +#include "gettext.h" +#include "hex.h" +#include "object-name.h" +#include "repository.h" #include "remote.h" #include "string-list.h" #include "thread-utils.h" @@ -14,6 +17,7 @@ #include "refspec.h" #include "transport-internal.h" #include "protocol.h" +#include "packfile.h" static int debug; @@ -135,7 +139,7 @@ static struct child_process *get_helper(struct transport *transport) helper->silent_exec_failure = 1; if (have_git_dir()) - strvec_pushf(&helper->env_array, "%s=%s", + strvec_pushf(&helper->env, "%s=%s", GIT_DIR_ENVIRONMENT, get_git_dir()); helper->trace2_child_class = helper->args.v[0]; /* "remote-<name>" */ @@ -429,6 +433,8 @@ static int fetch_with_fetch(struct transport *transport, warning(_("%s unexpectedly said: '%s'"), data->name, buf.buf); } strbuf_release(&buf); + + reprepare_packed_git(the_repository); return 0; } @@ -623,7 +629,8 @@ static int process_connect_service(struct transport *transport, ret = run_connect(transport, &cmdbuf); } else if (data->stateless_connect && (get_protocol_version_config() == protocol_v2) && - !strcmp("git-upload-pack", name)) { + (!strcmp("git-upload-pack", name) || + !strcmp("git-upload-archive", name))) { strbuf_addf(&cmdbuf, "stateless-connect %s\n", name); ret = run_connect(transport, &cmdbuf); if (ret) @@ -640,6 +647,7 @@ static int process_connect(struct transport *transport, struct helper_data *data = transport->data; const char *name; const char *exec; + int ret; name = for_push ? "git-receive-pack" : "git-upload-pack"; if (for_push) @@ -647,7 +655,10 @@ static int process_connect(struct transport *transport, else exec = data->transport_options.uploadpack; - return process_connect_service(transport, name, exec); + ret = process_connect_service(transport, name, exec); + if (ret) + do_take_over(transport); + return ret; } static int connect_helper(struct transport *transport, const char *name, @@ -657,32 +668,30 @@ static int connect_helper(struct transport *transport, const char *name, /* Get_helper so connect is inited. */ get_helper(transport); - if (!data->connect) - die(_("operation not supported by protocol")); if (!process_connect_service(transport, name, exec)) die(_("can't connect to subservice %s"), name); fd[0] = data->helper->out; fd[1] = data->helper->in; + + do_take_over(transport); return 0; } static struct ref *get_refs_list_using_list(struct transport *transport, int for_push); -static int fetch(struct transport *transport, - int nr_heads, struct ref **to_fetch) +static int fetch_refs(struct transport *transport, + int nr_heads, struct ref **to_fetch) { struct helper_data *data = transport->data; int i, count; get_helper(transport); - if (process_connect(transport, 0)) { - do_take_over(transport); - return transport->vtable->fetch(transport, nr_heads, to_fetch); - } + if (process_connect(transport, 0)) + return transport->vtable->fetch_refs(transport, nr_heads, to_fetch); /* * If we reach here, then the server, the client, and/or the transport @@ -715,6 +724,9 @@ static int fetch(struct transport *transport, if (data->transport_options.update_shallow) set_helper_option(transport, "update-shallow", "true"); + if (data->transport_options.refetch) + set_helper_option(transport, "refetch", "true"); + if (data->transport_options.filter_options.choice) { const char *spec = expand_list_objects_filter_spec( &data->transport_options.filter_options); @@ -845,6 +857,10 @@ static int push_update_ref_status(struct strbuf *buf, forced = 1; FREE_AND_NULL(msg); } + else if (!strcmp(msg, "expecting report")) { + status = REF_STATUS_EXPECTING_REPORT; + FREE_AND_NULL(msg); + } } if (state->hint) @@ -1062,7 +1078,7 @@ static int push_refs_with_export(struct transport *transport, set_common_push_options(transport, data->name, flags); if (flags & TRANSPORT_PUSH_FORCE) { if (set_helper_option(transport, "force", "true") != 0) - warning(_("helper %s does not support 'force'"), data->name); + warning(_("helper %s does not support '--force'"), data->name); } helper = get_helper(transport); @@ -1074,7 +1090,7 @@ static int push_refs_with_export(struct transport *transport, struct object_id oid; private = apply_refspecs(&data->rs, ref->name); - if (private && !get_oid(private, &oid)) { + if (private && !repo_get_oid(the_repository, private, &oid)) { strbuf_addf(&buf, "^%s", private); string_list_append_nodup(&revlist_args, strbuf_detach(&buf, NULL)); @@ -1132,10 +1148,8 @@ static int push_refs(struct transport *transport, { struct helper_data *data = transport->data; - if (process_connect(transport, 1)) { - do_take_over(transport); + if (process_connect(transport, 1)) return transport->vtable->push_refs(transport, remote_refs, flags); - } if (!remote_refs) { fprintf(stderr, @@ -1176,11 +1190,9 @@ static struct ref *get_refs_list(struct transport *transport, int for_push, { get_helper(transport); - if (process_connect(transport, for_push)) { - do_take_over(transport); + if (process_connect(transport, for_push)) return transport->vtable->get_refs_list(transport, for_push, transport_options); - } return get_refs_list_using_list(transport, for_push); } @@ -1198,16 +1210,13 @@ static struct ref *get_refs_list_using_list(struct transport *transport, data->get_refs_list_called = 1; helper = get_helper(transport); - if (data->object_format) { - write_str_in_full(helper->in, "option object-format\n"); - if (recvline(data, &buf) || strcmp(buf.buf, "ok")) - exit(128); - } + if (data->object_format) + set_helper_option(transport, "object-format", "true"); if (data->push && for_push) - write_str_in_full(helper->in, "list for-push\n"); + write_constant(helper->in, "list for-push\n"); else - write_str_in_full(helper->in, "list\n"); + write_constant(helper->in, "list\n"); while (1) { char *eov, *eon; @@ -1260,13 +1269,24 @@ static struct ref *get_refs_list_using_list(struct transport *transport, return ret; } +static int get_bundle_uri(struct transport *transport) +{ + get_helper(transport); + + if (process_connect(transport, 0)) + return transport->vtable->get_bundle_uri(transport); + + return -1; +} + static struct transport_vtable vtable = { - set_helper_option, - get_refs_list, - fetch, - push_refs, - connect_helper, - release_helper + .set_option = set_helper_option, + .get_refs_list = get_refs_list, + .get_bundle_uri = get_bundle_uri, + .fetch_refs = fetch_refs, + .push_refs = push_refs, + .connect = connect_helper, + .disconnect = release_helper }; int transport_helper_init(struct transport *transport, const char *name) @@ -1279,6 +1299,8 @@ int transport_helper_init(struct transport *transport, const char *name) if (getenv("GIT_TRANSPORT_HELPER_DEBUG")) debug = 1; + list_objects_filter_init(&data->transport_options.filter_options); + transport->data = data; transport->vtable = &vtable; transport->smart_options = &(data->transport_options); |