]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: display an error if --root and --fork-point are both provided
authorElijah Newren <newren@gmail.com>
Mon, 27 Apr 2020 17:59:49 +0000 (17:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Apr 2020 18:51:26 +0000 (11:51 -0700)
--root implies we want to rebase all commits since the beginning of
history.  --fork-point means we want to use the reflog of the specified
upstream to find the best common ancestor between <upstream> and
<branch> and only rebase commits since that common ancestor.  These
options are clearly contradictory, so throw an error (instead of
segfaulting on a NULL pointer) if both are specified.

Reported-by: Alexander Berg <alexander.berg@atos.net>
Documentation-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-rebase.txt
builtin/rebase.c

index f7a6033607fa558dfd5a0437d7b4327ff1c44c78..fbad356c68e8f2f43035857c09f52388ea5ebf0c 100644 (file)
@@ -414,12 +414,14 @@ When --fork-point is active, 'fork_point' will be used instead of
 <branch>` command (see linkgit:git-merge-base[1]).  If 'fork_point'
 ends up being empty, the <upstream> will be used as a fallback.
 +
-If either <upstream> or --root is given on the command line, then the
-default is `--no-fork-point`, otherwise the default is `--fork-point`.
+If <upstream> is given on the command line, then the default is
+`--no-fork-point`, otherwise the default is `--fork-point`.
 +
 If your branch was based on <upstream> but <upstream> was rewound and
 your branch contains commits which were dropped, this option can be used
 with `--keep-base` in order to drop those commits from your branch.
++
+See also INCOMPATIBLE OPTIONS below.
 
 --ignore-whitespace::
 --whitespace=<option>::
@@ -600,6 +602,7 @@ In addition, the following pairs of options are incompatible:
  * --preserve-merges and --empty=
  * --keep-base and --onto
  * --keep-base and --root
+ * --fork-point and --root
 
 BEHAVIORAL DIFFERENCES
 -----------------------
index bff53d5d167e8501d7f501046ddb35daf0f2cd17..287ac1aa21b54fc2f688166e54f7d581f818dcd6 100644 (file)
@@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                        die(_("cannot combine '--keep-base' with '--root'"));
        }
 
+       if (options.root && fork_point > 0)
+               die(_("cannot combine '--root' with '--fork-point'"));
+
        if (action != ACTION_NONE && !in_progress)
                die(_("No rebase in progress?"));
        setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0);