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

Re: [PATCH v7 2/5] trailer: move process_trailers to trailer.h

From
Pphillip.wood123@gmail.com <phillip.wood123@gmail.com>
Date
Mar 2, 2026, 14:56 UTC
Message-ID
<db8eda43-5b2b-41eb-91bf-1b5b4da817de@gmail.com>
In-Reply-To
<20260224070552.148591-3-me@linux.beauty>
On 24/02/2026 07:05, Li Chen wrote:
> Move process_trailers() from builtin/interpret-trailers.c into trailer.c
> and expose it via trailer.h.
> 
> This lets other call sites reuse the same trailer rewriting logic.
This looks good, thanks
Phillip
Show 113 quoted lines
> Signed-off-by: Li Chen <me@linux.beauty>
> ---
> v7:
> Rename the input parameter from sb to input.
> 
>   builtin/interpret-trailers.c | 36 ------------------------------------
>   trailer.c                    | 36 ++++++++++++++++++++++++++++++++++++
>   trailer.h                    |  3 +++
>   3 files changed, 39 insertions(+), 36 deletions(-)
> 
> diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
> index 69f9d67ec0..1354109e0f 100644
> --- a/builtin/interpret-trailers.c
> +++ b/builtin/interpret-trailers.c
> @@ -136,42 +136,6 @@ static void read_input_file(struct strbuf *sb, const char *file)
>   	strbuf_complete_line(sb);
>   }
>   
> -static void process_trailers(const struct process_trailer_options *opts,
> -			     struct list_head *new_trailer_head,
> -			     struct strbuf *input, struct strbuf *out)
> -{
> -	LIST_HEAD(head);
> -	struct trailer_block *trailer_block;
> -
> -	trailer_block = parse_trailers(opts, input->buf, &head);
> -
> -	/* Print the lines before the trailer block */
> -	if (!opts->only_trailers)
> -		strbuf_add(out, input->buf, trailer_block_start(trailer_block));
> -
> -	if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
> -		strbuf_addch(out, '\n');
> -
> -	if (!opts->only_input) {
> -		LIST_HEAD(config_head);
> -		LIST_HEAD(arg_head);
> -		parse_trailers_from_config(&config_head);
> -		parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
> -		list_splice(&config_head, &arg_head);
> -		process_trailers_lists(&head, &arg_head);
> -	}
> -
> -	/* Print trailer block. */
> -	format_trailers(opts, &head, out);
> -	free_trailers(&head);
> -
> -	/* Print the lines after the trailer block as is. */
> -	if (!opts->only_trailers)
> -		strbuf_add(out, input->buf + trailer_block_end(trailer_block),
> -			   input->len - trailer_block_end(trailer_block));
> -	trailer_block_release(trailer_block);
> -}
> -
>   static void interpret_trailers(const struct process_trailer_options *opts,
>   			       struct list_head *new_trailer_head,
>   			       const char *file)
> diff --git a/trailer.c b/trailer.c
> index 911a81ed99..0c9200506d 100644
> --- a/trailer.c
> +++ b/trailer.c
> @@ -1235,3 +1235,39 @@ int amend_file_with_trailers(const char *path, const struct strvec *trailer_args
>   	strvec_pushv(&run_trailer.args, trailer_args->v);
>   	return run_command(&run_trailer);
>   }
> +
> +void process_trailers(const struct process_trailer_options *opts,
> +		      struct list_head *new_trailer_head,
> +		      struct strbuf *input, struct strbuf *out)
> +{
> +	LIST_HEAD(head);
> +	struct trailer_block *trailer_block;
> +
> +	trailer_block = parse_trailers(opts, input->buf, &head);
> +
> +	/* Print the lines before the trailer block */
> +	if (!opts->only_trailers)
> +		strbuf_add(out, input->buf, trailer_block_start(trailer_block));
> +
> +	if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
> +		strbuf_addch(out, '\n');
> +
> +	if (!opts->only_input) {
> +		LIST_HEAD(config_head);
> +		LIST_HEAD(arg_head);
> +		parse_trailers_from_config(&config_head);
> +		parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
> +		list_splice(&config_head, &arg_head);
> +		process_trailers_lists(&head, &arg_head);
> +	}
> +
> +	/* Print trailer block. */
> +	format_trailers(opts, &head, out);
> +	free_trailers(&head);
> +
> +	/* Print the lines after the trailer block as is. */
> +	if (!opts->only_trailers)
> +		strbuf_add(out, input->buf + trailer_block_end(trailer_block),
> +			   input->len - trailer_block_end(trailer_block));
> +	trailer_block_release(trailer_block);
> +}
> diff --git a/trailer.h b/trailer.h
> index 4740549586..531fa1a13f 100644
> --- a/trailer.h
> +++ b/trailer.h
> @@ -202,4 +202,7 @@ void trailer_iterator_release(struct trailer_iterator *iter);
>    */
>   int amend_file_with_trailers(const char *path, const struct strvec *trailer_args);
>   
> +void process_trailers(const struct process_trailer_options *opts,
> +		      struct list_head *new_trailer_head,
> +		      struct strbuf *input, struct strbuf *out);
>   #endif /* TRAILER_H */
Previous: Li ChenNext: Li Chen
Message 6 of 32 in “rebase: support --trailer”
  1. 0/5 rebase: support --trailerLi Chen, Feb 24, 2026
  2. 1/5 interpret-trailers: factor trailer rewritingLi Chen, Feb 24, 2026
  3. Phillip WoodMar 2, 2026
  4. Li ChenMar 2, 2026
  5. 2/5 trailer: move process_trailers to trailer.hLi Chen, Feb 24, 2026
  6. phillip.wood123@gmail.comMar 2, 2026
  7. 3/5 trailer: append trailers without fork/execLi Chen, Feb 24, 2026
  8. Phillip WoodMar 2, 2026
  9. 4/5 commit, tag: parse --trailer with OPT_STRVECLi Chen, Feb 24, 2026
  10. Phillip WoodMar 2, 2026
  11. 5/5 rebase: support --trailerLi Chen, Feb 24, 2026
  12. Phillip WoodMar 3, 2026
  13. Kristoffer HaugsbakkMar 3, 2026
  14. Junio C HamanoMar 3, 2026
  15. Phillip WoodMar 4, 2026
  16. Junio C HamanoMar 4, 2026
  17. Junio C HamanoFeb 26, 2026
  18. Phillip WoodFeb 26, 2026
  19. Kristoffer HaugsbakkFeb 26, 2026
  20. Phillip WoodMar 4, 2026
  21. Li ChenMar 5, 2026
  22. Phillip WoodMar 6, 2026
  23. 0/6 rebase: support --trailerPhillip Wood, Mar 6, 2026
  24. 1/6 interpret-trailers: factor trailer rewritingPhillip Wood, Mar 6, 2026
  25. Junio C HamanoMar 6, 2026
  26. Phillip WoodMar 9, 2026
  27. 2/6 interpret-trailers: refactor create_in_place_tempfile()Phillip Wood, Mar 6, 2026
  28. Junio C HamanoMar 6, 2026
  29. 3/6 trailer: libify a couple of functionsPhillip Wood, Mar 6, 2026
  30. 4/6 trailer: append trailers without fork/execPhillip Wood, Mar 6, 2026
  31. 5/6 commit, tag: parse --trailer with OPT_STRVECPhillip Wood, Mar 6, 2026
  32. 6/6 rebase: support --trailerPhillip Wood, Mar 6, 2026

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.