builtin rebase: support `--allow-empty-message` option
This commit introduces the `--allow-empty-message` option to `builtin/rebase.c`. The motivation behind this option is: if there are empty messages (which is not allowed in Git by default, but can be imported from different version control systems), the rebase will fail. Using `--allow-empty-message` overrides that behaviour which will allow the commits having empty messages to continue in rebase operation. Note: a very recent change made this the default in the shell scripted `git rebase`, therefore the builtin rebase does the same. 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>
Pratik Karki committed
Sep 4, 2018 at 15:00 UTC
9b3a448b4eee25050dc1e1c14c886e27e2985819
1 file changed
+7
builtin/rebase.c
+7
@@ -94,6 +94,7 @@ struct rebase_options {
94
char *gpg_sign_opt;
95
int autostash;
96
char *cmd;
97
+ int allow_empty_message;
98
};
99
100
static int is_interactive(struct rebase_options *opts)
@@ -348,6 +349,8 @@ static int run_specific_rebase(struct rebase_options *opts)
349
add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : "");
350
add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt);
351
add_var(&script_snippet, "cmd", opts->cmd);
352
+ add_var(&script_snippet, "allow_empty_message",
353
+ opts->allow_empty_message ? "--allow-empty-message" : "");
354
355
switch (opts->type) {
356
case REBASE_AM:
@@ -598,6 +601,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
601
.flags = REBASE_NO_QUIET,
602
.git_am_opt = STRBUF_INIT,
603
.allow_rerere_autoupdate = -1,
604
+ .allow_empty_message = 1,
605
};
606
const char *branch_name;
607
int ret, flags, total_argc, in_progress = 0;
@@ -698,6 +702,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
702
OPT_STRING_LIST('x', "exec", &exec, N_("exec"),
703
N_("add exec lines after each commit of the "
704
"editable list")),
705
+ OPT_BOOL(0, "allow-empty-message",
706
+ &options.allow_empty_message,
707
+ N_("allow rebasing commits with empty messages")),
708
OPT_END(),
709
};
710