Skip to content

Commit

Permalink
add tests for rebasing merged history
Browse files Browse the repository at this point in the history
Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Martin von Zweigbergk authored and Junio C Hamano committed Jun 7, 2013
1 parent 6a6bc5b commit 3f21398
Show file tree
Hide file tree
Showing 5 changed files with 260 additions and 137 deletions.
31 changes: 1 addition & 30 deletions t/t3400-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ test_expect_success 'prepare repository with topic branches' '
echo Side >>C &&
git add C &&
git commit -m "Add C" &&
git checkout -b nonlinear my-topic-branch &&
echo Edit >>B &&
git add B &&
git commit -m "Modify B" &&
git merge side &&
git checkout -b upstream-merged-nonlinear &&
git merge master &&
git checkout -f my-topic-branch &&
git tag topic
'
Expand Down Expand Up @@ -106,31 +99,9 @@ test_expect_success 'rebase from ambiguous branch name' '
git rebase master
'

test_expect_success 'rebase after merge master' '
git checkout --detach refs/tags/topic &&
git branch -D topic &&
git reset --hard topic &&
git merge master &&
git rebase master &&
! (git show | grep "^Merge:")
'

test_expect_success 'rebase of history with merges is linearized' '
git checkout nonlinear &&
test 4 = $(git rev-list master.. | wc -l) &&
git rebase master &&
test 3 = $(git rev-list master.. | wc -l)
'

test_expect_success 'rebase of history with merges after upstream merge is linearized' '
git checkout upstream-merged-nonlinear &&
test 5 = $(git rev-list master.. | wc -l) &&
git rebase master &&
test 3 = $(git rev-list master.. | wc -l)
'

test_expect_success 'rebase a single mode change' '
git checkout master &&
git branch -D topic &&
echo 1 >X &&
git add X &&
test_tick &&
Expand Down
45 changes: 0 additions & 45 deletions t/t3401-rebase-partial.sh

This file was deleted.

10 changes: 1 addition & 9 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,11 @@ test_expect_success 'interrupted squash works as expected (case 2)' '
test $one = $(git rev-parse HEAD~2)
'

test_expect_success 'ignore patch if in upstream' '
HEAD=$(git rev-parse HEAD) &&
git checkout -b has-cherry-picked HEAD^ &&
test_expect_success '--continue tries to commit, even for "edit"' '
echo unrelated > file7 &&
git add file7 &&
test_tick &&
git commit -m "unrelated change" &&
git cherry-pick $HEAD &&
EXPECT_COUNT=1 git rebase -i $HEAD &&
test $HEAD = $(git rev-parse HEAD^)
'

test_expect_success '--continue tries to commit, even for "edit"' '
parent=$(git rev-parse HEAD^) &&
test_tick &&
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
Expand Down
53 changes: 0 additions & 53 deletions t/t3409-rebase-preserve-merges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ Run "git rebase -p" and check that merges are properly carried along
GIT_AUTHOR_EMAIL=bogus_email_address
export GIT_AUTHOR_EMAIL

# Clone 1 (trivial merge):
#
# A1--A2 <-- origin/master
# \ \
# B1--M <-- topic
# \
# B2 <-- origin/topic
#
# Clone 2 (conflicting merge):
#
# A1--A2--B3 <-- origin/master
Expand All @@ -36,16 +28,6 @@ export GIT_AUTHOR_EMAIL
# \--A3 <-- topic2
# \
# B2 <-- origin/topic
#
# Clone 4 (merge using second parent as base):
#
# A1--A2--B3 <-- origin/master
# \
# B1--A3--M <-- topic
# \ /
# \--A4 <-- topic2
# \
# B2 <-- origin/topic

test_expect_success 'setup for merge-preserving rebase' \
'echo First > A &&
Expand All @@ -58,20 +40,6 @@ test_expect_success 'setup for merge-preserving rebase' \
git checkout -f master &&
echo Third >> A &&
git commit -a -m "Modify A2" &&
git clone ./. clone1 &&
(cd clone1 &&
git checkout -b topic origin/topic &&
git merge origin/master
) &&
git clone ./. clone4 &&
(
cd clone4 &&
git checkout -b topic origin/topic &&
git merge origin/master
) &&
echo Fifth > B &&
git add B &&
git commit -m "Add different B" &&
Expand Down Expand Up @@ -101,16 +69,6 @@ test_expect_success 'setup for merge-preserving rebase' \
git commit -a -m "Modify B2"
'

test_expect_success 'rebase -p fakes interactive rebase' '
(
cd clone1 &&
git fetch &&
git rebase -p origin/topic &&
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
)
'

test_expect_success '--continue works after a conflict' '
(
cd clone2 &&
Expand Down Expand Up @@ -138,15 +96,4 @@ test_expect_success 'rebase -p preserves no-ff merges' '
)
'

test_expect_success 'rebase -p works when base inside second parent' '
(
cd clone4 &&
git fetch &&
git rebase -p HEAD^2 &&
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify B" | wc -l) &&
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
)
'

test_done
Loading

0 comments on commit 3f21398

Please sign in to comment.