diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-19 09:54:56 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-19 09:54:56 -0700 |
| commit | accd0e107bb36cbcdb158f8bb19d5bae589294a9 (patch) | |
| tree | 9c127dab3844830d92aaf884a0f1037d11d5a3c3 /builtin/rebase.c | |
| parent | a7a079c2c4bc7b269229a6ea6c147b6b2d5b2684 (diff) | |
| parent | e4f9d6b0ab2e1903765258991a6265599d0007ce (diff) | |
| download | git-accd0e107bb36cbcdb158f8bb19d5bae589294a9.tar.xz | |
Merge branch 'lc/rebase-trailer'
"git rebase" learns "--trailer" command to drive the
interpret-trailers machinery.
* lc/rebase-trailer:
rebase: support --trailer
commit, tag: parse --trailer with OPT_STRVEC
trailer: append trailers without fork/exec
trailer: libify a couple of functions
interpret-trailers: refactor create_in_place_tempfile()
interpret-trailers: factor trailer rewriting
Diffstat (limited to 'builtin/rebase.c')
| -rw-r--r-- | builtin/rebase.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c index 8c1316db38..a1c7d78196 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -36,6 +36,7 @@ #include "reset.h" #include "trace2.h" #include "hook.h" +#include "trailer.h" static char const * const builtin_rebase_usage[] = { N_("git rebase [-i] [options] [--exec <cmd>] " @@ -113,6 +114,7 @@ struct rebase_options { enum action action; char *reflog_action; int signoff; + struct strvec trailer_args; int allow_rerere_autoupdate; int keep_empty; int autosquash; @@ -143,6 +145,7 @@ struct rebase_options { .flags = REBASE_NO_QUIET, \ .git_am_opts = STRVEC_INIT, \ .exec = STRING_LIST_INIT_NODUP, \ + .trailer_args = STRVEC_INIT, \ .git_format_patch_opt = STRBUF_INIT, \ .fork_point = -1, \ .reapply_cherry_picks = -1, \ @@ -166,6 +169,7 @@ static void rebase_options_release(struct rebase_options *opts) free(opts->strategy); string_list_clear(&opts->strategy_opts, 0); strbuf_release(&opts->git_format_patch_opt); + strvec_clear(&opts->trailer_args); } static struct replay_opts get_replay_opts(const struct rebase_options *opts) @@ -177,6 +181,10 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts) sequencer_init_config(&replay); replay.signoff = opts->signoff; + + for (size_t i = 0; i < opts->trailer_args.nr; i++) + strvec_push(&replay.trailer_args, opts->trailer_args.v[i]); + replay.allow_ff = !(opts->flags & REBASE_FORCE); if (opts->allow_rerere_autoupdate) replay.allow_rerere_auto = opts->allow_rerere_autoupdate; @@ -1134,6 +1142,8 @@ int cmd_rebase(int argc, .flags = PARSE_OPT_NOARG, .defval = REBASE_DIFFSTAT, }, + OPT_STRVEC(0, "trailer", &options.trailer_args, N_("trailer"), + N_("add custom trailer(s)")), OPT_BOOL(0, "signoff", &options.signoff, N_("add a Signed-off-by trailer to each commit")), OPT_BOOL(0, "committer-date-is-author-date", @@ -1287,6 +1297,12 @@ int cmd_rebase(int argc, builtin_rebase_options, builtin_rebase_usage, 0); + if (options.trailer_args.nr) { + if (validate_trailer_args(&options.trailer_args)) + die(NULL); + options.flags |= REBASE_FORCE; + } + if (preserve_merges_selected) die(_("--preserve-merges was replaced by --rebase-merges\n" "Note: Your `pull.rebase` configuration may also be set to 'preserve',\n" @@ -1544,6 +1560,9 @@ int cmd_rebase(int argc, if (options.root && !options.onto_name) imply_merge(&options, "--root without --onto"); + if (options.trailer_args.nr) + imply_merge(&options, "--trailer"); + if (isatty(2) && options.flags & REBASE_NO_QUIET) strbuf_addstr(&options.git_format_patch_opt, " --progress"); |
