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 <chris@arachsys.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Chris Webb committed
Jun 26, 2012 at 22:55 UTC
b64b7feb730b7a23c7a473a484ba6e68d410c990
2 files changed
+27
-4
t/t3404-rebase-interactive.sh
+27
@@ -755,4 +755,31 @@ test_expect_success 'rebase-i history with funny messages' '
755
test_cmp expect actual
756
'
757
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
+
785
test_done
t/t3412-rebase-root.sh
-4
@@ -22,10 +22,6 @@ test_expect_success 'prepare repository' '
22
test_commit 4 B
23
'
24
25
-test_expect_success 'rebase --root expects --onto' '
26
- test_must_fail git rebase --root
27
-'
28
-
25
test_expect_success 'setup pre-rebase hook' '
26
mkdir -p .git/hooks &&
27
cat >.git/hooks/pre-rebase <<EOF &&