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

Re: [PATCH v2 2/4] revision.h: unify "disable_stdin" and "read_from_stdin"

From
Emily Shaffer <emilyshaffer@google.com>
Date
Jun 17, 2021, 23:44 UTC
Message-ID
<YMveZXZRM5vHYRx5@google.com>
In-Reply-To
<patch-2.4-d88b2c0410-20210617T105537Z-avarab@gmail.com>
On Thu, Jun 17, 2021 at 12:57:35PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 14 quoted lines
> 
> In 8b3dce56508 (Teach --stdin option to "log" family, 2009-11-03) we
> added the "disable_stdin" flag, and then much later in
> a12cbe23ef7 (rev-list: make empty --stdin not an error, 2018-08-22) we
> gained a "read_from_stdin" flag.
> 
> The interaction between these is more subtle than they might appear at
> first sight, as noted in a12cbe23ef7. "read_stdin" is not the inverse
> of "disable_stdin", rather we read stdin if we see the "--stdin"
> option.
> 
> The "read" is intended to understood as "I read it", not "you should
> read it". Let's avoid this confusion by using "consume" and "consumed"
> instead, i.e. a word whose present and past tense isn't the same.
Unfortunately, I still find your disambiguation text to be ambiguous...
Show 18 quoted lines
> diff --git a/revision.c b/revision.c
> index 8140561b6c..69b3812093 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -2741,11 +2741,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
>  			}
>  
>  			if (!strcmp(arg, "--stdin")) {
> -				if (revs->disable_stdin) {
> +				if (revs->stdin_handling == REV_INFO_STDIN_IGNORE) {
>  					argv[left++] = arg;
>  					continue;
>  				}
> -				if (revs->read_from_stdin++)
> +				if (revs->consumed_stdin_per_option++)
>  					die("--stdin given twice?");
>  				read_revisions_from_stdin(revs, &prune_data);
>  				continue;

Eeh. I know this is not logic introduced by your patch, BUT your patch does change the semantics of the replacement to ->disable_stdin from a bool to an enum. There is an implicit assumption here - "if stdin_handling isn't REV_INFO_STDIN_IGNORE, then it must be REV_INFO_CONSUME_ON_OPTION." That's true during this patch, but becomes false in the next patch in this series, and it didn't look to me like this section of code was changed accordingly. [snip]

Show 7 quoted lines
> +	/*
> +	 * Did we read from stdin due to stdin_handling ==
> +	 * REV_INFO_STDIN_CONSUME_ON_OPTION and seeing the --stdin
> +	 * option?
>  	 */
> -	int read_from_stdin;
> +	int consumed_stdin_per_option;

And indeed, the comment here confirms the implicit assumption made in the code. Based on this comment, I'd expect the implementation to explicitly check that stdin_handling == CONSUME_ON_OPTION.

 - Emily
Previous: Ævar Arnfjörð BjarmasonNext: Jonathan Tan
Message 10 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.