Skip to content

Commit 73d51ed

Browse files
prertikgitster
authored andcommitted
builtin rebase: support --signoff
This commit adds support for `--signoff` which is used to add a `Signed-off-by` trailer to all the rebased commits. The actual handling is left to the rebase backends. Signed-off-by: Pratik Karki <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 361badd commit 73d51ed

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

builtin/rebase.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct rebase_options {
9393
} flags;
9494
struct strbuf git_am_opt;
9595
const char *action;
96+
int signoff;
9697
};
9798

9899
static int is_interactive(struct rebase_options *opts)
@@ -168,6 +169,11 @@ static int read_basic_state(struct rebase_options *opts)
168169
if (file_exists(state_dir_path("verbose", opts)))
169170
opts->flags |= REBASE_VERBOSE;
170171

172+
if (file_exists(state_dir_path("signoff", opts))) {
173+
opts->signoff = 1;
174+
opts->flags |= REBASE_FORCE;
175+
}
176+
171177
strbuf_release(&buf);
172178

173179
return 0;
@@ -249,6 +255,7 @@ static int run_specific_rebase(struct rebase_options *opts)
249255
if (opts->switch_to)
250256
add_var(&script_snippet, "switch_to", opts->switch_to);
251257
add_var(&script_snippet, "action", opts->action ? opts->action : "");
258+
add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
252259

253260
switch (opts->type) {
254261
case REBASE_AM:
@@ -513,6 +520,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
513520
{OPTION_NEGBIT, 'n', "no-stat", &options.flags, NULL,
514521
N_("do not show diffstat of what changed upstream"),
515522
PARSE_OPT_NOARG, NULL, REBASE_DIFFSTAT },
523+
OPT_BOOL(0, "signoff", &options.signoff,
524+
N_("add a Signed-off-by: line to each commit")),
516525
OPT_BIT('f', "force-rebase", &options.flags,
517526
N_("cherry-pick all commits, even if unchanged"),
518527
REBASE_FORCE),
@@ -745,6 +754,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
745754
break;
746755
}
747756

757+
if (options.signoff) {
758+
if (options.type == REBASE_PRESERVE_MERGES)
759+
die("cannot combine '--signoff' with "
760+
"'--preserve-merges'");
761+
strbuf_addstr(&options.git_am_opt, " --signoff");
762+
options.flags |= REBASE_FORCE;
763+
}
764+
748765
if (!options.root) {
749766
if (argc < 1)
750767
die("TODO: handle @{upstream}");

0 commit comments

Comments
 (0)