git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Cannot clone the git repository shared over http with authorization.

From
Jeff King <peff@peff.net>
Date
Apr 2, 2012, 08:31 UTC
Message-ID
<20120402083115.GA2235@sigill.intra.peff.net>
In-Reply-To
<20120401194534.GA16512@ecki>
On Sun, Apr 01, 2012 at 09:45:36PM +0200, Clemens Buchacher wrote:
Show 5 quoted lines
> So far I figured out that setting 'git config http.maxRequests 1' fixes
> the problem as well. Looking at the output with GIT_CURL_VERBOSE=1 set,
> it seems that some GET requests use the credentials, while others do
> not. My guess is that the CURLOPT_USERPWD option does not apply to all
> threads.

Yes, that is exactly it. Furthermore, the multi-fetch code paths used by the http walker do not have the magic "notice a 401 and retry". I think something like this should fix it (it passes your tests):

diff --git a/http.c b/http.c
index f3f83d7..c6dc9b7 100644
--- a/http.c
+++ b/http.c
@@ -494,6 +494,8 @@ struct active_request_slot *get_active_slot(void)
 	curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
 	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
+	if (http_auth.password)
+		init_curl_http_auth(slot->curl);
 
 	return slot;
 }

which is basically just double-checking that we set CURLOPT_USERPWD
whenever we get a slot (I wish there was some way of asking "does this
curl handle have USERPWD already set?", but I couldn't fine one).

It still doesn't do 401-handling itself, but it works OK in practice
because the first request will be a non-multi fetch (to get info/refs),
which recognizes the 401 and prompts the user, and then that credential
gets used subsequently.

-Peff
Previous: Clemens BuchacherNext: Clemens Buchacher
Message 4 of 12 in “Cannot clone the git repository shared over http with authorization.”
  1. Artur R. CzechowskiApr 1, 2012
  2. Clemens BuchacherApr 1, 2012
  3. Clemens BuchacherApr 1, 2012
  4. Jeff KingApr 2, 2012
  5. Clemens BuchacherApr 10, 2012
  6. 1/2 http auth fails with multiple curl handlesClemens Buchacher, Apr 10, 2012
  7. 2/2 fix http auth with multiple curl handlesClemens Buchacher, Apr 10, 2012
  8. Jeff KingApr 12, 2012
  9. Junio C HamanoApr 12, 2012
  10. Jeff KingApr 13, 2012
  11. 1/2 http: clean up leak in init_curl_http_authJeff King, Apr 13, 2012
  12. 2/2 http: use newer curl options for setting credentialsJeff King, Apr 13, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.