Skip to content

Commit 1119a15

Browse files
peffgitster
authored andcommitted
http: drop support for curl < 7.11.1
Drop support for this ancient version of curl and simplify the code by allowing us get rid of some "#ifdef"'s. Git will not build with vanilla curl older than 7.11.1 due our use of CURLOPT_POSTFIELDSIZE in 37ee680 (http.postbuffer: allow full range of ssize_t values, 2017-04-11). This field was introduced in curl 7.11.1. We could solve these compilation problems with more #ifdefs, but it's not worth the trouble. Version 7.11.1 came out in March of 2004, over 17 years ago. Let's declare that too old and drop any existing ifdefs that go further back. One obvious benefit is that we'll have fewer conditional bits cluttering the code. This patch drops all #ifdefs that reference older versions (note that curl's preprocessor macros are in hex, so we're looking for 070b01, not 071101). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit 1119a15

File tree

3 files changed

+1
-67
lines changed

3 files changed

+1
-67
lines changed

http.c

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,11 @@
1919
static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
2020
static int trace_curl_data = 1;
2121
static int trace_curl_redact = 1;
22-
#if LIBCURL_VERSION_NUM >= 0x070a08
2322
long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
24-
#else
25-
long int git_curl_ipresolve;
26-
#endif
2723
int active_requests;
2824
int http_is_verbose;
2925
ssize_t http_post_buffer = 16 * LARGE_PACKET_MAX;
3026

31-
#if LIBCURL_VERSION_NUM >= 0x070a06
32-
#define LIBCURL_CAN_HANDLE_AUTH_ANY
33-
#endif
34-
3527
static int min_curl_sessions = 1;
3628
static int curl_session_count;
3729
#ifdef USE_CURL_MULTI
@@ -68,15 +60,9 @@ static struct {
6860
{ "tlsv1.3", CURL_SSLVERSION_TLSv1_3 },
6961
#endif
7062
};
71-
#if LIBCURL_VERSION_NUM >= 0x070903
7263
static const char *ssl_key;
73-
#endif
74-
#if LIBCURL_VERSION_NUM >= 0x070908
7564
static const char *ssl_capath;
76-
#endif
77-
#if LIBCURL_VERSION_NUM >= 0x071304
7865
static const char *curl_no_proxy;
79-
#endif
8066
#if LIBCURL_VERSION_NUM >= 0x072c00
8167
static const char *ssl_pinnedkey;
8268
#endif
@@ -101,9 +87,7 @@ static struct {
10187
{ "digest", CURLAUTH_DIGEST },
10288
{ "negotiate", CURLAUTH_GSSNEGOTIATE },
10389
{ "ntlm", CURLAUTH_NTLM },
104-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
10590
{ "anyauth", CURLAUTH_ANY },
106-
#endif
10791
/*
10892
* CURLAUTH_DIGEST_IE has no corresponding command-line option in
10993
* curl(1) and is not included in CURLAUTH_ANY, so we leave it out
@@ -143,7 +127,6 @@ enum http_follow_config http_follow_config = HTTP_FOLLOW_INITIAL;
143127

144128
static struct credential cert_auth = CREDENTIAL_INIT;
145129
static int ssl_cert_password_required;
146-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
147130
static unsigned long http_auth_methods = CURLAUTH_ANY;
148131
static int http_auth_methods_restricted;
149132
/* Modes for which empty_auth cannot actually help us. */
@@ -153,7 +136,6 @@ static unsigned long empty_auth_useless =
153136
| CURLAUTH_DIGEST_IE
154137
#endif
155138
| CURLAUTH_DIGEST;
156-
#endif
157139

158140
static struct curl_slist *pragma_header;
159141
static struct curl_slist *no_pragma_header;
@@ -237,12 +219,8 @@ static void finish_active_slot(struct active_request_slot *slot)
237219
if (slot->results != NULL) {
238220
slot->results->curl_result = slot->curl_result;
239221
slot->results->http_code = slot->http_code;
240-
#if LIBCURL_VERSION_NUM >= 0x070a08
241222
curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
242223
&slot->results->auth_avail);
243-
#else
244-
slot->results->auth_avail = 0;
245-
#endif
246224

247225
curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CONNECTCODE,
248226
&slot->results->http_connectcode);
@@ -305,14 +283,10 @@ static int http_options(const char *var, const char *value, void *cb)
305283
return git_config_string(&ssl_version, var, value);
306284
if (!strcmp("http.sslcert", var))
307285
return git_config_pathname(&ssl_cert, var, value);
308-
#if LIBCURL_VERSION_NUM >= 0x070903
309286
if (!strcmp("http.sslkey", var))
310287
return git_config_pathname(&ssl_key, var, value);
311-
#endif
312-
#if LIBCURL_VERSION_NUM >= 0x070908
313288
if (!strcmp("http.sslcapath", var))
314289
return git_config_pathname(&ssl_capath, var, value);
315-
#endif
316290
if (!strcmp("http.sslcainfo", var))
317291
return git_config_pathname(&ssl_cainfo, var, value);
318292
if (!strcmp("http.sslcertpasswordprotected", var)) {
@@ -461,12 +435,6 @@ static int curl_empty_auth_enabled(void)
461435
if (curl_empty_auth >= 0)
462436
return curl_empty_auth;
463437

464-
#ifndef LIBCURL_CAN_HANDLE_AUTH_ANY
465-
/*
466-
* Our libcurl is too old to do AUTH_ANY in the first place;
467-
* just default to turning the feature off.
468-
*/
469-
#else
470438
/*
471439
* In the automatic case, kick in the empty-auth
472440
* hack as long as we would potentially try some
@@ -479,7 +447,6 @@ static int curl_empty_auth_enabled(void)
479447
if (http_auth_methods_restricted &&
480448
(http_auth_methods & ~empty_auth_useless))
481449
return 1;
482-
#endif
483450
return 0;
484451
}
485452

@@ -552,7 +519,6 @@ static void init_curl_proxy_auth(CURL *result)
552519

553520
var_override(&http_proxy_authmethod, getenv("GIT_HTTP_PROXY_AUTHMETHOD"));
554521

555-
#if LIBCURL_VERSION_NUM >= 0x070a07 /* CURLOPT_PROXYAUTH and CURLAUTH_ANY */
556522
if (http_proxy_authmethod) {
557523
int i;
558524
for (i = 0; i < ARRAY_SIZE(proxy_authmethods); i++) {
@@ -570,7 +536,6 @@ static void init_curl_proxy_auth(CURL *result)
570536
}
571537
else
572538
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
573-
#endif
574539
}
575540

576541
static int has_cert_password(void)
@@ -879,12 +844,8 @@ static CURL *get_curl_handle(void)
879844
}
880845
#endif
881846

882-
#if LIBCURL_VERSION_NUM >= 0x070907
883847
curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
884-
#endif
885-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
886848
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
887-
#endif
888849

889850
#ifdef CURLGSSAPI_DELEGATION_FLAG
890851
if (curl_deleg) {
@@ -940,14 +901,10 @@ static CURL *get_curl_handle(void)
940901
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
941902
if (has_cert_password())
942903
curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password);
943-
#if LIBCURL_VERSION_NUM >= 0x070903
944904
if (ssl_key != NULL)
945905
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
946-
#endif
947-
#if LIBCURL_VERSION_NUM >= 0x070908
948906
if (ssl_capath != NULL)
949907
curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
950-
#endif
951908
#if LIBCURL_VERSION_NUM >= 0x072c00
952909
if (ssl_pinnedkey != NULL)
953910
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
@@ -1180,12 +1137,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
11801137
curl_ssl_verify = 0;
11811138

11821139
set_from_env(&ssl_cert, "GIT_SSL_CERT");
1183-
#if LIBCURL_VERSION_NUM >= 0x070903
11841140
set_from_env(&ssl_key, "GIT_SSL_KEY");
1185-
#endif
1186-
#if LIBCURL_VERSION_NUM >= 0x070908
11871141
set_from_env(&ssl_capath, "GIT_SSL_CAPATH");
1188-
#endif
11891142
set_from_env(&ssl_cainfo, "GIT_SSL_CAINFO");
11901143

11911144
set_from_env(&user_agent, "GIT_HTTP_USER_AGENT");
@@ -1367,12 +1320,8 @@ struct active_request_slot *get_active_slot(void)
13671320
else
13681321
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);
13691322

1370-
#if LIBCURL_VERSION_NUM >= 0x070a08
13711323
curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
1372-
#endif
1373-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
13741324
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
1375-
#endif
13761325
if (http_auth.password || curl_empty_auth_enabled())
13771326
init_curl_http_auth(slot->curl);
13781327

@@ -1654,13 +1603,11 @@ static int handle_curl_result(struct slot_results *results)
16541603
credential_reject(&http_auth);
16551604
return HTTP_NOAUTH;
16561605
} else {
1657-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
16581606
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
16591607
if (results->auth_avail) {
16601608
http_auth_methods &= results->auth_avail;
16611609
http_auth_methods_restricted = 1;
16621610
}
1663-
#endif
16641611
return HTTP_REAUTH;
16651612
}
16661613
} else {

http.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@
2222
#define DEFAULT_MAX_REQUESTS 5
2323
#endif
2424

25-
#if LIBCURL_VERSION_NUM < 0x070704
26-
#define curl_global_cleanup() do { /* nothing */ } while (0)
27-
#endif
28-
29-
#if LIBCURL_VERSION_NUM < 0x070800
30-
#define curl_global_init(a) do { /* nothing */ } while (0)
31-
#elif LIBCURL_VERSION_NUM >= 0x070c00
25+
#if LIBCURL_VERSION_NUM >= 0x070c00
3226
#define curl_global_init(a) curl_global_init_mem(a, xmalloc, free, \
3327
xrealloc, xstrdup, xcalloc)
3428
#endif
@@ -37,10 +31,6 @@
3731
#define NO_CURL_EASY_DUPHANDLE
3832
#endif
3933

40-
#if LIBCURL_VERSION_NUM < 0x070a03
41-
#define CURLE_HTTP_RETURNED_ERROR CURLE_HTTP_NOT_FOUND
42-
#endif
43-
4434
#if LIBCURL_VERSION_NUM < 0x070c03
4535
#define NO_CURL_IOCTL
4636
#endif

remote-curl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ static int set_option(const char *name, const char *value)
185185
strbuf_detach(&unquoted, NULL));
186186
}
187187
return 0;
188-
189-
#if LIBCURL_VERSION_NUM >= 0x070a08
190188
} else if (!strcmp(name, "family")) {
191189
if (!strcmp(value, "ipv4"))
192190
git_curl_ipresolve = CURL_IPRESOLVE_V4;
@@ -197,7 +195,6 @@ static int set_option(const char *name, const char *value)
197195
else
198196
return -1;
199197
return 0;
200-
#endif /* LIBCURL_VERSION_NUM >= 0x070a08 */
201198
} else if (!strcmp(name, "from-promisor")) {
202199
options.from_promisor = 1;
203200
return 0;

0 commit comments

Comments
 (0)