diff options
| author | Li Chen <me@linux.beauty> | 2026-03-06 14:53:31 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-06 13:02:20 -0800 |
| commit | 5e148696bf86f0173dfc91571d15ba833ec19ccd (patch) | |
| tree | 63c53c41184137472ef8fe360a14f66100552e61 /trailer.c | |
| parent | 6b2243fdd45f0596fc640823faaa6a1aec05a420 (diff) | |
| download | git-5e148696bf86f0173dfc91571d15ba833ec19ccd.tar.xz | |
commit, tag: parse --trailer with OPT_STRVEC
Now that amend_file_with_trailers() expects raw trailer lines, do not
store argv-style "--trailer=<trailer>" strings in git commit and git
tag.
Parse --trailer using OPT_STRVEC so trailer_args contains only the
trailer value, and drop the temporary prefix stripping in
amend_file_with_trailers().
Signed-off-by: Li Chen <me@linux.beauty>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.c')
| -rw-r--r-- | trailer.c | 25 |
1 files changed, 2 insertions, 23 deletions
@@ -1341,46 +1341,25 @@ int amend_file_with_trailers(const char *path, const struct strvec *trailer_args) { struct strbuf buf = STRBUF_INIT; - struct strvec stripped_trailer_args = STRVEC_INIT; int ret = 0; - size_t i; if (!trailer_args) BUG("amend_file_with_trailers called with NULL trailer_args"); if (!trailer_args->nr) return 0; - for (i = 0; i < trailer_args->nr; i++) { - const char *txt = trailer_args->v[i]; - - /* - * Historically amend_file_with_trailers() passed its arguments - * to "git interpret-trailers", which expected argv entries in - * "--trailer=<trailer>" form. Continue to accept those for - * existing callers, but pass only the value portion to the - * in-process implementation. - */ - skip_prefix(txt, "--trailer=", &txt); - if (!*txt) { - ret = error(_("empty --trailer argument")); - goto out; - } - strvec_push(&stripped_trailer_args, txt); - } - - if (validate_trailer_args(&stripped_trailer_args)) { + if (validate_trailer_args(trailer_args)) { ret = -1; goto out; } if (strbuf_read_file(&buf, path, 0) < 0) ret = error_errno(_("could not read '%s'"), path); else - amend_strbuf_with_trailers(&buf, &stripped_trailer_args); + amend_strbuf_with_trailers(&buf, trailer_args); if (!ret) ret = write_file_in_place(path, &buf); out: - strvec_clear(&stripped_trailer_args); strbuf_release(&buf); return ret; } |
