Skip to content

Commit 7e5dcec

Browse files
alexhenriegitster
authored andcommitted
rebase: add documentation and test for --no-rebase-merges
As far as I can tell, --no-rebase-merges has always worked, but has never been documented. It is especially important to document it before a rebase.rebaseMerges option is introduced so that users know how to override the config option on the command line. It's also important to clarify that --rebase-merges without an argument is not the same as --no-rebase-merges and not passing --rebase-merges is not the same as passing --rebase-merges=no-rebase-cousins. A test case is necessary to make sure that --no-rebase-merges keeps working after its code is refactored in the following patches of this series. The test case is a little contrived: It's unlikely that a user would type both --rebase-merges and --no-rebase-merges at the same time. However, if an alias is defined which includes --rebase-merges, the user might decide to add --no-rebase-merges to countermand that part of the alias but leave alone other flags set by the alias. Signed-off-by: Alex Henrie <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e25cabb commit 7e5dcec

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

Documentation/git-rebase.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,20 +529,24 @@ See also INCOMPATIBLE OPTIONS below.
529529

530530
-r::
531531
--rebase-merges[=(rebase-cousins|no-rebase-cousins)]::
532+
--no-rebase-merges::
532533
By default, a rebase will simply drop merge commits from the todo
533534
list, and put the rebased commits into a single, linear branch.
534535
With `--rebase-merges`, the rebase will instead try to preserve
535536
the branching structure within the commits that are to be rebased,
536537
by recreating the merge commits. Any resolved merge conflicts or
537538
manual amendments in these merge commits will have to be
538-
resolved/re-applied manually.
539+
resolved/re-applied manually. `--no-rebase-merges` can be used to
540+
countermand a previous `--rebase-merges`.
539541
+
540-
By default, or when `no-rebase-cousins` was specified, commits which do not
541-
have `<upstream>` as direct ancestor will keep their original branch point,
542-
i.e. commits that would be excluded by linkgit:git-log[1]'s
543-
`--ancestry-path` option will keep their original ancestry by default. If
544-
the `rebase-cousins` mode is turned on, such commits are instead rebased
545-
onto `<upstream>` (or `<onto>`, if specified).
542+
When rebasing merges, there are two modes: `rebase-cousins` and
543+
`no-rebase-cousins`. If the mode is not specified, it defaults to
544+
`no-rebase-cousins`. In `no-rebase-cousins` mode, commits which do not have
545+
`<upstream>` as direct ancestor will keep their original branch point, i.e.
546+
commits that would be excluded by linkgit:git-log[1]'s `--ancestry-path`
547+
option will keep their original ancestry by default. In `rebase-cousins` mode,
548+
such commits are instead rebased onto `<upstream>` (or `<onto>`, if
549+
specified).
546550
+
547551
It is currently only possible to recreate the merge commits using the
548552
`ort` merge strategy; different merge strategies can be used only via

t/t3430-rebase-merges.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ test_expect_success 'with a branch tip that was cherry-picked already' '
250250
EOF
251251
'
252252

253+
test_expect_success '--no-rebase-merges countermands --rebase-merges' '
254+
git checkout -b no-rebase-merges E &&
255+
git rebase --rebase-merges --no-rebase-merges C &&
256+
test_cmp_graph C.. <<-\EOF
257+
* B
258+
* D
259+
o C
260+
EOF
261+
'
262+
253263
test_expect_success 'do not rebase cousins unless asked for' '
254264
git checkout -b cousins main &&
255265
before="$(git rev-parse --verify HEAD)" &&

0 commit comments

Comments
 (0)