[PATCH v4 14/29] rebase: die on invalid trailer args
- From
Li Chen <me@linux.beauty>
- Date
- Oct 14, 2025, 12:24 UTC
- Message-ID
- <20251014122452.1851103-15-me@linux.beauty>
- In-Reply-To
- <20251014122452.1851103-1-me@linux.beauty>
This can simplify the error handle in validate_trailer_args_after_config and its caller.
Signed-off-by: Li Chen <chenl311@chinatelecom.cn> --- builtin/rebase.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c index cc90980d7d..872945a897 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1124,29 +1124,22 @@ static int check_exec_cmd(const char *cmd) return 0; } -static int validate_trailer_args_after_config(const struct strvec *cli_args, - struct strbuf *err) +static void validate_trailer_args_after_config(const struct strvec *cli_args) { for (size_t i = 0; i < cli_args->nr; i++) { const char *txt = cli_args->v[i]; // Key[:=]Val const char *sep; - if (!*txt) { - strbuf_addstr(err, _("empty --trailer argument")); - return -1; - } + if (!*txt) + die(_("empty --trailer argument")); sep = strpbrk(txt, ":="); /* there must be key bfore seperator */ - if (sep && sep == txt) { - strbuf_addf(err, - _("invalid trailer '%s': missing key before separator"), - txt); - return -1; - } + if (sep && sep == txt) + die(_("invalid trailer '%s': missing key before separator"), + txt); } - return 0; } int cmd_rebase(int argc, @@ -1353,13 +1346,8 @@ int cmd_rebase(int argc, builtin_rebase_usage, 0); if (options.trailer_args.nr) { - struct strbuf err = STRBUF_INIT; - - if (validate_trailer_args_after_config(&options.trailer_args, &err)) - die("%s", err.buf); - + validate_trailer_args_after_config(&options.trailer_args); options.flags |= REBASE_FORCE; - strbuf_release(&err); } if (preserve_merges_selected)
-- 2.51.0