Skip to content

Commit

Permalink
Merge branch 'mz/rebase-tests'
Browse files Browse the repository at this point in the history
* mz/rebase-tests:
  rebase topology tests: fix commit names on case-insensitive file systems
  tests: move test for rebase messages from t3400 to t3406
  t3406: modernize style
  add tests for rebasing merged history
  add tests for rebasing root
  add tests for rebasing of empty commits
  add tests for rebasing with patch-equivalence present
  add simple tests of consistency across rebase types
  • Loading branch information
Junio C Hamano committed Jun 23, 2013
2 parents ee64e34 + 984f78d commit 8ff80a2
Show file tree
Hide file tree
Showing 8 changed files with 673 additions and 203 deletions.
33 changes: 33 additions & 0 deletions t/lib-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,36 @@ EOF
test_set_editor "$(pwd)/fake-editor.sh"
chmod a+x fake-editor.sh
}

# checks that the revisions in "$2" represent a linear range with the
# subjects in "$1"
test_linear_range () {
revlist_merges=$(git rev-list --merges "$2") &&
test -z "$revlist_merges" &&
expected=$1
set -- $(git log --reverse --format=%s "$2")
test "$expected" = "$*"
}

reset_rebase () {
test_might_fail git rebase --abort &&
git reset --hard &&
git clean -f
}

cherry_pick () {
git cherry-pick -n "$2" &&
git commit -m "$1" &&
git tag "$1"
}

revert () {
git revert -n "$2" &&
git commit -m "$1" &&
git tag "$1"
}

make_empty () {
git commit --allow-empty -m "$1" &&
git tag "$1"
}
53 changes: 1 addition & 52 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 All @@ -66,28 +59,6 @@ test_expect_success 'rebase against master' '
git rebase master
'

test_expect_success 'rebase against master twice' '
git rebase master >out &&
test_i18ngrep "Current branch my-topic-branch is up to date" out
'

test_expect_success 'rebase against master twice with --force' '
git rebase --force-rebase master >out &&
test_i18ngrep "Current branch my-topic-branch is up to date, rebase forced" out
'

test_expect_success 'rebase against master twice from another branch' '
git checkout my-topic-branch^ &&
git rebase master my-topic-branch >out &&
test_i18ngrep "Current branch my-topic-branch is up to date" out
'

test_expect_success 'rebase fast-forward to master' '
git checkout my-topic-branch^ &&
git rebase my-topic-branch >out &&
test_i18ngrep "Fast-forwarded HEAD to my-topic-branch" out
'

test_expect_success 'the rebase operation should not have destroyed author information' '
! (git log | grep "Author:" | grep "<>")
'
Expand All @@ -106,31 +77,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
69 changes: 0 additions & 69 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
50 changes: 30 additions & 20 deletions t/t3406-rebase-message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,17 @@ test_description='messages from rebase operation'

. ./test-lib.sh

quick_one () {
echo "$1" >"file$1" &&
git add "file$1" &&
test_tick &&
git commit -m "$1"
}
test_expect_success 'setup' '
test_commit O fileO &&
test_commit X fileX &&
test_commit A fileA &&
test_commit B fileB &&
test_commit Y fileY &&
test_expect_success setup '
quick_one O &&
git branch topic &&
quick_one X &&
quick_one A &&
quick_one B &&
quick_one Y &&
git checkout topic &&
quick_one A &&
quick_one B &&
quick_one Z &&
git checkout -b topic O &&
git cherry-pick A B &&
test_commit Z fileZ &&
git tag start
'

cat >expect <<\EOF
Expand All @@ -34,12 +24,32 @@ Committed: 0003 Z
EOF

test_expect_success 'rebase -m' '
git rebase -m master >report &&
sed -n -e "/^Already applied: /p" \
-e "/^Committed: /p" report >actual &&
test_cmp expect actual
'

test_expect_success 'rebase against master twice' '
git rebase master >out &&
test_i18ngrep "Current branch topic is up to date" out
'

test_expect_success 'rebase against master twice with --force' '
git rebase --force-rebase master >out &&
test_i18ngrep "Current branch topic is up to date, rebase forced" out
'

test_expect_success 'rebase against master twice from another branch' '
git checkout topic^ &&
git rebase master topic >out &&
test_i18ngrep "Current branch topic is up to date" out
'

test_expect_success 'rebase fast-forward to master' '
git checkout topic^ &&
git rebase topic >out &&
test_i18ngrep "Fast-forwarded HEAD to topic" out
'

test_expect_success 'rebase --stat' '
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 8ff80a2

Please sign in to comment.