summaryrefslogtreecommitdiff
path: root/builtin/rebase.c
diff options
context:
space:
mode:
authorLibravatar Pratik Karki <predatoramigo@gmail.com>2018-09-04 14:59:50 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-09-06 11:56:19 -0700
commit73d51ed0a59f561e55ab1b649eb073e7dddf8b88 (patch)
treee2f6f2bef5ce5bb64b5eab2cdff66ff1a3586065 /builtin/rebase.c
parentbuiltin rebase: allow selecting the rebase "backend" (diff)
downloadtgif-73d51ed0a59f561e55ab1b649eb073e7dddf8b88.tar.xz
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 <predatoramigo@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 61695ac7b9..3c8b29d82c 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -93,6 +93,7 @@ struct rebase_options {
} flags;
struct strbuf git_am_opt;
const char *action;
+ int signoff;
};
static int is_interactive(struct rebase_options *opts)
@@ -168,6 +169,11 @@ static int read_basic_state(struct rebase_options *opts)
if (file_exists(state_dir_path("verbose", opts)))
opts->flags |= REBASE_VERBOSE;
+ if (file_exists(state_dir_path("signoff", opts))) {
+ opts->signoff = 1;
+ opts->flags |= REBASE_FORCE;
+ }
+
strbuf_release(&buf);
return 0;
@@ -249,6 +255,7 @@ static int run_specific_rebase(struct rebase_options *opts)
if (opts->switch_to)
add_var(&script_snippet, "switch_to", opts->switch_to);
add_var(&script_snippet, "action", opts->action ? opts->action : "");
+ add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
switch (opts->type) {
case REBASE_AM:
@@ -513,6 +520,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
{OPTION_NEGBIT, 'n', "no-stat", &options.flags, NULL,
N_("do not show diffstat of what changed upstream"),
PARSE_OPT_NOARG, NULL, REBASE_DIFFSTAT },
+ OPT_BOOL(0, "signoff", &options.signoff,
+ N_("add a Signed-off-by: line to each commit")),
OPT_BIT('f', "force-rebase", &options.flags,
N_("cherry-pick all commits, even if unchanged"),
REBASE_FORCE),
@@ -745,6 +754,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
break;
}
+ if (options.signoff) {
+ if (options.type == REBASE_PRESERVE_MERGES)
+ die("cannot combine '--signoff' with "
+ "'--preserve-merges'");
+ strbuf_addstr(&options.git_am_opt, " --signoff");
+ options.flags |= REBASE_FORCE;
+ }
+
if (!options.root) {
if (argc < 1)
die("TODO: handle @{upstream}");