Skip to content

Commit 9b3a448

Browse files
prertikgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68e46d7 commit 9b3a448

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

builtin/rebase.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct rebase_options {
9494
char *gpg_sign_opt;
9595
int autostash;
9696
char *cmd;
97+
int allow_empty_message;
9798
};
9899

99100
static int is_interactive(struct rebase_options *opts)
@@ -348,6 +349,8 @@ static int run_specific_rebase(struct rebase_options *opts)
348349
add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : "");
349350
add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt);
350351
add_var(&script_snippet, "cmd", opts->cmd);
352+
add_var(&script_snippet, "allow_empty_message",
353+
opts->allow_empty_message ? "--allow-empty-message" : "");
351354

352355
switch (opts->type) {
353356
case REBASE_AM:
@@ -598,6 +601,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
598601
.flags = REBASE_NO_QUIET,
599602
.git_am_opt = STRBUF_INIT,
600603
.allow_rerere_autoupdate = -1,
604+
.allow_empty_message = 1,
601605
};
602606
const char *branch_name;
603607
int ret, flags, total_argc, in_progress = 0;
@@ -698,6 +702,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
698702
OPT_STRING_LIST('x', "exec", &exec, N_("exec"),
699703
N_("add exec lines after each commit of the "
700704
"editable list")),
705+
OPT_BOOL(0, "allow-empty-message",
706+
&options.allow_empty_message,
707+
N_("allow rebasing commits with empty messages")),
701708
OPT_END(),
702709
};
703710

0 commit comments

Comments
 (0)