http: drop support for curl < 7.16.0

In the last commit we dropped support for curl < 7.11.1, let's continue that and drop support for versions older than 7.16.0. This allows us to get rid of some now-obsolete #ifdefs. Choosing 7.16.0 is a somewhat arbitrary cutoff: 1. It came out in October of 2006, almost 15 years ago. Besides being a nice round number, around 10 years is a common end-of-life support period, even for conservative distributions. 2. That version introduced the curl_multi interface, which gives us a lot of bang for the buck in removing #ifdefs RHEL 5 came with curl 7.15.5[1] (released in August 2006). RHEL 5's extended life cycle program ended on 2020-11-30[1]. RHEL 6 comes with curl 7.19.7 (released in November 2009), and RHEL 7 comes with 7.29.0 (released in February 2013). 1. http://lore.kernel.org/git/873e1f31-2a96-5b72-2f20-a5816cad1b51@jupiterrise.com Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 30, 2021 at 11:31 UTC 013c7e2b070f5b69d6585b0c18426a959f1bf739
6 files changed +2 -122
http-push.c
-23
@@ -203,10 +203,8 @@ static void curl_setup_http(CURL *curl, const char *url,
203 curl_easy_setopt(curl, CURLOPT_INFILE, buffer);
204 curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);
205 curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
206 -#ifndef NO_CURL_IOCTL
206 curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);
207 curl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);
209 -#endif
208 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);
209 curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
210 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);
@@ -249,8 +247,6 @@ static void process_response(void *callback_data)
247 finish_request(request);
248 }
249
252 -#ifdef USE_CURL_MULTI
253 -
250 static void start_fetch_loose(struct transfer_request *request)
251 {
252 struct active_request_slot *slot;
@@ -299,7 +295,6 @@ static void start_mkcol(struct transfer_request *request)
295 FREE_AND_NULL(request->url);
296 }
297 }
302 -#endif
298
299 static void start_fetch_packed(struct transfer_request *request)
300 {
@@ -605,7 +600,6 @@ static void finish_request(struct transfer_request *request)
600 }
601 }
602
608 -#ifdef USE_CURL_MULTI
603 static int is_running_queue;
604 static int fill_active_slot(void *unused)
605 {
@@ -629,7 +623,6 @@ static int fill_active_slot(void *unused)
623 }
624 return 0;
625 }
632 -#endif
626
627 static void get_remote_object_list(unsigned char parent);
628
@@ -658,10 +651,8 @@ static void add_fetch_request(struct object *obj)
651 request->next = request_queue_head;
652 request_queue_head = request;
653
661 -#ifdef USE_CURL_MULTI
654 fill_active_slots();
655 step_active_slots();
664 -#endif
656 }
657
658 static int add_send_request(struct object *obj, struct remote_lock *lock)
@@ -696,10 +687,8 @@ static int add_send_request(struct object *obj, struct remote_lock *lock)
687 request->next = request_queue_head;
688 request_queue_head = request;
689
699 -#ifdef USE_CURL_MULTI
690 fill_active_slots();
691 step_active_slots();
702 -#endif
692
693 return 1;
694 }
@@ -1682,21 +1671,15 @@ static int delete_remote_branch(const char *pattern, int force)
1671
1672 static void run_request_queue(void)
1673 {
1685 -#ifdef USE_CURL_MULTI
1674 is_running_queue = 1;
1675 fill_active_slots();
1676 add_fill_function(NULL, fill_active_slot);
1689 -#endif
1677 do {
1678 finish_all_active_slots();
1692 -#ifdef USE_CURL_MULTI
1679 fill_active_slots();
1694 -#endif
1680 } while (request_queue_head && !aborted);
1681
1697 -#ifdef USE_CURL_MULTI
1682 is_running_queue = 0;
1699 -#endif
1683 }
1684
1685 int cmd_main(int argc, const char **argv)
@@ -1770,10 +1753,6 @@ int cmd_main(int argc, const char **argv)
1753 break;
1754 }
1755
1773 -#ifndef USE_CURL_MULTI
1774 - die("git-push is not available for http/https repository when not compiled with USE_CURL_MULTI");
1775 -#endif
1776 -
1756 if (!repo->url)
1757 usage(http_push_usage);
1758
@@ -1786,9 +1765,7 @@ int cmd_main(int argc, const char **argv)
1765
1766 http_init(NULL, repo->url, 1);
1767
1789 -#ifdef USE_CURL_MULTI
1768 is_running_queue = 0;
1791 -#endif
1769
1770 /* Verify DAV compliance/lock support */
1771 if (!locking_available()) {
http-walker.c
-12
@@ -127,7 +127,6 @@ static void release_object_request(struct object_request *obj_req)
127 free(obj_req);
128 }
129
130 -#ifdef USE_CURL_MULTI
130 static int fill_active_slot(struct walker *walker)
131 {
132 struct object_request *obj_req;
@@ -146,7 +145,6 @@ static int fill_active_slot(struct walker *walker)
145 }
146 return 0;
147 }
149 -#endif
148
149 static void prefetch(struct walker *walker, unsigned char *sha1)
150 {
@@ -163,10 +161,8 @@ static void prefetch(struct walker *walker, unsigned char *sha1)
161 http_is_verbose = walker->get_verbosely;
162 list_add_tail(&newreq->node, &object_queue_head);
163
166 -#ifdef USE_CURL_MULTI
164 fill_active_slots();
165 step_active_slots();
169 -#endif
166 }
167
168 static int is_alternate_allowed(const char *url)
@@ -357,11 +353,9 @@ static void fetch_alternates(struct walker *walker, const char *base)
353 * wait for them to arrive and return to processing this request's
354 * curl message
355 */
360 -#ifdef USE_CURL_MULTI
356 while (cdata->got_alternates == 0) {
357 step_active_slots();
358 }
364 -#endif
359
360 /* Nothing to do if they've already been fetched */
361 if (cdata->got_alternates == 1)
@@ -505,12 +499,8 @@ static int fetch_object(struct walker *walker, unsigned char *hash)
499 return 0;
500 }
501
508 -#ifdef USE_CURL_MULTI
502 while (obj_req->state == WAITING)
503 step_active_slots();
511 -#else
512 - start_object_request(walker, obj_req);
513 -#endif
504
505 /*
506 * obj_req->req might change when fetching alternates in the callback
@@ -623,9 +613,7 @@ struct walker *get_http_walker(const char *url)
613 walker->cleanup = cleanup;
614 walker->data = data;
615
626 -#ifdef USE_CURL_MULTI
616 add_fill_function(walker, (int (*)(void *)) fill_active_slot);
628 -#endif
617
618 return walker;
619 }
http.c
+1 -55
@@ -26,10 +26,8 @@ ssize_t http_post_buffer = 16 * LARGE_PACKET_MAX;
26
27 static int min_curl_sessions = 1;
28 static int curl_session_count;
29 -#ifdef USE_CURL_MULTI
29 static int max_requests = -1;
30 static CURLM *curlm;
32 -#endif
31 #ifndef NO_CURL_EASY_DUPHANDLE
32 static CURL *curl_default;
33 #endif
@@ -117,14 +115,6 @@ static int curl_empty_auth = -1;
115
116 enum http_follow_config http_follow_config = HTTP_FOLLOW_INITIAL;
117
120 -#if LIBCURL_VERSION_NUM >= 0x071700
121 -/* Use CURLOPT_KEYPASSWD as is */
122 -#elif LIBCURL_VERSION_NUM >= 0x070903
123 -#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
124 -#else
125 -#define CURLOPT_KEYPASSWD CURLOPT_SSLCERTPASSWD
126 -#endif
127 -
118 static struct credential cert_auth = CREDENTIAL_INIT;
119 static int ssl_cert_password_required;
120 static unsigned long http_auth_methods = CURLAUTH_ANY;
@@ -168,7 +158,6 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
158 return size / eltsize;
159 }
160
171 -#ifndef NO_CURL_IOCTL
161 curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)
162 {
163 struct buffer *buffer = clientp;
@@ -185,7 +174,6 @@ curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)
174 return CURLIOE_UNKNOWNCMD;
175 }
176 }
188 -#endif
177
178 size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
179 {
@@ -233,12 +221,9 @@ static void finish_active_slot(struct active_request_slot *slot)
221
222 static void xmulti_remove_handle(struct active_request_slot *slot)
223 {
236 -#ifdef USE_CURL_MULTI
224 curl_multi_remove_handle(curlm, slot->curl);
238 -#endif
225 }
226
241 -#ifdef USE_CURL_MULTI
227 static void process_curl_messages(void)
228 {
229 int num_messages;
@@ -266,7 +251,6 @@ static void process_curl_messages(void)
251 curl_message = curl_multi_info_read(curlm, &num_messages);
252 }
253 }
269 -#endif
254
255 static int http_options(const char *var, const char *value, void *cb)
256 {
@@ -315,18 +299,14 @@ static int http_options(const char *var, const char *value, void *cb)
299
300 if (!strcmp("http.minsessions", var)) {
301 min_curl_sessions = git_config_int(var, value);
318 -#ifndef USE_CURL_MULTI
302 if (min_curl_sessions > 1)
303 min_curl_sessions = 1;
321 -#endif
304 return 0;
305 }
324 -#ifdef USE_CURL_MULTI
306 if (!strcmp("http.maxrequests", var)) {
307 max_requests = git_config_int(var, value);
308 return 0;
309 }
329 -#endif
310 if (!strcmp("http.lowspeedlimit", var)) {
311 curl_low_speed_limit = (long)git_config_int(var, value);
312 return 0;
@@ -574,7 +554,7 @@ static void set_curl_keepalive(CURL *c)
554 curl_easy_setopt(c, CURLOPT_TCP_KEEPALIVE, 1);
555 }
556
577 -#elif LIBCURL_VERSION_NUM >= 0x071000
557 +#else
558 static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
559 {
560 int ka = 1;
@@ -595,12 +575,6 @@ static void set_curl_keepalive(CURL *c)
575 {
576 curl_easy_setopt(c, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
577 }
598 -
599 -#else
600 -static void set_curl_keepalive(CURL *c)
601 -{
602 - /* not supported on older curl versions */
603 -}
578 #endif
579
580 static void redact_sensitive_header(struct strbuf *header)
@@ -1121,7 +1095,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1095 no_pragma_header = curl_slist_append(http_copy_default_headers(),
1096 "Pragma:");
1097
1124 -#ifdef USE_CURL_MULTI
1098 {
1099 char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
1100 if (http_max_requests != NULL)
@@ -1131,7 +1104,6 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1104 curlm = curl_multi_init();
1105 if (!curlm)
1106 die("curl_multi_init failed");
1134 -#endif
1107
1108 if (getenv("GIT_SSL_NO_VERIFY"))
1109 curl_ssl_verify = 0;
@@ -1154,10 +1126,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1126 curl_ssl_verify = 1;
1127
1128 curl_session_count = 0;
1157 -#ifdef USE_CURL_MULTI
1129 if (max_requests < 1)
1130 max_requests = DEFAULT_MAX_REQUESTS;
1160 -#endif
1131
1132 set_from_env(&http_proxy_ssl_cert, "GIT_PROXY_SSL_CERT");
1133 set_from_env(&http_proxy_ssl_key, "GIT_PROXY_SSL_KEY");
@@ -1201,9 +1171,7 @@ void http_cleanup(void)
1171 curl_easy_cleanup(curl_default);
1172 #endif
1173
1204 -#ifdef USE_CURL_MULTI
1174 curl_multi_cleanup(curlm);
1206 -#endif
1175 curl_global_cleanup();
1176
1177 string_list_clear(&extra_http_headers, 0);
@@ -1250,7 +1218,6 @@ struct active_request_slot *get_active_slot(void)
1218 struct active_request_slot *slot = active_queue_head;
1219 struct active_request_slot *newslot;
1220
1253 -#ifdef USE_CURL_MULTI
1221 int num_transfers;
1222
1223 /* Wait for a slot to open up if the queue is full */
@@ -1259,7 +1226,6 @@ struct active_request_slot *get_active_slot(void)
1226 if (num_transfers < active_requests)
1227 process_curl_messages();
1228 }
1262 -#endif
1229
1230 while (slot != NULL && slot->in_use)
1231 slot = slot->next;
@@ -1330,7 +1296,6 @@ struct active_request_slot *get_active_slot(void)
1296
1297 int start_active_slot(struct active_request_slot *slot)
1298 {
1333 -#ifdef USE_CURL_MULTI
1299 CURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl);
1300 int num_transfers;
1301
@@ -1348,11 +1313,9 @@ int start_active_slot(struct active_request_slot *slot)
1313 * something.
1314 */
1315 curl_multi_perform(curlm, &num_transfers);
1351 -#endif
1316 return 1;
1317 }
1318
1355 -#ifdef USE_CURL_MULTI
1319 struct fill_chain {
1320 void *data;
1321 int (*fill)(void *);
@@ -1411,11 +1374,9 @@ void step_active_slots(void)
1374 fill_active_slots();
1375 }
1376 }
1414 -#endif
1377
1378 void run_active_slot(struct active_request_slot *slot)
1379 {
1418 -#ifdef USE_CURL_MULTI
1380 fd_set readfds;
1381 fd_set writefds;
1382 fd_set excfds;
@@ -1428,7 +1389,6 @@ void run_active_slot(struct active_request_slot *slot)
1389 step_active_slots();
1390
1391 if (slot->in_use) {
1431 -#if LIBCURL_VERSION_NUM >= 0x070f04
1392 long curl_timeout;
1393 curl_multi_timeout(curlm, &curl_timeout);
1394 if (curl_timeout == 0) {
@@ -1440,10 +1400,6 @@ void run_active_slot(struct active_request_slot *slot)
1400 select_timeout.tv_sec = curl_timeout / 1000;
1401 select_timeout.tv_usec = (curl_timeout % 1000) * 1000;
1402 }
1443 -#else
1444 - select_timeout.tv_sec = 0;
1445 - select_timeout.tv_usec = 50000;
1446 -#endif
1403
1404 max_fd = -1;
1405 FD_ZERO(&readfds);
@@ -1466,12 +1422,6 @@ void run_active_slot(struct active_request_slot *slot)
1422 select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
1423 }
1424 }
1469 -#else
1470 - while (slot->in_use) {
1471 - slot->curl_result = curl_easy_perform(slot->curl);
1472 - finish_active_slot(slot);
1473 - }
1474 -#endif
1425 }
1426
1427 static void release_active_slot(struct active_request_slot *slot)
@@ -1485,9 +1435,7 @@ static void release_active_slot(struct active_request_slot *slot)
1435 curl_session_count--;
1436 }
1437 }
1488 -#ifdef USE_CURL_MULTI
1438 fill_active_slots();
1490 -#endif
1439 }
1440
1441 void finish_all_active_slots(void)
@@ -1613,12 +1561,10 @@ static int handle_curl_result(struct slot_results *results)
1561 } else {
1562 if (results->http_connectcode == 407)
1563 credential_reject(&proxy_auth);
1616 -#if LIBCURL_VERSION_NUM >= 0x070c00
1564 if (!curl_errorstr[0])
1565 strlcpy(curl_errorstr,
1566 curl_easy_strerror(results->curl_result),
1567 sizeof(curl_errorstr));
1621 -#endif
1568 return HTTP_ERROR;
1569 }
1570 }
http.h
+1 -24
@@ -10,31 +10,12 @@
10 #include "remote.h"
11 #include "url.h"
12
13 -/*
14 - * We detect based on the cURL version if multi-transfer is
15 - * usable in this implementation and define this symbol accordingly.
16 - * This shouldn't be set by the Makefile or by the user (e.g. via CFLAGS).
17 - */
18 -#undef USE_CURL_MULTI
19 -
20 -#if LIBCURL_VERSION_NUM >= 0x071000
21 -#define USE_CURL_MULTI
13 #define DEFAULT_MAX_REQUESTS 5
23 -#endif
24 -
25 -#if LIBCURL_VERSION_NUM >= 0x070c00
26 -#define curl_global_init(a) curl_global_init_mem(a, xmalloc, free, \
27 - xrealloc, xstrdup, xcalloc)
28 -#endif
14
30 -#if (LIBCURL_VERSION_NUM < 0x070c04) || (LIBCURL_VERSION_NUM == 0x071000)
15 +#if LIBCURL_VERSION_NUM == 0x071000
16 #define NO_CURL_EASY_DUPHANDLE
17 #endif
18
34 -#if LIBCURL_VERSION_NUM < 0x070c03
35 -#define NO_CURL_IOCTL
36 -#endif
37 -
19 /*
20 * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4,
21 * and the constants were known as CURLFTPSSL_*
@@ -72,9 +53,7 @@ struct buffer {
53 size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
54 size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
55 size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
75 -#ifndef NO_CURL_IOCTL
56 curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);
77 -#endif
57
58 /* Slot lifecycle functions */
59 struct active_request_slot *get_active_slot(void);
@@ -91,11 +70,9 @@ void finish_all_active_slots(void);
70 int run_one_slot(struct active_request_slot *slot,
71 struct slot_results *results);
72
94 -#ifdef USE_CURL_MULTI
73 void fill_active_slots(void);
74 void add_fill_function(void *data, int (*fill)(void *));
75 void step_active_slots(void);
98 -#endif
76
77 void http_init(struct remote *remote, const char *url,
78 int proactive_auth);
imap-send.c
-4
@@ -1526,11 +1526,7 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,
1526 if (cred.username) {
1527 if (res == CURLE_OK)
1528 credential_approve(&cred);
1529 -#if LIBCURL_VERSION_NUM >= 0x070d01
1529 else if (res == CURLE_LOGIN_DENIED)
1531 -#else
1532 - else
1533 -#endif
1530 credential_reject(&cred);
1531 }
1532
remote-curl.c
-4
@@ -706,7 +706,6 @@ static size_t rpc_out(void *ptr, size_t eltsize,
706 return avail;
707 }
708
709 -#ifndef NO_CURL_IOCTL
709 static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
710 {
711 struct rpc_state *rpc = clientp;
@@ -727,7 +726,6 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
726 return CURLIOE_UNKNOWNCMD;
727 }
728 }
730 -#endif
729
730 struct check_pktline_state {
731 char len_buf[4];
@@ -946,10 +944,8 @@ retry:
944 rpc->initial_buffer = 1;
945 curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);
946 curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);
949 -#ifndef NO_CURL_IOCTL
947 curl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);
948 curl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);
952 -#endif
949 if (options.verbosity > 1) {
950 fprintf(stderr, "POST %s (chunked)\n", rpc->service_name);
951 fflush(stderr);