mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-11 08:30:32 -05:00
The git_connect() function takes a "name" argument which is a bit confusing. It is _not_ the program to run on the remote repo, which is specified by the "prog" argument. It should instead be one of a few well-known strings specifying the type of operation (e.g., "git-upload-pack"). But to add to the confusion, unless otherwise configured, those well-known strings will also be the same as the programs we run, making it easy to mistake which variable is which. This confusion comes fromeaa0fd6584(git_connect(): fix corner cases in downgrading v2 to v0, 2023-03-17), though in its defense, the term "name" and the use of a string are found in other connect code, going all the way back tob236752a87(Support remote archive from all smart transports, 2009-12-09). But let's see if we can clean things up a bit. The term "name" is overly vague. We use "service" in other places, including in the smart-http protocol, so let's use it here, too. Using a string invites the notion that it can be anything, not one of a defined set. Let's instead introduce an enum, which has the added bonus that the compiler can catch typos for us, rather than quietly choosing the wrong service from an unexpected strcmp() result. We do still have to turn our enum into those well-known strings to pass along in the remote-helper protocol (e.g., for a stateless-connect directive). But now we do so explicitly and in a way that I think is much more obvious to follow. This is a pure cleanup; there should be no behavior change. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
39 lines
1.4 KiB
C
39 lines
1.4 KiB
C
#ifndef CONNECT_H
|
|
#define CONNECT_H
|
|
|
|
#include "protocol.h"
|
|
|
|
#define CONNECT_VERBOSE (1u << 0)
|
|
#define CONNECT_DIAG_URL (1u << 1)
|
|
#define CONNECT_IPV4 (1u << 2)
|
|
#define CONNECT_IPV6 (1u << 3)
|
|
enum git_connect_service {
|
|
GIT_CONNECT_UPLOAD_PACK,
|
|
GIT_CONNECT_RECEIVE_PACK,
|
|
GIT_CONNECT_UPLOAD_ARCHIVE,
|
|
};
|
|
struct child_process *git_connect(int fd[2], const char *url, enum git_connect_service, const char *prog, int flags);
|
|
int finish_connect(struct child_process *conn);
|
|
int git_connection_is_socket(struct child_process *conn);
|
|
int server_supports(const char *feature);
|
|
int parse_feature_request(const char *features, const char *feature);
|
|
const char *server_feature_value(const char *feature, size_t *len_ret);
|
|
int url_is_local_not_ssh(const char *url);
|
|
|
|
struct packet_reader;
|
|
enum protocol_version discover_version(struct packet_reader *reader);
|
|
|
|
int server_supports_hash(const char *desired, int *feature_supported);
|
|
const char *parse_feature_value(const char *feature_list, const char *feature, size_t *lenp, size_t *offset);
|
|
int server_supports_v2(const char *c);
|
|
void ensure_server_supports_v2(const char *c);
|
|
int server_feature_v2(const char *c, const char **v);
|
|
int server_supports_feature(const char *c, const char *feature,
|
|
int die_on_error);
|
|
|
|
void check_stateless_delimiter(int stateless_rpc,
|
|
struct packet_reader *reader,
|
|
const char *error);
|
|
|
|
#endif
|