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

Re: [PATCH] http-push and http-fetch: handle URLs without leading /

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 19, 2008, 23:14 UTC
Message-ID
<alpine.LSU.1.00.0801192310290.5731@racer.site>
In-Reply-To
<1200756171-11696-4-git-send-email-gb@gbarbier.org>
Hi,
On Sat, 19 Jan 2008, Grégoire Barbier wrote:
> Since HTTP/302 is not handled in the git code calling curl, URLs without
> leading / used to lead to frozen git-fetch or git-push with no error message.

JFYI these lines are a little bit too long; I would like to see them unwrapped with a 4-space indent on a 80-column display.

I am not sure how easily Junio can fix them.
Show 13 quoted lines
> @@ -51,6 +52,12 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
>  		commits = 1;
>  	}
>  	url = argv[arg];
> +        if (url && url[strlen(url)-1] != '/') {
> +                rewritten_url = malloc(strlen(url)+2);
> +                strcpy(rewritten_url, url);
> +                strcat(rewritten_url, "/");
> +                url = rewritten_url;
> +        }
>  
>  	walker = get_http_walker(url);
>  	walker->get_tree = get_tree;
Please use strbuf, like so:
	struct strbuf rewritten_url = STRBUF_INIT;
	...
	url = argv[arg];
        if (url && url[strlen(url)-1] != '/') {
		strbuf_addstr(&rewritten_url, url);
		strbuf_addch(&rewritten_url, '/');
		url = rewritten_url.buf;
	}
	...
	strbuf_release(&rewritten_url);
	
BTW it seems you indented using spaces, but we like the indentation as 
tabs in git.git.
Other than that, I like your patch!

Thanks, Dscho

Previous: Johannes SchindelinNext: Junio C Hamano
Message 11 of 13 in “http-push: fix webdav lock leak.”
  1. http-push: fix webdav lock leak.Grégoire Barbier, Jan 19, 2008
  2. http-push: fail when info/refs exists and is already lockedGrégoire Barbier, Jan 19, 2008
  3. http-push: more explicit error message with bad URL or passwordGrégoire Barbier, Jan 19, 2008
  4. http-push and http-fetch: handle URLs without leading /Grégoire Barbier, Jan 19, 2008
  5. added #define DEFAULT_MAX_REQUESTS for USE_CURL_MULTI modeGrégoire Barbier, Jan 19, 2008
  6. Junio C HamanoJan 21, 2008
  7. Grégoire BarbierJan 21, 2008
  8. Junio C HamanoJan 21, 2008
  9. Mike HommeyJan 19, 2008
  10. Johannes SchindelinJan 19, 2008
  11. Johannes SchindelinJan 19, 2008
  12. Junio C HamanoJan 20, 2008
  13. Johannes SchindelinJan 19, 2008

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.