Skip to content

Commit 8f79fb6

Browse files
committed
Merge branch 'ab/http-drop-old-curl-plus'
Conditional compilation around versions of libcURL has been straightened out. * ab/http-drop-old-curl-plus: http: don't hardcode the value of CURL_SOCKOPT_OK http: centralize the accounting of libcurl dependencies http: correct curl version check for CURLOPT_PINNEDPUBLICKEY http: correct version check for CURL_HTTP_VERSION_2 http: drop support for curl < 7.18.0 (again) Makefile: drop support for curl < 7.9.8 (again) INSTALL: mention that we need libcurl 7.19.4 or newer to build INSTALL: reword and copy-edit the "libcurl" section INSTALL: don't mention the "curl" executable at all
2 parents 68658a8 + 32da6e6 commit 8f79fb6

File tree

5 files changed

+157
-34
lines changed

5 files changed

+157
-34
lines changed

INSTALL

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,15 @@ Issues of note:
138138
BLK_SHA1. Also included is a version optimized for PowerPC
139139
(PPC_SHA1).
140140

141-
- "libcurl" library is used by git-http-fetch, git-fetch, and, if
142-
the curl version >= 7.34.0, for git-imap-send. You might also
143-
want the "curl" executable for debugging purposes. If you do not
144-
use http:// or https:// repositories, and do not want to put
145-
patches into an IMAP mailbox, you do not have to have them
146-
(use NO_CURL).
141+
- "libcurl" library is used for fetching and pushing
142+
repositories over http:// or https://, as well as by
143+
git-imap-send if the curl version is >= 7.34.0. If you do
144+
not need that functionality, use NO_CURL to build without
145+
it.
146+
147+
Git requires version "7.19.4" or later of "libcurl" to build
148+
without NO_CURL. This version requirement may be bumped in
149+
the future.
147150

148151
- "expat" library; git-http-push uses it for remote lock
149152
management over DAV. Similar to "curl" above, this is optional

Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,15 +1421,8 @@ else
14211421
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
14221422
PROGRAM_OBJS += http-fetch.o
14231423
PROGRAMS += $(REMOTE_CURL_NAMES)
1424-
curl_check := $(shell (echo 070908; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
1425-
ifeq "$(curl_check)" "070908"
1426-
ifndef NO_EXPAT
1427-
PROGRAM_OBJS += http-push.o
1428-
else
1429-
EXCLUDED_PROGRAMS += git-http-push
1430-
endif
1431-
else
1432-
EXCLUDED_PROGRAMS += git-http-push
1424+
ifndef NO_EXPAT
1425+
PROGRAM_OBJS += http-push.o
14331426
endif
14341427
curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
14351428
ifeq "$(curl_check)" "072200"

git-curl-compat.h

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#ifndef GIT_CURL_COMPAT_H
2+
#define GIT_CURL_COMPAT_H
3+
#include <curl/curl.h>
4+
5+
/**
6+
* This header centralizes the declaration of our libcurl dependencies
7+
* to make it easy to discover the oldest versions we support, and to
8+
* inform decisions about removing support for older libcurl in the
9+
* future.
10+
*
11+
* The oldest supported version of curl is documented in the "INSTALL"
12+
* document.
13+
*
14+
* The source of truth for what versions have which symbols is
15+
* https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions;
16+
* the release dates are taken from curl.git (at
17+
* https://github.com/curl/curl/).
18+
*
19+
* For each X symbol we need from curl we define our own
20+
* GIT_CURL_HAVE_X. If multiple similar symbols with the same prefix
21+
* were defined in the same version we pick one and check for that name.
22+
*
23+
* We may also define a missing CURL_* symbol to its known value, if
24+
* doing so is sufficient to add support for it to older versions that
25+
* don't have it.
26+
*
27+
* Keep any symbols in date order of when their support was
28+
* introduced, oldest first, in the official version of cURL library.
29+
*/
30+
31+
/**
32+
* CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011.
33+
*/
34+
#if LIBCURL_VERSION_NUM < 0x071505
35+
#define CURL_SOCKOPT_OK 0
36+
#endif
37+
38+
/**
39+
* CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012.
40+
*/
41+
#if LIBCURL_VERSION_NUM >= 0x071900
42+
#define GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE 1
43+
#endif
44+
45+
46+
/**
47+
* CURLOPT_LOGIN_OPTIONS was added in 7.34.0, released in December
48+
* 2013.
49+
*
50+
* If we start requiring 7.34.0 we might also be able to remove the
51+
* code conditional on USE_CURL_FOR_IMAP_SEND in imap-send.c, see
52+
* 1e16b255b95 (git-imap-send: use libcurl for implementation,
53+
* 2014-11-09) and the check it added for "072200" in the Makefile.
54+
55+
*/
56+
#if LIBCURL_VERSION_NUM >= 0x072200
57+
#define GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS 1
58+
#endif
59+
60+
/**
61+
* CURL_SSLVERSION_TLSv1_[012] was added in 7.34.0, released in
62+
* December 2013.
63+
*/
64+
#if LIBCURL_VERSION_NUM >= 0x072200
65+
#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
66+
#endif
67+
68+
/**
69+
* CURLOPT_PINNEDPUBLICKEY was added in 7.39.0, released in November
70+
* 2014.
71+
*/
72+
#if LIBCURL_VERSION_NUM >= 0x072c00
73+
#define GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY 1
74+
#endif
75+
76+
/**
77+
* CURL_HTTP_VERSION_2 was added in 7.43.0, released in June 2015.
78+
*
79+
* The CURL_HTTP_VERSION_2 alias (but not CURL_HTTP_VERSION_2_0) has
80+
* always been a macro, not an enum field (checked on curl version
81+
* 7.78.0)
82+
*/
83+
#if LIBCURL_VERSION_NUM >= 0x072b00
84+
#define GIT_CURL_HAVE_CURL_HTTP_VERSION_2 1
85+
#endif
86+
87+
/**
88+
* CURLSSLOPT_NO_REVOKE was added in 7.44.0, released in August 2015.
89+
*
90+
* The CURLSSLOPT_NO_REVOKE is, has always been a macro, not an enum
91+
* field (checked on curl version 7.78.0)
92+
*/
93+
#if LIBCURL_VERSION_NUM >= 0x072c00
94+
#define GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE 1
95+
#endif
96+
97+
/**
98+
* CURLOPT_PROXY_CAINFO was added in 7.52.0, released in August 2017.
99+
*/
100+
#if LIBCURL_VERSION_NUM >= 0x073400
101+
#define GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO 1
102+
#endif
103+
104+
/**
105+
* CURLOPT_PROXY_{KEYPASSWD,SSLCERT,SSLKEY} was added in 7.52.0,
106+
* released in August 2017.
107+
*/
108+
#if LIBCURL_VERSION_NUM >= 0x073400
109+
#define GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD 1
110+
#endif
111+
112+
/**
113+
* CURL_SSLVERSION_TLSv1_3 was added in 7.53.0, released in February
114+
* 2017.
115+
*/
116+
#if LIBCURL_VERSION_NUM >= 0x073400
117+
#define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_3 1
118+
#endif
119+
120+
/**
121+
* CURLSSLSET_{NO_BACKENDS,OK,TOO_LATE,UNKNOWN_BACKEND} were added in
122+
* 7.56.0, released in September 2017.
123+
*/
124+
#if LIBCURL_VERSION_NUM >= 0x073800
125+
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
126+
#endif
127+
128+
#endif

http.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "git-compat-util.h"
2+
#include "git-curl-compat.h"
23
#include "http.h"
34
#include "config.h"
45
#include "pack.h"
@@ -47,19 +48,19 @@ static struct {
4748
{ "sslv2", CURL_SSLVERSION_SSLv2 },
4849
{ "sslv3", CURL_SSLVERSION_SSLv3 },
4950
{ "tlsv1", CURL_SSLVERSION_TLSv1 },
50-
#if LIBCURL_VERSION_NUM >= 0x072200
51+
#ifdef GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
5152
{ "tlsv1.0", CURL_SSLVERSION_TLSv1_0 },
5253
{ "tlsv1.1", CURL_SSLVERSION_TLSv1_1 },
5354
{ "tlsv1.2", CURL_SSLVERSION_TLSv1_2 },
5455
#endif
55-
#if LIBCURL_VERSION_NUM >= 0x073400
56+
#ifdef GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_3
5657
{ "tlsv1.3", CURL_SSLVERSION_TLSv1_3 },
5758
#endif
5859
};
5960
static const char *ssl_key;
6061
static const char *ssl_capath;
6162
static const char *curl_no_proxy;
62-
#if LIBCURL_VERSION_NUM >= 0x072c00
63+
#ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
6364
static const char *ssl_pinnedkey;
6465
#endif
6566
static const char *ssl_cainfo;
@@ -373,10 +374,10 @@ static int http_options(const char *var, const char *value, void *cb)
373374
}
374375

375376
if (!strcmp("http.pinnedpubkey", var)) {
376-
#if LIBCURL_VERSION_NUM >= 0x072c00
377+
#ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
377378
return git_config_pathname(&ssl_pinnedkey, var, value);
378379
#else
379-
warning(_("Public key pinning not supported with cURL < 7.44.0"));
380+
warning(_("Public key pinning not supported with cURL < 7.39.0"));
380381
return 0;
381382
#endif
382383
}
@@ -500,7 +501,7 @@ static int has_cert_password(void)
500501
return 1;
501502
}
502503

503-
#if LIBCURL_VERSION_NUM >= 0x073400
504+
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD
504505
static int has_proxy_cert_password(void)
505506
{
506507
if (http_proxy_ssl_cert == NULL || proxy_ssl_cert_password_required != 1)
@@ -516,7 +517,7 @@ static int has_proxy_cert_password(void)
516517
}
517518
#endif
518519

519-
#if LIBCURL_VERSION_NUM >= 0x071900
520+
#ifdef GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE
520521
static void set_curl_keepalive(CURL *c)
521522
{
522523
curl_easy_setopt(c, CURLOPT_TCP_KEEPALIVE, 1);
@@ -536,7 +537,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
536537
if (rc < 0)
537538
warning_errno("unable to set SO_KEEPALIVE on socket");
538539

539-
return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
540+
return CURL_SOCKOPT_OK;
540541
}
541542

542543
static void set_curl_keepalive(CURL *c)
@@ -732,7 +733,7 @@ static long get_curl_allowed_protocols(int from_user)
732733
return allowed_protocols;
733734
}
734735

735-
#if LIBCURL_VERSION_NUM >=0x072f00
736+
#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
736737
static int get_curl_http_version_opt(const char *version_string, long *opt)
737738
{
738739
int i;
@@ -774,7 +775,7 @@ static CURL *get_curl_handle(void)
774775
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
775776
}
776777

777-
#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
778+
#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
778779
if (curl_http_version) {
779780
long opt;
780781
if (!get_curl_http_version_opt(curl_http_version, &opt)) {
@@ -805,7 +806,7 @@ static CURL *get_curl_handle(void)
805806

806807
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
807808
!http_schannel_check_revoke) {
808-
#if LIBCURL_VERSION_NUM >= 0x072c00
809+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
809810
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
810811
#else
811812
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
@@ -845,20 +846,20 @@ static CURL *get_curl_handle(void)
845846
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
846847
if (ssl_capath != NULL)
847848
curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
848-
#if LIBCURL_VERSION_NUM >= 0x072c00
849+
#ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
849850
if (ssl_pinnedkey != NULL)
850851
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
851852
#endif
852853
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
853854
!http_schannel_use_ssl_cainfo) {
854855
curl_easy_setopt(result, CURLOPT_CAINFO, NULL);
855-
#if LIBCURL_VERSION_NUM >= 0x073400
856+
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
856857
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
857858
#endif
858859
} else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL) {
859860
if (ssl_cainfo != NULL)
860861
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
861-
#if LIBCURL_VERSION_NUM >= 0x073400
862+
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
862863
if (http_proxy_ssl_ca_info != NULL)
863864
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, http_proxy_ssl_ca_info);
864865
#endif
@@ -927,7 +928,6 @@ static CURL *get_curl_handle(void)
927928
*/
928929
curl_easy_setopt(result, CURLOPT_PROXY, "");
929930
} else if (curl_http_proxy) {
930-
#if LIBCURL_VERSION_NUM >= 0x071800
931931
if (starts_with(curl_http_proxy, "socks5h"))
932932
curl_easy_setopt(result,
933933
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
@@ -940,8 +940,7 @@ static CURL *get_curl_handle(void)
940940
else if (starts_with(curl_http_proxy, "socks"))
941941
curl_easy_setopt(result,
942942
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
943-
#endif
944-
#if LIBCURL_VERSION_NUM >= 0x073400
943+
#ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD
945944
else if (starts_with(curl_http_proxy, "https")) {
946945
curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
947946

@@ -1006,7 +1005,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
10061005
free(normalized_url);
10071006
string_list_clear(&config.vars, 1);
10081007

1009-
#if LIBCURL_VERSION_NUM >= 0x073800
1008+
#ifdef GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
10101009
if (http_ssl_backend) {
10111010
const curl_ssl_backend **backends;
10121011
struct strbuf buf = STRBUF_INIT;

imap-send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
14411441
curl_easy_setopt(curl, CURLOPT_PORT, server.port);
14421442

14431443
if (server.auth_method) {
1444-
#if LIBCURL_VERSION_NUM < 0x072200
1444+
#ifndef GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS
14451445
warning("No LOGIN_OPTIONS support in this cURL version");
14461446
#else
14471447
struct strbuf auth = STRBUF_INIT;

0 commit comments

Comments
 (0)