Skip to content

Commit 644de29

Browse files
peffgitster
authored andcommitted
http: drop support for curl < 7.19.4
In the last commit we dropped support for curl < 7.16.0, let's continue that and drop support for versions older than 7.19.3. This allows us to simplify the code by getting rid of some "#ifdef"'s. Git was broken with vanilla curl < 7.19.4 from v2.12.0 until v2.15.0. Compiling with it was broken by using CURLPROTO_* outside any "#ifdef" in aeae4db (http: create function to get curl allowed protocols, 2016-12-14), and fixed in v2.15.0 in f18777b (http: fix handling of missing CURLPROTO_*, 2017-08-11). It's unclear how much anyone was impacted by that in practice, since as noted in [1] RHEL versions using curl older than that still compiled, because RedHat backported some features. Perhaps other vendors did the same. Still, it's one datapoint indicating that it wasn't in active use at the time. That (the v2.12.0 release) was in Feb 24, 2017, with v2.15.0 on Oct 30, 2017, it's now mid-2021. 1. http://lore.kernel.org/git/[email protected]; followed-up by f18777b (http: fix handling of missing CURLPROTO_*, 2017-08-11) 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 013c7e2 commit 644de29

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

http.c

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ static int min_curl_sessions = 1;
2828
static int curl_session_count;
2929
static int max_requests = -1;
3030
static CURLM *curlm;
31-
#ifndef NO_CURL_EASY_DUPHANDLE
3231
static CURL *curl_default;
33-
#endif
3432

3533
#define PREV_BUF_SIZE 4096
3634

@@ -440,24 +438,8 @@ static void init_curl_http_auth(CURL *result)
440438

441439
credential_fill(&http_auth);
442440

443-
#if LIBCURL_VERSION_NUM >= 0x071301
444441
curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username);
445442
curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password);
446-
#else
447-
{
448-
static struct strbuf up = STRBUF_INIT;
449-
/*
450-
* Note that we assume we only ever have a single set of
451-
* credentials in a given program run, so we do not have
452-
* to worry about updating this buffer, only setting its
453-
* initial value.
454-
*/
455-
if (!up.len)
456-
strbuf_addf(&up, "%s:%s",
457-
http_auth.username, http_auth.password);
458-
curl_easy_setopt(result, CURLOPT_USERPWD, up.buf);
459-
}
460-
#endif
461443
}
462444

463445
/* *var must be free-able */
@@ -471,22 +453,10 @@ static void var_override(const char **var, char *value)
471453

472454
static void set_proxyauth_name_password(CURL *result)
473455
{
474-
#if LIBCURL_VERSION_NUM >= 0x071301
475456
curl_easy_setopt(result, CURLOPT_PROXYUSERNAME,
476457
proxy_auth.username);
477458
curl_easy_setopt(result, CURLOPT_PROXYPASSWORD,
478459
proxy_auth.password);
479-
#else
480-
struct strbuf s = STRBUF_INIT;
481-
482-
strbuf_addstr_urlencode(&s, proxy_auth.username,
483-
is_rfc3986_unreserved);
484-
strbuf_addch(&s, ':');
485-
strbuf_addstr_urlencode(&s, proxy_auth.password,
486-
is_rfc3986_unreserved);
487-
curl_proxyuserpwd = strbuf_detach(&s, NULL);
488-
curl_easy_setopt(result, CURLOPT_PROXYUSERPWD, curl_proxyuserpwd);
489-
#endif
490460
}
491461

492462
static void init_curl_proxy_auth(CURL *result)
@@ -748,7 +718,6 @@ void setup_curl_trace(CURL *handle)
748718
curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
749719
}
750720

751-
#ifdef CURLPROTO_HTTP
752721
static long get_curl_allowed_protocols(int from_user)
753722
{
754723
long allowed_protocols = 0;
@@ -764,7 +733,6 @@ static long get_curl_allowed_protocols(int from_user)
764733

765734
return allowed_protocols;
766735
}
767-
#endif
768736

769737
#if LIBCURL_VERSION_NUM >=0x072f00
770738
static int get_curl_http_version_opt(const char *version_string, long *opt)
@@ -906,19 +874,11 @@ static CURL *get_curl_handle(void)
906874
}
907875

908876
curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
909-
#if LIBCURL_VERSION_NUM >= 0x071301
910877
curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
911-
#elif LIBCURL_VERSION_NUM >= 0x071101
912-
curl_easy_setopt(result, CURLOPT_POST301, 1);
913-
#endif
914-
#ifdef CURLPROTO_HTTP
915878
curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
916879
get_curl_allowed_protocols(0));
917880
curl_easy_setopt(result, CURLOPT_PROTOCOLS,
918881
get_curl_allowed_protocols(-1));
919-
#else
920-
warning(_("Protocol restrictions not supported with cURL < 7.19.4"));
921-
#endif
922882
if (getenv("GIT_CURL_VERBOSE"))
923883
http_trace_curl_no_data();
924884
setup_curl_trace(result);
@@ -1012,11 +972,9 @@ static CURL *get_curl_handle(void)
1012972
die("Invalid proxy URL '%s'", curl_http_proxy);
1013973

1014974
curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
1015-
#if LIBCURL_VERSION_NUM >= 0x071304
1016975
var_override(&curl_no_proxy, getenv("NO_PROXY"));
1017976
var_override(&curl_no_proxy, getenv("no_proxy"));
1018977
curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy);
1019-
#endif
1020978
}
1021979
init_curl_proxy_auth(result);
1022980

@@ -1147,9 +1105,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
11471105
ssl_cert_password_required = 1;
11481106
}
11491107

1150-
#ifndef NO_CURL_EASY_DUPHANDLE
11511108
curl_default = get_curl_handle();
1152-
#endif
11531109
}
11541110

11551111
void http_cleanup(void)
@@ -1167,9 +1123,7 @@ void http_cleanup(void)
11671123
}
11681124
active_queue_head = NULL;
11691125

1170-
#ifndef NO_CURL_EASY_DUPHANDLE
11711126
curl_easy_cleanup(curl_default);
1172-
#endif
11731127

11741128
curl_multi_cleanup(curlm);
11751129
curl_global_cleanup();
@@ -1248,11 +1202,7 @@ struct active_request_slot *get_active_slot(void)
12481202
}
12491203

12501204
if (slot->curl == NULL) {
1251-
#ifdef NO_CURL_EASY_DUPHANDLE
1252-
slot->curl = get_curl_handle();
1253-
#else
12541205
slot->curl = curl_easy_duphandle(curl_default);
1255-
#endif
12561206
curl_session_count++;
12571207
}
12581208

http.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
#define DEFAULT_MAX_REQUESTS 5
1414

15-
#if LIBCURL_VERSION_NUM == 0x071000
16-
#define NO_CURL_EASY_DUPHANDLE
17-
#endif
18-
1915
/*
2016
* CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4,
2117
* and the constants were known as CURLFTPSSL_*

0 commit comments

Comments
 (0)