Skip to content

Commit aa29ccf

Browse files
chriscoolgitster
authored andcommitted
revert: add tests to check cherry-picking many commits
Note that there is an expected failure when running: git cherry-pick -3 fourth that's because: git rev-list --no-walk -3 fourth produce only one commit and not 3 as "--no-walk" seems to take over "-3". Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e2bfd3 commit aa29ccf

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

t/t3508-cherry-pick-many-commits.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/sh
2+
3+
test_description='test cherry-picking many commits'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
echo first > file1 &&
9+
git add file1 &&
10+
test_tick &&
11+
git commit -m "first" &&
12+
git tag first &&
13+
14+
git checkout -b other &&
15+
for val in second third fourth
16+
do
17+
echo $val >> file1 &&
18+
git add file1 &&
19+
test_tick &&
20+
git commit -m "$val" &&
21+
git tag $val
22+
done
23+
'
24+
25+
test_expect_success 'cherry-pick first..fourth works' '
26+
git checkout master &&
27+
git reset --hard first &&
28+
test_tick &&
29+
git cherry-pick first..fourth &&
30+
git diff --quiet other &&
31+
git diff --quiet HEAD other &&
32+
test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
33+
'
34+
35+
test_expect_success 'cherry-pick --ff first..fourth works' '
36+
git checkout master &&
37+
git reset --hard first &&
38+
test_tick &&
39+
git cherry-pick --ff first..fourth &&
40+
git diff --quiet other &&
41+
git diff --quiet HEAD other &&
42+
test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify fourth)"
43+
'
44+
45+
test_expect_success 'cherry-pick -n first..fourth works' '
46+
git checkout master &&
47+
git reset --hard first &&
48+
test_tick &&
49+
git cherry-pick -n first..fourth &&
50+
git diff --quiet other &&
51+
git diff --cached --quiet other &&
52+
git diff --quiet HEAD first
53+
'
54+
55+
test_expect_success 'revert first..fourth works' '
56+
git checkout master &&
57+
git reset --hard fourth &&
58+
test_tick &&
59+
git revert first..fourth &&
60+
git diff --quiet first &&
61+
git diff --cached --quiet first &&
62+
git diff --quiet HEAD first
63+
'
64+
65+
test_expect_success 'revert ^first fourth works' '
66+
git checkout master &&
67+
git reset --hard fourth &&
68+
test_tick &&
69+
git revert ^first fourth &&
70+
git diff --quiet first &&
71+
git diff --cached --quiet first &&
72+
git diff --quiet HEAD first
73+
'
74+
75+
test_expect_success 'revert fourth fourth~1 fourth~2 works' '
76+
git checkout master &&
77+
git reset --hard fourth &&
78+
test_tick &&
79+
git revert fourth fourth~1 fourth~2 &&
80+
git diff --quiet first &&
81+
git diff --cached --quiet first &&
82+
git diff --quiet HEAD first
83+
'
84+
85+
test_expect_failure 'cherry-pick -3 fourth works' '
86+
git checkout master &&
87+
git reset --hard first &&
88+
test_tick &&
89+
git cherry-pick -3 fourth &&
90+
git diff --quiet other &&
91+
git diff --quiet HEAD other &&
92+
test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
93+
'
94+
95+
test_done

0 commit comments

Comments
 (0)