aboutsummaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorLi Chen <me@linux.beauty>2026-03-06 14:53:30 +0000
committerJunio C Hamano <gitster@pobox.com>2026-03-06 13:02:20 -0800
commit6b2243fdd45f0596fc640823faaa6a1aec05a420 (patch)
tree4d47d1fc329104be346d3eff07ffed1265ff0212 /builtin/commit.c
parenta4fd4c523444f6b7d11b7af4dc6d790ac4fd8ec5 (diff)
downloadgit-6b2243fdd45f0596fc640823faaa6a1aec05a420.tar.xz
trailer: append trailers without fork/exec
Introduce amend_strbuf_with_trailers() to apply trailer additions to a message buffer via process_trailers(), avoiding the need to run git interpret-trailers as a child process. Update amend_file_with_trailers() to use the in-process helper and rewrite the target file via tempfile+rename, preserving the previous in-place semantics. As the trailers are no longer added in a separate process and trailer_config_init() die()s on missing config values it is called early on in cmd_commit() and cmd_tag() so that they die() early before writing the message file. The trailer arguments are now also sanity checked. Keep existing callers unchanged by continuing to accept argv-style --trailer=<trailer> entries and stripping the prefix before feeding the in-process implementation. Signed-off-by: Li Chen <me@linux.beauty> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 9e3a09d532..eb9013995c 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1820,6 +1820,9 @@ int cmd_commit(int argc,
argc = parse_and_validate_options(argc, argv, builtin_commit_options,
builtin_commit_usage,
prefix, current_head, &s);
+ if (trailer_args.nr)
+ trailer_config_init();
+
if (verbose == -1)
verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;