Skip to content

Commit b64b7fe

Browse files
arachsysgitster
authored andcommitted
Add tests for rebase -i --root without --onto
Test for likely breakages in t3404, including successful reordering of non-conflicting changes with a new root, correct preservation of commit message and author in a root commit when it is squashed with the sentinel, and presence of the sentinel following a conflicting cherry-pick of a new root. Remove test_must_fail for git rebase --root without --onto from t3412 as this case will now be successfully handled by an implicit git rebase -i. Signed-off-by: Chris Webb <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent df5df20 commit b64b7fe

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

t/t3404-rebase-interactive.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,4 +755,31 @@ test_expect_success 'rebase-i history with funny messages' '
755755
test_cmp expect actual
756756
'
757757

758+
test_expect_success 'rebase -i --root re-order and drop commits' '
759+
git checkout E &&
760+
FAKE_LINES="3 1 2 5" git rebase -i --root &&
761+
test E = $(git cat-file commit HEAD | sed -ne \$p) &&
762+
test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
763+
test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
764+
test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
765+
test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
766+
'
767+
768+
test_expect_success 'rebase -i --root retain root commit author and message' '
769+
git checkout A &&
770+
echo B >file7 &&
771+
git add file7 &&
772+
GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
773+
FAKE_LINES="2" git rebase -i --root &&
774+
git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
775+
git cat-file commit HEAD | grep -q "^different author$"
776+
'
777+
778+
test_expect_success 'rebase -i --root temporary sentinel commit' '
779+
git checkout B &&
780+
FAKE_LINES="2" test_must_fail git rebase -i --root &&
781+
git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
782+
git rebase --abort
783+
'
784+
758785
test_done

t/t3412-rebase-root.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ test_expect_success 'prepare repository' '
2222
test_commit 4 B
2323
'
2424

25-
test_expect_success 'rebase --root expects --onto' '
26-
test_must_fail git rebase --root
27-
'
28-
2925
test_expect_success 'setup pre-rebase hook' '
3026
mkdir -p .git/hooks &&
3127
cat >.git/hooks/pre-rebase <<EOF &&

0 commit comments

Comments
 (0)