revert: improve success message by adding abbreviated commit sha1
[git/kirr.git] / t / t3508-cherry-pick-many-commits.sh
blob6044173007c44882049ab187e2d97265215f2604
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 cat <<-EOF >expected &&
27 Finished cherry-pick of commit $(git rev-parse --short second).
28 Finished cherry-pick of commit $(git rev-parse --short third).
29 Finished cherry-pick of commit $(git rev-parse --short fourth).
30 EOF
32 git checkout -f master &&
33 git reset --hard first &&
34 test_tick &&
35 git cherry-pick first..fourth 2>actual &&
36 git diff --quiet other &&
37 git diff --quiet HEAD other &&
38 test_cmp expected actual &&
39 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
42 test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
43 cat <<-EOF >expected &&
44 Finished cherry-pick of commit $(git rev-parse --short second) with strategy resolve.
45 Finished cherry-pick of commit $(git rev-parse --short third) with strategy resolve.
46 Finished cherry-pick of commit $(git rev-parse --short fourth) with strategy resolve.
47 EOF
49 git checkout -f master &&
50 git reset --hard first &&
51 test_tick &&
52 git cherry-pick --strategy resolve first..fourth 2>actual &&
53 git diff --quiet other &&
54 git diff --quiet HEAD other &&
55 test_cmp expected actual &&
56 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
59 test_expect_success 'cherry-pick --ff first..fourth works' '
60 git checkout -f master &&
61 git reset --hard first &&
62 test_tick &&
63 git cherry-pick --ff first..fourth &&
64 git diff --quiet other &&
65 git diff --quiet HEAD other &&
66 test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify fourth)"
69 test_expect_success 'cherry-pick -n first..fourth works' '
70 git checkout -f master &&
71 git reset --hard first &&
72 test_tick &&
73 git cherry-pick -n first..fourth &&
74 git diff --quiet other &&
75 git diff --cached --quiet other &&
76 git diff --quiet HEAD first
79 test_expect_success 'revert first..fourth works' '
80 git checkout -f master &&
81 git reset --hard fourth &&
82 test_tick &&
83 git revert first..fourth &&
84 git diff --quiet first &&
85 git diff --cached --quiet first &&
86 git diff --quiet HEAD first
89 test_expect_success 'revert ^first fourth works' '
90 git checkout -f master &&
91 git reset --hard fourth &&
92 test_tick &&
93 git revert ^first fourth &&
94 git diff --quiet first &&
95 git diff --cached --quiet first &&
96 git diff --quiet HEAD first
99 test_expect_success 'revert fourth fourth~1 fourth~2 works' '
100 git checkout -f master &&
101 git reset --hard fourth &&
102 test_tick &&
103 git revert fourth fourth~1 fourth~2 &&
104 git diff --quiet first &&
105 git diff --cached --quiet first &&
106 git diff --quiet HEAD first
109 test_expect_success 'cherry-pick -3 fourth works' '
110 git checkout -f master &&
111 git reset --hard first &&
112 test_tick &&
113 git cherry-pick -3 fourth &&
114 git diff --quiet other &&
115 git diff --quiet HEAD other &&
116 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
119 test_expect_success 'cherry-pick --stdin works' '
120 git checkout -f master &&
121 git reset --hard first &&
122 test_tick &&
123 git rev-list --reverse first..fourth | git cherry-pick --stdin &&
124 git diff --quiet other &&
125 git diff --quiet HEAD other &&
126 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
129 test_done