Subject: [PATCH v5 04/29] trailer: move config_head and arg_head to if storage

From: Li Chen <[email-masked]>
Date: Wed, 22 Oct 2025 13:39:24 +0800

From: Li Chen <[email-masked]>

Move LIST_HEAD(config_head) and LIST_HEAD(arg_head) into the
non-only_input branch so they are created only when needed.
No functional change.

Signed-off-by: Li Chen <[email-masked]>
---
 trailer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/trailer.c b/trailer.c
index b7b0029e05..9abb5a522a 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1265,14 +1265,15 @@ int trailer_process(const struct process_trailer_options *opts,
 {
 	struct trailer_block *blk;
 	LIST_HEAD(orig_head);
-	LIST_HEAD(config_head);
-	LIST_HEAD(arg_head);
 	struct strbuf trailers_sb = STRBUF_INIT;
 	int had_trailer_before;
 
 	blk = parse_trailers(opts, msg, &orig_head);
 	had_trailer_before = !list_empty(&orig_head);
 	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);
-- 
2.51.0