Skip to content

Commit 8ff80a2

Browse files
committed
Merge branch 'mz/rebase-tests'
* 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
2 parents ee64e34 + 984f78d commit 8ff80a2

8 files changed

+673
-203
lines changed

t/lib-rebase.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,36 @@ EOF
6565
test_set_editor "$(pwd)/fake-editor.sh"
6666
chmod a+x fake-editor.sh
6767
}
68+
69+
# checks that the revisions in "$2" represent a linear range with the
70+
# subjects in "$1"
71+
test_linear_range () {
72+
revlist_merges=$(git rev-list --merges "$2") &&
73+
test -z "$revlist_merges" &&
74+
expected=$1
75+
set -- $(git log --reverse --format=%s "$2")
76+
test "$expected" = "$*"
77+
}
78+
79+
reset_rebase () {
80+
test_might_fail git rebase --abort &&
81+
git reset --hard &&
82+
git clean -f
83+
}
84+
85+
cherry_pick () {
86+
git cherry-pick -n "$2" &&
87+
git commit -m "$1" &&
88+
git tag "$1"
89+
}
90+
91+
revert () {
92+
git revert -n "$2" &&
93+
git commit -m "$1" &&
94+
git tag "$1"
95+
}
96+
97+
make_empty () {
98+
git commit --allow-empty -m "$1" &&
99+
git tag "$1"
100+
}

t/t3400-rebase.sh

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ test_expect_success 'prepare repository with topic branches' '
4040
echo Side >>C &&
4141
git add C &&
4242
git commit -m "Add C" &&
43-
git checkout -b nonlinear my-topic-branch &&
44-
echo Edit >>B &&
45-
git add B &&
46-
git commit -m "Modify B" &&
47-
git merge side &&
48-
git checkout -b upstream-merged-nonlinear &&
49-
git merge master &&
5043
git checkout -f my-topic-branch &&
5144
git tag topic
5245
'
@@ -66,28 +59,6 @@ test_expect_success 'rebase against master' '
6659
git rebase master
6760
'
6861

69-
test_expect_success 'rebase against master twice' '
70-
git rebase master >out &&
71-
test_i18ngrep "Current branch my-topic-branch is up to date" out
72-
'
73-
74-
test_expect_success 'rebase against master twice with --force' '
75-
git rebase --force-rebase master >out &&
76-
test_i18ngrep "Current branch my-topic-branch is up to date, rebase forced" out
77-
'
78-
79-
test_expect_success 'rebase against master twice from another branch' '
80-
git checkout my-topic-branch^ &&
81-
git rebase master my-topic-branch >out &&
82-
test_i18ngrep "Current branch my-topic-branch is up to date" out
83-
'
84-
85-
test_expect_success 'rebase fast-forward to master' '
86-
git checkout my-topic-branch^ &&
87-
git rebase my-topic-branch >out &&
88-
test_i18ngrep "Fast-forwarded HEAD to my-topic-branch" out
89-
'
90-
9162
test_expect_success 'the rebase operation should not have destroyed author information' '
9263
! (git log | grep "Author:" | grep "<>")
9364
'
@@ -106,31 +77,9 @@ test_expect_success 'rebase from ambiguous branch name' '
10677
git rebase master
10778
'
10879

109-
test_expect_success 'rebase after merge master' '
110-
git checkout --detach refs/tags/topic &&
111-
git branch -D topic &&
112-
git reset --hard topic &&
113-
git merge master &&
114-
git rebase master &&
115-
! (git show | grep "^Merge:")
116-
'
117-
118-
test_expect_success 'rebase of history with merges is linearized' '
119-
git checkout nonlinear &&
120-
test 4 = $(git rev-list master.. | wc -l) &&
121-
git rebase master &&
122-
test 3 = $(git rev-list master.. | wc -l)
123-
'
124-
125-
test_expect_success 'rebase of history with merges after upstream merge is linearized' '
126-
git checkout upstream-merged-nonlinear &&
127-
test 5 = $(git rev-list master.. | wc -l) &&
128-
git rebase master &&
129-
test 3 = $(git rev-list master.. | wc -l)
130-
'
131-
13280
test_expect_success 'rebase a single mode change' '
13381
git checkout master &&
82+
git branch -D topic &&
13483
echo 1 >X &&
13584
git add X &&
13685
test_tick &&

t/t3401-rebase-partial.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -477,19 +477,11 @@ test_expect_success 'interrupted squash works as expected (case 2)' '
477477
test $one = $(git rev-parse HEAD~2)
478478
'
479479

480-
test_expect_success 'ignore patch if in upstream' '
481-
HEAD=$(git rev-parse HEAD) &&
482-
git checkout -b has-cherry-picked HEAD^ &&
480+
test_expect_success '--continue tries to commit, even for "edit"' '
483481
echo unrelated > file7 &&
484482
git add file7 &&
485483
test_tick &&
486484
git commit -m "unrelated change" &&
487-
git cherry-pick $HEAD &&
488-
EXPECT_COUNT=1 git rebase -i $HEAD &&
489-
test $HEAD = $(git rev-parse HEAD^)
490-
'
491-
492-
test_expect_success '--continue tries to commit, even for "edit"' '
493485
parent=$(git rev-parse HEAD^) &&
494486
test_tick &&
495487
FAKE_LINES="edit 1" git rebase -i HEAD^ &&

t/t3406-rebase-message.sh

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,17 @@ test_description='messages from rebase operation'
44

55
. ./test-lib.sh
66

7-
quick_one () {
8-
echo "$1" >"file$1" &&
9-
git add "file$1" &&
10-
test_tick &&
11-
git commit -m "$1"
12-
}
7+
test_expect_success 'setup' '
8+
test_commit O fileO &&
9+
test_commit X fileX &&
10+
test_commit A fileA &&
11+
test_commit B fileB &&
12+
test_commit Y fileY &&
1313
14-
test_expect_success setup '
15-
quick_one O &&
16-
git branch topic &&
17-
quick_one X &&
18-
quick_one A &&
19-
quick_one B &&
20-
quick_one Y &&
21-
22-
git checkout topic &&
23-
quick_one A &&
24-
quick_one B &&
25-
quick_one Z &&
14+
git checkout -b topic O &&
15+
git cherry-pick A B &&
16+
test_commit Z fileZ &&
2617
git tag start
27-
2818
'
2919

3020
cat >expect <<\EOF
@@ -34,12 +24,32 @@ Committed: 0003 Z
3424
EOF
3525

3626
test_expect_success 'rebase -m' '
37-
3827
git rebase -m master >report &&
3928
sed -n -e "/^Already applied: /p" \
4029
-e "/^Committed: /p" report >actual &&
4130
test_cmp expect actual
31+
'
32+
33+
test_expect_success 'rebase against master twice' '
34+
git rebase master >out &&
35+
test_i18ngrep "Current branch topic is up to date" out
36+
'
37+
38+
test_expect_success 'rebase against master twice with --force' '
39+
git rebase --force-rebase master >out &&
40+
test_i18ngrep "Current branch topic is up to date, rebase forced" out
41+
'
42+
43+
test_expect_success 'rebase against master twice from another branch' '
44+
git checkout topic^ &&
45+
git rebase master topic >out &&
46+
test_i18ngrep "Current branch topic is up to date" out
47+
'
4248

49+
test_expect_success 'rebase fast-forward to master' '
50+
git checkout topic^ &&
51+
git rebase topic >out &&
52+
test_i18ngrep "Fast-forwarded HEAD to topic" out
4353
'
4454

4555
test_expect_success 'rebase --stat' '

t/t3409-rebase-preserve-merges.sh

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ Run "git rebase -p" and check that merges are properly carried along
1111
GIT_AUTHOR_EMAIL=bogus_email_address
1212
export GIT_AUTHOR_EMAIL
1313

14-
# Clone 1 (trivial merge):
15-
#
16-
# A1--A2 <-- origin/master
17-
# \ \
18-
# B1--M <-- topic
19-
# \
20-
# B2 <-- origin/topic
21-
#
2214
# Clone 2 (conflicting merge):
2315
#
2416
# A1--A2--B3 <-- origin/master
@@ -36,16 +28,6 @@ export GIT_AUTHOR_EMAIL
3628
# \--A3 <-- topic2
3729
# \
3830
# B2 <-- origin/topic
39-
#
40-
# Clone 4 (merge using second parent as base):
41-
#
42-
# A1--A2--B3 <-- origin/master
43-
# \
44-
# B1--A3--M <-- topic
45-
# \ /
46-
# \--A4 <-- topic2
47-
# \
48-
# B2 <-- origin/topic
4931

5032
test_expect_success 'setup for merge-preserving rebase' \
5133
'echo First > A &&
@@ -58,20 +40,6 @@ test_expect_success 'setup for merge-preserving rebase' \
5840
git checkout -f master &&
5941
echo Third >> A &&
6042
git commit -a -m "Modify A2" &&
61-
62-
git clone ./. clone1 &&
63-
(cd clone1 &&
64-
git checkout -b topic origin/topic &&
65-
git merge origin/master
66-
) &&
67-
68-
git clone ./. clone4 &&
69-
(
70-
cd clone4 &&
71-
git checkout -b topic origin/topic &&
72-
git merge origin/master
73-
) &&
74-
7543
echo Fifth > B &&
7644
git add B &&
7745
git commit -m "Add different B" &&
@@ -101,16 +69,6 @@ test_expect_success 'setup for merge-preserving rebase' \
10169
git commit -a -m "Modify B2"
10270
'
10371

104-
test_expect_success 'rebase -p fakes interactive rebase' '
105-
(
106-
cd clone1 &&
107-
git fetch &&
108-
git rebase -p origin/topic &&
109-
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
110-
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
111-
)
112-
'
113-
11472
test_expect_success '--continue works after a conflict' '
11573
(
11674
cd clone2 &&
@@ -138,15 +96,4 @@ test_expect_success 'rebase -p preserves no-ff merges' '
13896
)
13997
'
14098

141-
test_expect_success 'rebase -p works when base inside second parent' '
142-
(
143-
cd clone4 &&
144-
git fetch &&
145-
git rebase -p HEAD^2 &&
146-
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
147-
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify B" | wc -l) &&
148-
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
149-
)
150-
'
151-
15299
test_done

0 commit comments

Comments
 (0)