aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-02-27 15:23:01 -0800
committerJunio C Hamano <gitster@pobox.com>2025-02-27 15:23:01 -0800
commit68c3be61fc58cafe3786625f5a2b5cf8e7186392 (patch)
tree70d1c6901fbc4c43276f75f1208215a9f56a4390
parent16b2e579f91cddb672bc63612d516d65c8be0a7c (diff)
parent3306edb3805aac7baf77c4916b5495ff278353e5 (diff)
downloadgit-68c3be61fc58cafe3786625f5a2b5cf8e7186392.tar.xz
Merge branch 'bc/http-push-auth-netrc-fix'
The netrc support (via the cURL library) for the HTTP transport has been re-enabled. * bc/http-push-auth-netrc-fix: http: allow using netrc for WebDAV-based HTTP protocol
-rw-r--r--http.c3
-rwxr-xr-xt/t5540-http-push-webdav.sh10
2 files changed, 11 insertions, 2 deletions
diff --git a/http.c b/http.c
index f4504133e8..0c9a872809 100644
--- a/http.c
+++ b/http.c
@@ -598,8 +598,7 @@ static void init_curl_http_auth(CURL *result)
{
if ((!http_auth.username || !*http_auth.username) &&
(!http_auth.credential || !*http_auth.credential)) {
- int empty_auth = curl_empty_auth_enabled();
- if ((empty_auth != -1 && !always_auth_proactively()) || empty_auth == 1) {
+ if (!always_auth_proactively() && curl_empty_auth_enabled()) {
curl_easy_setopt(result, CURLOPT_USERPWD, ":");
return;
} else if (!always_auth_proactively()) {
diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh
index 37db3dec0c..3fa05ff185 100755
--- a/t/t5540-http-push-webdav.sh
+++ b/t/t5540-http-push-webdav.sh
@@ -201,4 +201,14 @@ test_expect_failure 'push to password-protected repository (no user in URL)' '
test_cmp expect actual
'
+test_expect_success 'push to password-protected repository (netrc)' '
+ test_commit pw-netrc &&
+ echo "default login user@host password pass@host" >"$HOME/.netrc" &&
+ GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
+ git rev-parse --verify HEAD >expect &&
+ git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
+ rev-parse --verify HEAD >actual &&
+ test_cmp expect actual
+'
+
test_done