mirror of
https://github.com/git/git.git
synced 2024-11-24 18:33:43 +08:00
builtin rebase: error out on incompatible option/mode combinations
While working on the GSoC project to convert the rebase command to a builtin, the rebase command learned to error out on certain command-line option combinations that cannot work, such as --whitespace=fix with --interactive. This commit converts that code. Signed-off-by: Pratik Karki <predatoramigo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3dba9d0884
commit
b361bd754d
@ -1099,6 +1099,28 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
break;
|
||||
}
|
||||
|
||||
if (options.git_am_opt.len) {
|
||||
const char *p;
|
||||
|
||||
/* all am options except -q are compatible only with --am */
|
||||
strbuf_reset(&buf);
|
||||
strbuf_addbuf(&buf, &options.git_am_opt);
|
||||
strbuf_addch(&buf, ' ');
|
||||
while ((p = strstr(buf.buf, " -q ")))
|
||||
strbuf_splice(&buf, p - buf.buf, 4, " ", 1);
|
||||
strbuf_trim(&buf);
|
||||
|
||||
if (is_interactive(&options) && buf.len)
|
||||
die(_("error: cannot combine interactive options "
|
||||
"(--interactive, --exec, --rebase-merges, "
|
||||
"--preserve-merges, --keep-empty, --root + "
|
||||
"--onto) with am options (%s)"), buf.buf);
|
||||
if (options.type == REBASE_MERGE && buf.len)
|
||||
die(_("error: cannot combine merge options (--merge, "
|
||||
"--strategy, --strategy-option) with am options "
|
||||
"(%s)"), buf.buf);
|
||||
}
|
||||
|
||||
if (options.signoff) {
|
||||
if (options.type == REBASE_PRESERVE_MERGES)
|
||||
die("cannot combine '--signoff' with "
|
||||
@ -1107,6 +1129,25 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
options.flags |= REBASE_FORCE;
|
||||
}
|
||||
|
||||
if (options.type == REBASE_PRESERVE_MERGES)
|
||||
/*
|
||||
* Note: incompatibility with --signoff handled in signoff block above
|
||||
* Note: incompatibility with --interactive is just a strong warning;
|
||||
* git-rebase.txt caveats with "unless you know what you are doing"
|
||||
*/
|
||||
if (options.rebase_merges)
|
||||
die(_("error: cannot combine '--preserve_merges' with "
|
||||
"'--rebase-merges'"));
|
||||
|
||||
if (options.rebase_merges) {
|
||||
if (strategy_options.nr)
|
||||
die(_("error: cannot combine '--rebase_merges' with "
|
||||
"'--strategy-option'"));
|
||||
if (options.strategy)
|
||||
die(_("error: cannot combine '--rebase_merges' with "
|
||||
"'--strategy'"));
|
||||
}
|
||||
|
||||
if (!options.root) {
|
||||
if (argc < 1) {
|
||||
struct branch *branch;
|
||||
|
Loading…
Reference in New Issue
Block a user