From: Pratik Karki <predatoramigo@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, Johannes.Schindelin@gmx.de,
sbeller@google.com, alban.gruin@gmail.com, gitster@pobox.com,
Pratik Karki <predatoramigo@gmail.com>
Subject: [PATCH 6/6] builtin rebase: error out on incompatible option/mode combinations
Date: Wed, 8 Aug 2018 21:21:35 +0545 [thread overview]
Message-ID: <20180808153635.19944-7-predatoramigo@gmail.com> (raw)
In-Reply-To: <20180808153635.19944-1-predatoramigo@gmail.com>
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>
---
builtin/rebase.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index fb8ab5a177..4e69458161 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1098,6 +1098,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 "
@@ -1106,6 +1128,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;
--
2.18.0
prev parent reply other threads:[~2018-08-08 15:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-08 15:36 [GSoC] [PATCH 0/6] builtin rebase rest Pratik Karki
2018-08-08 15:36 ` [PATCH 1/6] builtin rebase: optionally auto-detect the upstream Pratik Karki
2018-08-08 15:36 ` [PATCH 2/6] builtin rebase: optionally pass custom reflogs to reset_head() Pratik Karki
2018-08-08 15:36 ` [PATCH 3/6] builtin rebase: fast-forward to onto if it is a proper descendant Pratik Karki
2018-08-08 15:36 ` [PATCH 4/6] builtin rebase: show progress when connected to a terminal Pratik Karki
2018-08-08 15:36 ` [PATCH 5/6] builtin rebase: use no-op editor when interactive is "implied" Pratik Karki
2018-08-08 15:36 ` Pratik Karki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180808153635.19944-7-predatoramigo@gmail.com \
--to=predatoramigo@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=alban.gruin@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).