Skip to content

Commit a7e664f

Browse files
committed
Merge branch 'jn/document-rebase-i-p-limitation' into maint
* jn/document-rebase-i-p-limitation: rebase -i -p: document shortcomings
2 parents 12575b7 + cddb42d commit a7e664f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Documentation/git-rebase.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details).
310310
-p::
311311
--preserve-merges::
312312
Instead of ignoring merges, try to recreate them.
313+
+
314+
This uses the `--interactive` machinery internally, but combining it
315+
with the `--interactive` option explicitly is generally not a good
316+
idea unless you know what you are doing (see BUGS below).
317+
313318

314319
--root::
315320
Rebase all commits reachable from <branch>, instead of
@@ -611,6 +616,28 @@ The ripple effect of a "hard case" recovery is especially bad:
611616
case" recovery too!
612617

613618

619+
BUGS
620+
----
621+
The todo list presented by `--preserve-merges --interactive` does not
622+
represent the topology of the revision graph. Editing commits and
623+
rewording their commit messages should work fine, but attempts to
624+
reorder commits tend to produce counterintuitive results.
625+
626+
For example, an attempt to rearrange
627+
------------
628+
1 --- 2 --- 3 --- 4 --- 5
629+
------------
630+
to
631+
------------
632+
1 --- 2 --- 4 --- 3 --- 5
633+
------------
634+
by moving the "pick 4" line will result in the following history:
635+
------------
636+
3
637+
/
638+
1 --- 2 --- 4 --- 5
639+
------------
640+
614641
Authors
615642
------
616643
Written by Junio C Hamano <[email protected]> and

t/t3404-rebase-interactive.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ test_expect_success '-p handles "no changes" gracefully' '
181181
test $HEAD = $(git rev-parse HEAD)
182182
'
183183

184+
test_expect_failure 'exchange two commits with -p' '
185+
FAKE_LINES="2 1" git rebase -i -p HEAD~2 &&
186+
test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
187+
test G = $(git cat-file commit HEAD | sed -ne \$p)
188+
'
189+
184190
test_expect_success 'preserve merges with -p' '
185191
git checkout -b to-be-preserved master^ &&
186192
: > unrelated-file &&

0 commit comments

Comments
 (0)