Merge branch 'jn/rebase-rename-am'
[git/jnareb-git/bp-gitweb.git] / t / t3508-cherry-pick-many-commits.sh
blobf90ed3da3e0cb93b63d32d8002dc6d9bd3596a65
1 #!/bin/sh
3 test_description='test cherry-picking many commits'
5 . ./test-lib.sh
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 &&
14 git checkout -b other &&
15 for val in second third fourth
17 echo $val >> file1 &&
18 git add file1 &&
19 test_tick &&
20 git commit -m "$val" &&
21 git tag $val
22 done
25 test_expect_success 'cherry-pick first..fourth works' '
26 git checkout -f 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)"
35 test_expect_success 'cherry-pick --ff first..fourth works' '
36 git checkout -f 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)"
45 test_expect_success 'cherry-pick -n first..fourth works' '
46 git checkout -f 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
55 test_expect_success 'revert first..fourth works' '
56 git checkout -f 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
65 test_expect_success 'revert ^first fourth works' '
66 git checkout -f 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
75 test_expect_success 'revert fourth fourth~1 fourth~2 works' '
76 git checkout -f 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
85 test_expect_success 'cherry-pick -3 fourth works' '
86 git checkout -f 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)"
95 test_expect_success 'cherry-pick --stdin works' '
96 git checkout -f master &&
97 git reset --hard first &&
98 test_tick &&
99 git rev-list --reverse first..fourth | git cherry-pick --stdin &&
100 git diff --quiet other &&
101 git diff --quiet HEAD other &&
102 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
105 test_done