Skip to content

Commit a35413c

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Documentation-by: Alban Gruin <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit a35413c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Documentation/git-rebase.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,14 @@ When --fork-point is active, 'fork_point' will be used instead of
414414
<branch>` command (see linkgit:git-merge-base[1]). If 'fork_point'
415415
ends up being empty, the <upstream> will be used as a fallback.
416416
+
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`.
419419
+
420420
If your branch was based on <upstream> but <upstream> was rewound and
421421
your branch contains commits which were dropped, this option can be used
422422
with `--keep-base` in order to drop those commits from your branch.
423+
+
424+
See also INCOMPATIBLE OPTIONS below.
423425

424426
--ignore-whitespace::
425427
--whitespace=<option>::
@@ -600,6 +602,7 @@ In addition, the following pairs of options are incompatible:
600602
* --preserve-merges and --empty=
601603
* --keep-base and --onto
602604
* --keep-base and --root
605+
* --fork-point and --root
603606

604607
BEHAVIORAL DIFFERENCES
605608
-----------------------

builtin/rebase.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
16521652
die(_("cannot combine '--keep-base' with '--root'"));
16531653
}
16541654

1655+
if (options.root && fork_point > 0)
1656+
die(_("cannot combine '--root' with '--fork-point'"));
1657+
16551658
if (action != ACTION_NONE && !in_progress)
16561659
die(_("No rebase in progress?"));
16571660
setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0);

0 commit comments

Comments
 (0)