docs: clarify that passing --depth to git-clone implies --single-branch
[alt-git.git] / t / t3508-cherry-pick-many-commits.sh
blob19c99d7ef1bc02e67a7b995206b9f66c04c1b31c
1 #!/bin/sh
3 test_description='test cherry-picking many commits'
5 . ./test-lib.sh
7 check_head_differs_from() {
8 ! test_cmp_rev HEAD "$1"
11 check_head_equals() {
12 test_cmp_rev HEAD "$1"
15 test_expect_success setup '
16 echo first > file1 &&
17 git add file1 &&
18 test_tick &&
19 git commit -m "first" &&
20 git tag first &&
22 git checkout -b other &&
23 for val in second third fourth
25 echo $val >> file1 &&
26 git add file1 &&
27 test_tick &&
28 git commit -m "$val" &&
29 git tag $val
30 done
33 test_expect_success 'cherry-pick first..fourth works' '
34 git checkout -f master &&
35 git reset --hard first &&
36 test_tick &&
37 git cherry-pick first..fourth &&
38 git diff --quiet other &&
39 git diff --quiet HEAD other &&
40 check_head_differs_from fourth
43 test_expect_success 'cherry-pick three one two works' '
44 git checkout -f first &&
45 test_commit one &&
46 test_commit two &&
47 test_commit three &&
48 git checkout -f master &&
49 git reset --hard first &&
50 git cherry-pick three one two &&
51 git diff --quiet three &&
52 git diff --quiet HEAD three &&
53 test "$(git log --reverse --format=%s first..)" = "three
54 one
55 two"
58 test_expect_success 'cherry-pick three one two: fails' '
59 git checkout -f master &&
60 git reset --hard first &&
61 test_must_fail git cherry-pick three one two:
64 test_expect_success 'output to keep user entertained during multi-pick' '
65 cat <<-\EOF >expected &&
66 [master OBJID] second
67 Author: A U Thor <author@example.com>
68 1 file changed, 1 insertion(+)
69 [master OBJID] third
70 Author: A U Thor <author@example.com>
71 1 file changed, 1 insertion(+)
72 [master OBJID] fourth
73 Author: A U Thor <author@example.com>
74 1 file changed, 1 insertion(+)
75 EOF
77 git checkout -f master &&
78 git reset --hard first &&
79 test_tick &&
80 git cherry-pick first..fourth >actual &&
81 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
82 test_line_count -ge 3 actual.fuzzy &&
83 test_i18ncmp expected actual.fuzzy
86 test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
87 git checkout -f master &&
88 git reset --hard first &&
89 test_tick &&
90 git cherry-pick --strategy resolve first..fourth &&
91 git diff --quiet other &&
92 git diff --quiet HEAD other &&
93 check_head_differs_from fourth
96 test_expect_success 'output during multi-pick indicates merge strategy' '
97 cat <<-\EOF >expected &&
98 Trying simple merge.
99 [master OBJID] second
100 Author: A U Thor <author@example.com>
101 1 file changed, 1 insertion(+)
102 Trying simple merge.
103 [master OBJID] third
104 Author: A U Thor <author@example.com>
105 1 file changed, 1 insertion(+)
106 Trying simple merge.
107 [master OBJID] fourth
108 Author: A U Thor <author@example.com>
109 1 file changed, 1 insertion(+)
112 git checkout -f master &&
113 git reset --hard first &&
114 test_tick &&
115 git cherry-pick --strategy resolve first..fourth >actual &&
116 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
117 test_i18ncmp expected actual.fuzzy
120 test_expect_success 'cherry-pick --ff first..fourth works' '
121 git checkout -f master &&
122 git reset --hard first &&
123 test_tick &&
124 git cherry-pick --ff first..fourth &&
125 git diff --quiet other &&
126 git diff --quiet HEAD other &&
127 check_head_equals fourth
130 test_expect_success 'cherry-pick -n first..fourth works' '
131 git checkout -f master &&
132 git reset --hard first &&
133 test_tick &&
134 git cherry-pick -n first..fourth &&
135 git diff --quiet other &&
136 git diff --cached --quiet other &&
137 git diff --quiet HEAD first
140 test_expect_success 'revert first..fourth works' '
141 git checkout -f master &&
142 git reset --hard fourth &&
143 test_tick &&
144 git revert first..fourth &&
145 git diff --quiet first &&
146 git diff --cached --quiet first &&
147 git diff --quiet HEAD first
150 test_expect_success 'revert ^first fourth works' '
151 git checkout -f master &&
152 git reset --hard fourth &&
153 test_tick &&
154 git revert ^first fourth &&
155 git diff --quiet first &&
156 git diff --cached --quiet first &&
157 git diff --quiet HEAD first
160 test_expect_success 'revert fourth fourth~1 fourth~2 works' '
161 git checkout -f master &&
162 git reset --hard fourth &&
163 test_tick &&
164 git revert fourth fourth~1 fourth~2 &&
165 git diff --quiet first &&
166 git diff --cached --quiet first &&
167 git diff --quiet HEAD first
170 test_expect_success 'cherry-pick -3 fourth works' '
171 git checkout -f master &&
172 git reset --hard first &&
173 test_tick &&
174 git cherry-pick -3 fourth &&
175 git diff --quiet other &&
176 git diff --quiet HEAD other &&
177 check_head_differs_from fourth
180 test_expect_success 'cherry-pick --stdin works' '
181 git checkout -f master &&
182 git reset --hard first &&
183 test_tick &&
184 git rev-list --reverse first..fourth | git cherry-pick --stdin &&
185 git diff --quiet other &&
186 git diff --quiet HEAD other &&
187 check_head_differs_from fourth
190 test_done