summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/connect.c b/connect.c
index 10fad43e98..34cac24d54 100644
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
@@ -23,6 +22,7 @@
#include "protocol.h"
#include "alias.h"
#include "bundle-uri.h"
+#include "promisor-remote.h"
static char *server_capabilities_v1;
static struct strvec server_capabilities_v2 = STRVEC_INIT;
@@ -77,7 +77,7 @@ static NORETURN void die_initial_contact(int unexpected)
/* Checks if the server supports the capability 'c' */
int server_supports_v2(const char *c)
{
- int i;
+ size_t i;
for (i = 0; i < server_capabilities_v2.nr; i++) {
const char *out;
@@ -96,7 +96,7 @@ void ensure_server_supports_v2(const char *c)
int server_feature_v2(const char *c, const char **v)
{
- int i;
+ size_t i;
for (i = 0; i < server_capabilities_v2.nr; i++) {
const char *out;
@@ -112,7 +112,7 @@ int server_feature_v2(const char *c, const char **v)
int server_supports_feature(const char *c, const char *feature,
int die_on_error)
{
- int i;
+ size_t i;
for (i = 0; i < server_capabilities_v2.nr; i++) {
const char *out;
@@ -232,12 +232,12 @@ static void annotate_refs_with_symref_info(struct ref *ref)
string_list_clear(&symref, 0);
}
-static void process_capabilities(struct packet_reader *reader, int *linelen)
+static void process_capabilities(struct packet_reader *reader, size_t *linelen)
{
const char *feat_val;
size_t feat_len;
const char *line = reader->line;
- int nul_location = strlen(line);
+ size_t nul_location = strlen(line);
if (nul_location == *linelen)
return;
server_capabilities_v1 = xstrdup(line + nul_location + 1);
@@ -251,7 +251,7 @@ static void process_capabilities(struct packet_reader *reader, int *linelen)
reader->hash_algo = &hash_algos[hash_algo];
free(hash_name);
} else {
- reader->hash_algo = &hash_algos[GIT_HASH_SHA1];
+ reader->hash_algo = &hash_algos[GIT_HASH_SHA1_LEGACY];
}
}
@@ -271,14 +271,14 @@ static int process_dummy_ref(const struct packet_reader *reader)
!strcmp(name, "capabilities^{}");
}
-static void check_no_capabilities(const char *line, int len)
+static void check_no_capabilities(const char *line, size_t len)
{
if (strlen(line) != len)
warning(_("ignoring capabilities after first line '%s'"),
line + strlen(line));
}
-static int process_ref(const struct packet_reader *reader, int len,
+static int process_ref(const struct packet_reader *reader, size_t len,
struct ref ***list, unsigned int flags,
struct oid_array *extra_have)
{
@@ -306,7 +306,7 @@ static int process_ref(const struct packet_reader *reader, int len,
return 1;
}
-static int process_shallow(const struct packet_reader *reader, int len,
+static int process_shallow(const struct packet_reader *reader, size_t len,
struct oid_array *shallow_points)
{
const char *line = reader->line;
@@ -341,7 +341,7 @@ struct ref **get_remote_heads(struct packet_reader *reader,
struct oid_array *shallow_points)
{
struct ref **orig_list = list;
- int len = 0;
+ size_t len = 0;
enum get_remote_heads_state state = EXPECTING_FIRST_REF;
*list = NULL;
@@ -394,7 +394,7 @@ static int process_ref_v2(struct packet_reader *reader, struct ref ***list,
const char **unborn_head_target)
{
int ret = 1;
- int i = 0;
+ size_t i = 0;
struct object_id old_oid;
struct ref *ref;
struct string_list line_sections = STRING_LIST_INIT_DUP;
@@ -488,6 +488,7 @@ void check_stateless_delimiter(int stateless_rpc,
static void send_capabilities(int fd_out, struct packet_reader *reader)
{
const char *hash_name;
+ const char *promisor_remote_info;
if (server_supports_v2("agent"))
packet_write_fmt(fd_out, "agent=%s", git_user_agent_sanitized());
@@ -499,7 +500,14 @@ static void send_capabilities(int fd_out, struct packet_reader *reader)
reader->hash_algo = &hash_algos[hash_algo];
packet_write_fmt(fd_out, "object-format=%s", reader->hash_algo->name);
} else {
- reader->hash_algo = &hash_algos[GIT_HASH_SHA1];
+ reader->hash_algo = &hash_algos[GIT_HASH_SHA1_LEGACY];
+ }
+ if (server_feature_v2("promisor-remote", &promisor_remote_info)) {
+ char *reply = promisor_remote_reply(promisor_remote_info);
+ if (reply) {
+ packet_write_fmt(fd_out, "promisor-remote=%s", reply);
+ free(reply);
+ }
}
}
@@ -552,7 +560,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
const struct string_list *server_options,
int stateless_rpc)
{
- int i;
+ size_t i;
struct strvec *ref_prefixes = transport_options ?
&transport_options->ref_prefixes : NULL;
const char **unborn_head_target = transport_options ?
@@ -625,7 +633,7 @@ const char *parse_feature_value(const char *feature_list, const char *feature, s
*offset = found + len - orig_start;
return value;
}
- /* feature with a value (e.g., "agent=git/1.2.3") */
+ /* feature with a value (e.g., "agent=git/1.2.3-Linux") */
else if (*value == '=') {
size_t end;
@@ -657,7 +665,7 @@ int server_supports_hash(const char *desired, int *feature_supported)
if (feature_supported)
*feature_supported = !!hash;
if (!hash) {
- hash = hash_algos[GIT_HASH_SHA1].name;
+ hash = hash_algos[GIT_HASH_SHA1_LEGACY].name;
len = strlen(hash);
}
while (hash) {
@@ -1020,7 +1028,7 @@ static int git_proxy_command_options(const char *var, const char *value,
static int git_use_proxy(const char *host)
{
git_proxy_command = getenv("GIT_PROXY_COMMAND");
- git_config(git_proxy_command_options, (void*)host);
+ repo_config(the_repository, git_proxy_command_options, (void*)host);
return (git_proxy_command && *git_proxy_command);
}
@@ -1146,7 +1154,7 @@ static const char *get_ssh_command(void)
if ((ssh = getenv("GIT_SSH_COMMAND")))
return ssh;
- if (!git_config_get_string_tmp("core.sshcommand", &ssh))
+ if (!repo_config_get_string_tmp(the_repository, "core.sshcommand", &ssh))
return ssh;
return NULL;
@@ -1165,7 +1173,7 @@ static void override_ssh_variant(enum ssh_variant *ssh_variant)
{
const char *variant = getenv("GIT_SSH_VARIANT");
- if (!variant && git_config_get_string_tmp("ssh.variant", &variant))
+ if (!variant && repo_config_get_string_tmp(the_repository, "ssh.variant", &variant))
return;
if (!strcmp(variant, "auto"))