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

Re: [PATCH/RFC 1/2] fetch-pack: new option to read refs from stdin

From
Jeff King <peff@peff.net>
Date
Mar 25, 2012, 01:19 UTC
Message-ID
<20120325011948.GC27651@sigill.intra.peff.net>
In-Reply-To
<4F6E3446.9080001@gmx.net>
On Sat, Mar 24, 2012 at 09:53:26PM +0100, Ivan Todoroski wrote:
> From c4bb55f9f27569faa368d823ca6fe4b236e37cd6 Mon Sep 17 00:00:00 2001
> From: Ivan Todoroski <grnch@gmx.net>
> Date: Sat, 24 Mar 2012 15:13:05 +0100
> Subject: [PATCH/RFC 1/2] fetch-pack: new option to read refs from stdin

You can drop these lines; they are redundant with the actual email headers.

Show 5 quoted lines
> ---
>  Documentation/git-fetch-pack.txt |    9 ++++++++
>  builtin/fetch-pack.c             |   44 ++++++++++++++++++++++++++++++++++++--
>  fetch-pack.h                     |    3 ++-
>  3 files changed, 53 insertions(+), 3 deletions(-)

Give more of a commit message. Why is this option useful (I know, of course, from our previous discussion. But keep in mind the audience of developers reading "git log" a year from now).

Show 8 quoted lines
> +--stdin::
> +	Take the list of refs from stdin, one per line. If there
> +	are refs specified on the command line in addition to this
> +	option, then the refs from stdin are processed after those
> +	on the command line.
> +	If '--stateless-rpc' is specified together with this option
> +	then the list of refs must be in packet format (pkt-line)
> +	with a flush packet terminating the list.

Nice. Thanks for taking the time not just to solve your problem, but to give sane semantics in the non-stateless-rpc case.

I think there is a minor formatting bug in the above. Asciidoc will make your two paragraphs into a single one, won't it? I think you need to do the (horribly ugly):

  --stdin::
      First paragraph.
  +
  Second paragraph.
to appease asciidoc.
Show 8 quoted lines
> --- a/builtin/fetch-pack.c
> +++ b/builtin/fetch-pack.c
> @@ -23,7 +23,7 @@ static struct fetch_pack_args args = {
>  };
>  
>  static const char fetch_pack_usage[] =
> -"git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
> +"git fetch-pack [--all] [--stdin] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";

Not a problem you introduced, but maybe it is time for us to cut down this gigantic line (it's 180 characters even before your patch!). Even breaking it across lines at 80 columns would help.

Show 6 quoted lines
> @@ -972,6 +976,42 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
>  	if (!dest)
>  		usage(fetch_pack_usage);
>  
> +	if (args.refs_from_stdin) {
> +		char ref[1000];

Ick. Is there any reason not to use a strbuf here? 1000 is probably plenty, but we are generally moving towards removing such limits where possible.

You'd also get to use strbuf_getline and strbuf_trim in the newline-delimited case.

-Peff
Previous: Ivan TodoroskiNext: Ivan Todoroski
Message 28 of 54 in “Clone fails on a repo with too many heads/tags”
  1. Ivan TodoroskiMar 18, 2012
  2. Ivan TodoroskiMar 18, 2012
  3. Nguyen Thai Ngoc DuyMar 18, 2012
  4. Jakub NarebskiMar 18, 2012
  5. Jeff KingMar 18, 2012
  6. Jakub NarebskiMar 18, 2012
  7. Jeff KingMar 19, 2012
  8. Nguyen Thai Ngoc DuyMar 19, 2012
  9. Jeff KingMar 19, 2012
  10. Ivan TodoroskiMar 19, 2012
  11. Nguyen Thai Ngoc DuyMar 19, 2012
  12. Jeff KingMar 19, 2012
  13. Ivan TodoroskiMar 21, 2012
  14. Shawn PearceMar 21, 2012
  15. Jeff KingMar 21, 2012
  16. Jakub NarebskiMar 21, 2012
  17. Ivan TodoroskiMar 21, 2012
  18. Jeff KingMar 21, 2012
  19. Ivan TodoroskiMar 24, 2012
  20. Jeff KingMar 25, 2012
  21. Jeff KingMar 25, 2012
  22. Ivan TodoroskiMar 25, 2012
  23. Ivan TodoroskiMar 25, 2012
  24. Jeff KingMar 26, 2012
  25. Ivan TodoroskiMar 27, 2012
  26. Ivan TodoroskiMar 25, 2012
  27. 1/2 fetch-pack: new option to read refs from stdinIvan Todoroski, Mar 24, 2012
  28. Jeff KingMar 25, 2012
  29. Ivan TodoroskiMar 25, 2012
  30. Ivan TodoroskiMar 25, 2012
  31. Ivan TodoroskiMar 25, 2012
  32. Jeff KingMar 26, 2012
  33. Ivan TodoroskiMar 26, 2012
  34. Jeff KingMar 26, 2012
  35. 2/2 remote-curl: send the refs to fetch-pack on stdinIvan Todoroski, Mar 24, 2012
  36. Jeff KingMar 25, 2012
  37. Ivan TodoroskiMar 25, 2012
  38. Jeff KingMar 26, 2012
  39. 0/4 Fix fetch-pack command line overflow during cloneIvan Todoroski, Mar 27, 2012
  40. 1/4 fetch-pack: new --stdin option to read refs from stdinIvan Todoroski, Mar 27, 2012
  41. Junio C HamanoMar 27, 2012
  42. Ivan TodoroskiMar 27, 2012
  43. Junio C HamanoMar 27, 2012
  44. Ivan TodoroskiMar 27, 2012
  45. 2/4 remote-curl: send the refs to fetch-pack on stdinIvan Todoroski, Mar 27, 2012
  46. Junio C HamanoMar 27, 2012
  47. Ivan TodoroskiMar 27, 2012
  48. 3/4 fetch-pack: test cases for the new --stdin optionIvan Todoroski, Mar 27, 2012
  49. Junio C HamanoMar 27, 2012
  50. Ivan TodoroskiMar 27, 2012
  51. Junio C HamanoMar 27, 2012
  52. Ivan TodoroskiMar 28, 2012
  53. 4/4 remote-curl: main test case for the OS command line overflowIvan Todoroski, Mar 27, 2012
  54. Junio C HamanoMar 27, 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.