rebase: display an error if --root and --fork-point are both provided
--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>
Elijah Newren committed
Apr 27, 2020 at 17:59 UTC
a35413c3785bf71e2c018691d6cd5f93638ba9ae
2 files changed
+8
-2
Documentation/git-rebase.txt
+5
-2
@@ -414,12 +414,14 @@ When --fork-point is active, 'fork_point' will be used instead of
414
<branch>` command (see linkgit:git-merge-base[1]). If 'fork_point'
415
ends up being empty, the <upstream> will be used as a fallback.
416
+
417
-If either <upstream> or --root is given on the command line, then the
418
-default is `--no-fork-point`, otherwise the default is `--fork-point`.
417
+If <upstream> is given on the command line, then the default is
418
+`--no-fork-point`, otherwise the default is `--fork-point`.
419
+
420
If your branch was based on <upstream> but <upstream> was rewound and
421
your branch contains commits which were dropped, this option can be used
422
with `--keep-base` in order to drop those commits from your branch.
423
++
424
+See also INCOMPATIBLE OPTIONS below.
425
426
--ignore-whitespace::
427
--whitespace=<option>::
@@ -600,6 +602,7 @@ In addition, the following pairs of options are incompatible:
602
* --preserve-merges and --empty=
603
* --keep-base and --onto
604
* --keep-base and --root
605
+ * --fork-point and --root
606
607
BEHAVIORAL DIFFERENCES
608
-----------------------
builtin/rebase.c
+3
@@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1652
die(_("cannot combine '--keep-base' with '--root'"));
1653
}
1654
1655
+ if (options.root && fork_point > 0)
1656
+ die(_("cannot combine '--root' with '--fork-point'"));
1657
+
1658
if (action != ACTION_NONE && !in_progress)
1659
die(_("No rebase in progress?"));
1660
setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0);