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

Re: [PATCH 4/5] sequencer: use the new hook API for the simpler "post-rewrite" call

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jan 24, 2023, 14:46 UTC
Message-ID
<a2810f20-c093-ba73-0fed-5d179e3e954b@dunelm.org.uk>
In-Reply-To
<patch-4.5-7a55c95f60f-20230123T170551Z-avarab@gmail.com>
Hi Ævar
On 23/01/2023 17:15, Ævar Arnfjörð Bjarmason wrote:
Show 10 quoted lines
> From: Emily Shaffer <emilyshaffer@google.com>
> 
> Change the invocation of the "post-rewrite" hook added in
> 795160457db (sequencer (rebase -i): run the post-rewrite hook, if
> needed, 2017-01-02) to use the new hook API.
> 
> This leaves the more complex "post-rewrite" invocation added in
> a87a6f3c98e (commit: move post-rewrite code to libgit, 2017-11-17)
> here in sequencer.c unconverted. That'll be done in a subsequent
> commit.

As a reader I'd find it more helpful to explain why the conversion isn't done here rather than leaving be to run "git show" to figure it out. If you re-roll perhaps we could replace the commit citation with something like

sequencer.c also contains an invocation of the "post-rewrite" hook in run_rewrite_hook() that is not converted as the hook API does not allow us to pass the hook input as a string yet.

Best Wishes
Phillip
Show 42 quoted lines
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>   sequencer.c | 18 ++++--------------
>   1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/sequencer.c b/sequencer.c
> index 3e4a1972897..d8d59d05dd4 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -4834,8 +4834,7 @@ static int pick_commits(struct repository *r,
>   		if (!stat(rebase_path_rewritten_list(), &st) &&
>   				st.st_size > 0) {
>   			struct child_process child = CHILD_PROCESS_INIT;
> -			const char *post_rewrite_hook =
> -				find_hook("post-rewrite");
> +			struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT;
>   
>   			child.in = open(rebase_path_rewritten_list(), O_RDONLY);
>   			child.git_cmd = 1;
> @@ -4845,18 +4844,9 @@ static int pick_commits(struct repository *r,
>   			/* we don't care if this copying failed */
>   			run_command(&child);
>   
> -			if (post_rewrite_hook) {
> -				struct child_process hook = CHILD_PROCESS_INIT;
> -
> -				hook.in = open(rebase_path_rewritten_list(),
> -					O_RDONLY);
> -				hook.stdout_to_stderr = 1;
> -				hook.trace2_hook_name = "post-rewrite";
> -				strvec_push(&hook.args, post_rewrite_hook);
> -				strvec_push(&hook.args, "rebase");
> -				/* we don't care if this hook failed */
> -				run_command(&hook);
> -			}
> +			hook_opt.path_to_stdin = rebase_path_rewritten_list();
> +			strvec_push(&hook_opt.args, "rebase");
> +			run_hooks_opt("post-rewrite", &hook_opt);
>   		}
>   		apply_autostash(rebase_path_autostash());
>   
Previous: Ævar Arnfjörð BjarmasonNext: Phillip Wood
Message 7 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.