Skip to content

Commit

Permalink
Add tests for rebase -i --root without --onto
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chris Webb authored and Junio C Hamano committed Jun 26, 2012
1 parent df5df20 commit b64b7fe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 27 additions & 0 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -755,4 +755,31 @@ test_expect_success 'rebase-i history with funny messages' '
test_cmp expect actual
'

test_expect_success 'rebase -i --root re-order and drop commits' '
git checkout E &&
FAKE_LINES="3 1 2 5" git rebase -i --root &&
test E = $(git cat-file commit HEAD | sed -ne \$p) &&
test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
'

test_expect_success 'rebase -i --root retain root commit author and message' '
git checkout A &&
echo B >file7 &&
git add file7 &&
GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
FAKE_LINES="2" git rebase -i --root &&
git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
git cat-file commit HEAD | grep -q "^different author$"
'

test_expect_success 'rebase -i --root temporary sentinel commit' '
git checkout B &&
FAKE_LINES="2" test_must_fail git rebase -i --root &&
git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
git rebase --abort
'

test_done
4 changes: 0 additions & 4 deletions t/t3412-rebase-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ test_expect_success 'prepare repository' '
test_commit 4 B
'

test_expect_success 'rebase --root expects --onto' '
test_must_fail git rebase --root
'

test_expect_success 'setup pre-rebase hook' '
mkdir -p .git/hooks &&
cat >.git/hooks/pre-rebase <<EOF &&
Expand Down

0 comments on commit b64b7fe

Please sign in to comment.