]> Kevux Git Server - rit/commit
trailer: append trailers without fork/exec
authorLi Chen <me@linux.beauty>
Fri, 6 Mar 2026 14:53:30 +0000 (14:53 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Mar 2026 21:02:20 +0000 (13:02 -0800)
commit6b2243fdd45f0596fc640823faaa6a1aec05a420
tree4d47d1fc329104be346d3eff07ffed1265ff0212
parenta4fd4c523444f6b7d11b7af4dc6d790ac4fd8ec5
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>
builtin/commit.c
builtin/tag.c
trailer.c
trailer.h