summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Pratik Karki <predatoramigo@gmail.com>2018-08-08 21:21:35 +0545
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-10-11 14:16:05 +0900
commitb361bd754d141ef1010286dbe5fe810992a498a0 (patch)
treede51260d3fc5a6100fd784dc008ff26c4a1ffe2b /builtin
parentbuiltin rebase: use no-op editor when interactive is "implied" (diff)
downloadtgif-b361bd754d141ef1010286dbe5fe810992a498a0.tar.xz
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rebase.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 36d311b42f..d3d1d39bfa 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -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;