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

Re: [RFC/PATCH] remote-curl: Obey passed URL

From
Jeff King <peff@peff.net>
Date
Oct 6, 2011, 13:25 UTC
Message-ID
<20111006132500.GA1792@sigill.intra.peff.net>
In-Reply-To
<2f1eccfa3fa9e732e9bea344fd69dfd9b16697a9.1317906388.git.git@drmicha.warpmail.net>
On Thu, Oct 06, 2011 at 03:15:59PM +0200, Michael J Gruber wrote:
Show 18 quoted lines
> When the curl remote helper is called, e.g., as
> 
> git-remote-https foo https://john@doe.com
> 
> it looks up remote.foo.url rather than taking the provided url, at least
> as far as http_init() is concerned (authentication). (It does use the
> provided url at later stages.)
> [...]
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -846,6 +846,7 @@ int main(int argc, const char **argv)
>  
>  	if (argc > 2) {
>  		end_url_with_slash(&buf, argv[2]);
> +		remote->url[0] = xstrdup(argv[2]);
>  	} else {
>  		end_url_with_slash(&buf, remote->url[0]);
>  	}

Your analysis is correct, but tweaking the remote object seems kind of ugly. I think a nicer solution would be to pass the URL in separately to http_init. Of the three existing callers:

  1. http-fetch.c just passes a NULL remote. Which means we don't even
     look at the URL at all for grabbing the auth information. Passing
     the URL would be an improvement.
  2. http-push.c creates a fake remote just to stick the URL in. That
     ugly code could just go away.
  3. remote-curl.c needs to pass in the alternate URL anyway, as you
     described.
So it seems like all callsites would benefit.

That being said, I wonder if http_init is the right place to pull the auth information out. It's where we've always done it, and it makes sense if you are hitting one base URL. But what happens if we get a redirect to some other site? Shouldn't we be deciding at the time of making the request what the context of the http request is?

And then http_init can stop caring entirely what the URL is.
-Peff
Previous: Michael J GruberNext: Jeff King
Message 12 of 30 in “Git ksshaskpass to play nice with https and kwallet”
  1. Michael J GruberOct 4, 2011
  2. Jeff KingOct 4, 2011
  3. Michael J GruberOct 4, 2011
  4. Jeff KingOct 4, 2011
  5. Michael J GruberOct 4, 2011
  6. Jeff KingOct 4, 2011
  7. Michael J GruberOct 4, 2011
  8. Jeff KingOct 5, 2011
  9. Jeff KingOct 5, 2011
  10. Michael J GruberOct 6, 2011
  11. remote-curl: Obey passed URLMichael J Gruber, Oct 6, 2011
  12. Jeff KingOct 6, 2011
  13. Jeff KingOct 6, 2011
  14. Michael J GruberOct 12, 2011
  15. http_init: accept separate URL parameterJeff King, Oct 12, 2011
  16. Jeff KingOct 12, 2011
  17. Junio C HamanoOct 12, 2011
  18. Jeff KingOct 12, 2011
  19. Michael J GruberOct 13, 2011
  20. 0/6 http-auth-earlyMichael J Gruber, Oct 14, 2011
  21. Jeff KingOct 14, 2011
  22. Michael J GruberOct 14, 2011
  23. Junio C HamanoOct 14, 2011
  24. 1/6 url: decode buffers that are not NUL-terminatedMichael J Gruber, Oct 14, 2011
  25. 2/6 improve httpd auth testsMichael J Gruber, Oct 14, 2011
  26. 3/6 remote-curl: don't retry auth failures with dumb protocolMichael J Gruber, Oct 14, 2011
  27. 4/6 http: retry authentication failures for all http requestsMichael J Gruber, Oct 14, 2011
  28. 5/6 http: use hostname in credential descriptionMichael J Gruber, Oct 14, 2011
  29. 6/6 http_init: accept separate URL parameterMichael J Gruber, Oct 14, 2011
  30. Tay Ray ChuanOct 13, 2011

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.