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

Re: [PATCH v3 2/4] remote-curl: send the refs to fetch-pack on stdin

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 2, 2012, 18:50 UTC
Message-ID
<7vfwcmezn1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4F79C264.1060508@gmx.net>
Ivan Todoroski <grnch@gmx.net> writes:
Show 15 quoted lines
> Now that we can throw an arbitrary number of refs at fetch-pack using
> its --stdin option, we use it in the remote-curl helper to bypass the
> OS command line length limit.
>
> Signed-off-by: Ivan Todoroski <grnch@gmx.net>
> ---
>  remote-curl.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/remote-curl.c b/remote-curl.c
> index d159fe7f34..a728edfa7f 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -633,6 +638,7 @@ static int fetch_git(struct discovery *heads,
>  	argv = xmalloc((15 + nr_heads) * sizeof(char*));

You no longer need an argv array whose size is proportional to nr_heads. I'll queue the patch without "+ nr_heads" part, but we should probably switch this to use argv_array API after this series settles.

Show 21 quoted lines
>  	argv[argc++] = "fetch-pack";
>  	argv[argc++] = "--stateless-rpc";
> +	argv[argc++] = "--stdin";
>  	argv[argc++] = "--lock-pack";
>  	if (options.followtags)
>  		argv[argc++] = "--include-tag";
> @@ -651,23 +657,27 @@ static int fetch_git(struct discovery *heads,
>  		argv[argc++] = depth_arg;
>  	}
>  	argv[argc++] = url;
> +	argv[argc++] = NULL;
> +
>  	for (i = 0; i < nr_heads; i++) {
>  		struct ref *ref = to_fetch[i];
>  		if (!ref->name || !*ref->name)
>  			die("cannot fetch by sha1 over smart http");
> -		argv[argc++] = ref->name;
> +		packet_buf_write(&preamble, "%s\n", ref->name);
>  	}
> -	argv[argc++] = NULL;
> +	packet_buf_flush(&preamble);
Previous: Ivan TodoroskiNext: Ivan Todoroski
Message 5 of 9 in “Clone fails on a repo with too many heads/tags”
  1. 0/4 Clone fails on a repo with too many heads/tagsIvan Todoroski, Apr 2, 2012
  2. 1/4 fetch-pack: new --stdin option to read refs from stdinIvan Todoroski, Apr 2, 2012
  3. Jeff KingApr 2, 2012
  4. 2/4 remote-curl: send the refs to fetch-pack on stdinIvan Todoroski, Apr 2, 2012
  5. Junio C HamanoApr 2, 2012
  6. 3/4 fetch-pack: test cases for the new --stdin optionIvan Todoroski, Apr 2, 2012
  7. Junio C HamanoApr 2, 2012
  8. Ivan TodoroskiApr 3, 2012
  9. 4/4 remote-curl: main test case for the OS command line overflowIvan Todoroski, Apr 2, 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.