aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/rebase.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2023-01-25 04:03:46 +0000
committerJunio C Hamano <gitster@pobox.com>2023-01-25 09:20:52 -0800
commit7d718c552b8fa084f2d5bb9c3e3872cfe558a1eb (patch)
tree198b39c671fb8b90e391409ba980d0720f15a77a /builtin/rebase.c
parent1207599e839bd9311ec506d82cd507e820767e9b (diff)
downloadgit-7d718c552b8fa084f2d5bb9c3e3872cfe558a1eb.tar.gz
rebase: flag --apply and --merge as incompatible
Previously, we flagged options which implied --apply as being incompatible with options which implied --merge. But if both options were given explicitly, then we didn't flag the incompatibility. The same is true with --apply and --interactive. Add the check, and add some testcases to verify these are also caught. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index c111b89e13..b742cc8fb5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -907,6 +907,9 @@ static int parse_opt_am(const struct option *opt, const char *arg, int unset)
BUG_ON_OPT_NEG(unset);
BUG_ON_OPT_ARG(arg);
+ if (opts->type != REBASE_UNSPECIFIED && opts->type != REBASE_APPLY)
+ die(_("apply options and merge options cannot be used together"));
+
opts->type = REBASE_APPLY;
return 0;
@@ -920,8 +923,10 @@ static int parse_opt_merge(const struct option *opt, const char *arg, int unset)
BUG_ON_OPT_NEG(unset);
BUG_ON_OPT_ARG(arg);
- if (!is_merge(opts))
- opts->type = REBASE_MERGE;
+ if (opts->type != REBASE_UNSPECIFIED && opts->type != REBASE_MERGE)
+ die(_("apply options and merge options cannot be used together"));
+
+ opts->type = REBASE_MERGE;
return 0;
}
@@ -935,6 +940,9 @@ static int parse_opt_interactive(const struct option *opt, const char *arg,
BUG_ON_OPT_NEG(unset);
BUG_ON_OPT_ARG(arg);
+ if (opts->type != REBASE_UNSPECIFIED && opts->type != REBASE_MERGE)
+ die(_("apply options and merge options cannot be used together"));
+
opts->type = REBASE_MERGE;
opts->flags |= REBASE_INTERACTIVE_EXPLICIT;