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

Re: [PATCH v2 3/4] pack-objects.c: do stdin parsing via revision.c's API

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jun 18, 2021, 18:57 UTC
Message-ID
<20210618185728.779629-1-jonathantanmy@google.com>
In-Reply-To
<patch-3.4-d433d7b24a-20210617T105537Z-avarab@gmail.com>
> Change the fgets(..., stdin) parsing in pack-objects.c to use a
> now-extended version of the rev_info stdin parsing API.

This leads me to think that the stdin parsing API is already present, but it turns out that it still needs to be extended. Maybe rewrite this as "extend the rev_info stdin parsing API to support <whatever we need to support>, and change the <...> in pack-objects.c to use it".

Show 25 quoted lines
> @@ -136,6 +149,28 @@ struct rev_info {
>  	 */
>  	int consumed_stdin_per_option;
>  
> +	/*
> +	 * When reading from stdin (see "stdin_handling" above) define
> +	 * a handle_stdin_line function to consume the lines.
> +	 *
> +	 * - Return REV_INFO_STDIN_LINE_PROCESS to continue
> +	 *   revision.c's normal processing of the line (after
> +	 *   possibly munging the provided strbuf).
> +	 *
> +	 * - Return REV_INFO_STDIN_LINE_BREAK to process no further
> +	 *   lines, or anything further from the current line (just
> +	 *   like REV_INFO_STDIN_LINE_CONTINUE).
> +	 *
> +	 * - Return REV_INFO_STDIN_LINE_CONTINUE to indicate that the
> +	 *   line is fully processed, moving onto the next line (if
> +	 *   any)
> +	 *
> +	 * Use the "stdin_line_priv" to optionally pass your own data
> +	 * around.
> +	 */
> +	rev_info_stdin_line_func handle_stdin_line;
> +	void *stdin_line_priv;

I assume that all 3 of these are needed now to minimize the diff (which is fine), but maybe comment on which of these are intended to stay and which are only temporary. In particular, (once things are stabilized) when would a caller need BREAK?

Also mention what happens if handle_stdin_line is not given (I presume that it would just be like a no-op function that returns PROCESS every time).

Looking at the bigger picture, though, and looking at the next patch, this looks like a confusing API especially with the presence of "--not". (In the next patch, you had to introduce a flags field, and the callback has to remember to always handle "--not" and to toggle the flag.) Perhaps the "--not" problem can be solved by making it revision.c's concern and having the callback take a boolean parameter indicating whether "--not" is active or not.

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 13 of 35 in “pack-objects: use revision.c's --stdin parsing”
  1. 0/4 pack-objects: use revision.c's --stdin parsingÆvar Arnfjörð Bjarmason, Jun 8, 2021
  2. 2/4 revision.h: unify "disable_stdin" and "read_from_stdin"Ævar Arnfjörð Bjarmason, Jun 8, 2021
  3. 3/4 pack-objects.c: do stdin parsing via revision.c's APIÆvar Arnfjörð Bjarmason, Jun 8, 2021
  4. Junio C HamanoJun 9, 2021
  5. 1/4 upload-pack: run is_repository_shallow() before setup_revisions()Ævar Arnfjörð Bjarmason, Jun 8, 2021
  6. 4/4 pack-objects.c: make use of REV_INFO_STDIN_LINE_PROCESSÆvar Arnfjörð Bjarmason, Jun 8, 2021
  7. 0/4 pack-objects: use revision.c's --stdin parsingÆvar Arnfjörð Bjarmason, Jun 17, 2021
  8. 1/4 upload-pack: run is_repository_shallow() before setup_revisions()Ævar Arnfjörð Bjarmason, Jun 17, 2021
  9. 2/4 revision.h: unify "disable_stdin" and "read_from_stdin"Ævar Arnfjörð Bjarmason, Jun 17, 2021
  10. Emily ShafferJun 17, 2021
  11. Jonathan TanJun 18, 2021
  12. 3/4 pack-objects.c: do stdin parsing via revision.c's APIÆvar Arnfjörð Bjarmason, Jun 17, 2021
  13. Jonathan TanJun 18, 2021
  14. 4/4 pack-objects.c: make use of REV_INFO_STDIN_LINE_PROCESSÆvar Arnfjörð Bjarmason, Jun 17, 2021
  15. 0/4 pack-objects: use revision.c's --stdin parsingÆvar Arnfjörð Bjarmason, Jun 21, 2021
  16. 1/4 upload-pack: run is_repository_shallow() before setup_revisions()Ævar Arnfjörð Bjarmason, Jun 21, 2021
  17. 3/4 pack-objects.c: do stdin parsing via revision.c's APIÆvar Arnfjörð Bjarmason, Jun 21, 2021
  18. Junio C HamanoJul 8, 2021
  19. 2/4 revision.h: refactor "disable_stdin" and "read_from_stdin"Ævar Arnfjörð Bjarmason, Jun 21, 2021
  20. Junio C HamanoJul 8, 2021
  21. 4/4 pack-objects.c: make use of REV_INFO_STDIN_LINE_PROCESSÆvar Arnfjörð Bjarmason, Jun 21, 2021
  22. Junio C HamanoJul 8, 2021
  23. 0/5 revision.[ch]: add --stdin parsing API, use in pack-objectsÆvar Arnfjörð Bjarmason, Jul 9, 2021
  24. 1/5 upload-pack: run is_repository_shallow() before setup_revisions()Ævar Arnfjörð Bjarmason, Jul 9, 2021
  25. 2/5 revision.h: refactor "disable_stdin" and "read_from_stdin"Ævar Arnfjörð Bjarmason, Jul 9, 2021
  26. Junio C HamanoJul 9, 2021
  27. 4/5 pack-objects.c: do stdin parsing via revision.c's APIÆvar Arnfjörð Bjarmason, Jul 9, 2021
  28. 5/5 pack-objects.c: make use of REV_INFO_STDIN_LINE_PROCESSÆvar Arnfjörð Bjarmason, Jul 9, 2021
  29. 3/5 revision.[ch]: add a "handle_stdin_line" APIÆvar Arnfjörð Bjarmason, Jul 9, 2021
  30. 0/5 add --stdin parsing API, use in pack-objectsÆvar Arnfjörð Bjarmason, Jul 26, 2021
  31. 1/5 upload-pack: run is_repository_shallow() before setup_revisions()Ævar Arnfjörð Bjarmason, Jul 26, 2021
  32. 5/5 pack-objects.c: make use of REV_INFO_STDIN_LINE_PROCESSÆvar Arnfjörð Bjarmason, Jul 26, 2021
  33. 2/5 revision.h: refactor "disable_stdin" and "read_from_stdin"Ævar Arnfjörð Bjarmason, Jul 26, 2021
  34. 4/5 pack-objects.c: do stdin parsing via revision.c's APIÆvar Arnfjörð Bjarmason, Jul 26, 2021
  35. 3/5 revision.[ch]: add a "handle_stdin_line" APIÆvar Arnfjörð Bjarmason, Jul 26, 2021

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.