Merge branch 'jk/curl-global-trace-components' into maint-2.51

Adjust to the way newer versions of cURL selectivel enables tracing
options, so that our tests can continue to work.

* jk/curl-global-trace-components:
  curl: add support for curl_global_trace() components
maint
Junio C Hamano 2025-10-14 13:41:25 -07:00
commit 2ba32befc9
3 changed files with 18 additions and 1 deletions

View File

@ -45,6 +45,13 @@
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
#endif

/**
* curl_global_trace() was added in 8.3.0, released September 2023.
*/
#if LIBCURL_VERSION_NUM >= 0x080300
#define GIT_CURL_HAVE_GLOBAL_TRACE 1
#endif

/**
* CURLOPT_TCP_KEEPCNT was added in 8.9.0, released in July, 2024.
*/

8
http.c
View File

@ -1348,6 +1348,14 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
die("curl_global_init failed");

#ifdef GIT_CURL_HAVE_GLOBAL_TRACE
{
const char *comp = getenv("GIT_TRACE_CURL_COMPONENTS");
if (comp)
curl_global_trace(comp);
}
#endif

if (proactive_auth && http_proactive_auth == PROACTIVE_AUTH_NONE)
http_proactive_auth = PROACTIVE_AUTH_IF_CREDENTIALS;


View File

@ -72,7 +72,9 @@ test_expect_success SOCKS_PROXY 'clone via Unix socket' '
test_when_finished "rm -rf clone" &&
test_config_global http.proxy "socks4://localhost$PWD/%2530.sock" && {
{
GIT_TRACE_CURL=$PWD/trace git clone "$HTTPD_URL/smart/repo.git" clone 2>err &&
GIT_TRACE_CURL=$PWD/trace \
GIT_TRACE_CURL_COMPONENTS=socks \
git clone "$HTTPD_URL/smart/repo.git" clone 2>err &&
grep -i "SOCKS4 request granted" trace
} ||
old_libcurl_error err