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

Re: [PATCH 3/5] hook API: support passing stdin to hooks, convert am's 'post-rewrite'

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 23, 2023, 23:13 UTC
Message-ID
<xmqqy1pskfo6.fsf@gitster.g>
In-Reply-To
<patch-3.5-c6b9b69c516-20230123T170551Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 13 quoted lines
> @@ -53,8 +53,14 @@ static int pick_next_hook(struct child_process *cp,
>  	if (!hook_path)
>  		return 0;
>  
> -	cp->no_stdin = 1;
>  	strvec_pushv(&cp->env, hook_cb->options->env.v);
> +	/* reopen the file for stdin; run_command closes it. */
> +	if (hook_cb->options->path_to_stdin) {
> +		cp->no_stdin = 0;
> +		cp->in = xopen(hook_cb->options->path_to_stdin, O_RDONLY);
> +	} else {
> +		cp->no_stdin = 1;
> +	}

By the way, using the path_to_stdin as the customization machinery for the API users, and keeping it to the API implementation to actually open the file and stuff .in member with it, is a good way to make sure that multiple processes do not compete for the same standard input stream. IOW, what I was worried about in my review of [2/5] is addressed by this mechanism.

Thanks.
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 11 of 27 in “hook API: support stdin, convert post-rewrite”
  1. 0/5 hook API: support stdin, convert post-rewriteÆvar Arnfjörð Bjarmason, Jan 23, 2023
  2. 1/5 run-command.c: remove dead assignment in while-loopÆvar Arnfjörð Bjarmason, Jan 23, 2023
  3. Junio C HamanoJan 23, 2023
  4. 2/5 run-command: allow stdin for run_processes_parallelÆvar Arnfjörð Bjarmason, Jan 23, 2023
  5. Junio C HamanoJan 23, 2023
  6. 4/5 sequencer: use the new hook API for the simpler "post-rewrite" callÆvar Arnfjörð Bjarmason, Jan 23, 2023
  7. Phillip WoodJan 24, 2023
  8. Phillip WoodJan 27, 2023
  9. 3/5 hook API: support passing stdin to hooks, convert am's 'post-rewrite'Ævar Arnfjörð Bjarmason, Jan 23, 2023
  10. Junio C HamanoJan 23, 2023
  11. Junio C HamanoJan 23, 2023
  12. 5/5 hook: support a --to-stdin=<path> option for testingÆvar Arnfjörð Bjarmason, Jan 23, 2023
  13. Junio C HamanoJan 24, 2023
  14. Michael StrawbridgeJan 24, 2023
  15. 0/5 hook API: support stdin, convert post-rewriteÆvar Arnfjörð Bjarmason, Feb 8, 2023
  16. 1/5 run-command.c: remove dead assignment in while-loopÆvar Arnfjörð Bjarmason, Feb 8, 2023
  17. Junio C HamanoFeb 8, 2023
  18. 2/5 run-command: allow stdin for run_processes_parallelÆvar Arnfjörð Bjarmason, Feb 8, 2023
  19. Junio C HamanoFeb 8, 2023
  20. 3/5 hook API: support passing stdin to hooks, convert am's 'post-rewrite'Ævar Arnfjörð Bjarmason, Feb 8, 2023
  21. Junio C HamanoFeb 8, 2023
  22. 5/5 hook: support a --to-stdin=<path> optionÆvar Arnfjörð Bjarmason, Feb 8, 2023
  23. Junio C HamanoFeb 8, 2023
  24. Ævar Arnfjörð BjarmasonFeb 9, 2023
  25. 4/5 sequencer: use the new hook API for the simpler "post-rewrite" callÆvar Arnfjörð Bjarmason, Feb 8, 2023
  26. Junio C HamanoFeb 8, 2023
  27. Junio C HamanoFeb 8, 2023

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.