refname objects: do not prune
[git/mjg.git] / t / t3508-cherry-pick-many-commits.sh
blob4e7136b83775946a07678119c7c9897bb0f2b709
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 'output to keep user entertained during multi-pick' '
59 cat <<-\EOF >expected &&
60 [master OBJID] second
61 Author: A U Thor <author@example.com>
62 1 file changed, 1 insertion(+)
63 [master OBJID] third
64 Author: A U Thor <author@example.com>
65 1 file changed, 1 insertion(+)
66 [master OBJID] fourth
67 Author: A U Thor <author@example.com>
68 1 file changed, 1 insertion(+)
69 EOF
71 git checkout -f master &&
72 git reset --hard first &&
73 test_tick &&
74 git cherry-pick first..fourth >actual &&
75 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
76 test_line_count -ge 3 actual.fuzzy &&
77 test_i18ncmp expected actual.fuzzy
80 test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
81 git checkout -f master &&
82 git reset --hard first &&
83 test_tick &&
84 git cherry-pick --strategy resolve first..fourth &&
85 git diff --quiet other &&
86 git diff --quiet HEAD other &&
87 check_head_differs_from fourth
90 test_expect_success 'output during multi-pick indicates merge strategy' '
91 cat <<-\EOF >expected &&
92 Trying simple merge.
93 [master OBJID] second
94 Author: A U Thor <author@example.com>
95 1 file changed, 1 insertion(+)
96 Trying simple merge.
97 [master OBJID] third
98 Author: A U Thor <author@example.com>
99 1 file changed, 1 insertion(+)
100 Trying simple merge.
101 [master OBJID] fourth
102 Author: A U Thor <author@example.com>
103 1 file changed, 1 insertion(+)
106 git checkout -f master &&
107 git reset --hard first &&
108 test_tick &&
109 git cherry-pick --strategy resolve first..fourth >actual &&
110 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
111 test_i18ncmp expected actual.fuzzy
114 test_expect_success 'cherry-pick --ff first..fourth works' '
115 git checkout -f master &&
116 git reset --hard first &&
117 test_tick &&
118 git cherry-pick --ff first..fourth &&
119 git diff --quiet other &&
120 git diff --quiet HEAD other &&
121 check_head_equals fourth
124 test_expect_success 'cherry-pick -n first..fourth works' '
125 git checkout -f master &&
126 git reset --hard first &&
127 test_tick &&
128 git cherry-pick -n first..fourth &&
129 git diff --quiet other &&
130 git diff --cached --quiet other &&
131 git diff --quiet HEAD first
134 test_expect_success 'revert first..fourth works' '
135 git checkout -f master &&
136 git reset --hard fourth &&
137 test_tick &&
138 git revert first..fourth &&
139 git diff --quiet first &&
140 git diff --cached --quiet first &&
141 git diff --quiet HEAD first
144 test_expect_success 'revert ^first fourth works' '
145 git checkout -f master &&
146 git reset --hard fourth &&
147 test_tick &&
148 git revert ^first fourth &&
149 git diff --quiet first &&
150 git diff --cached --quiet first &&
151 git diff --quiet HEAD first
154 test_expect_success 'revert fourth fourth~1 fourth~2 works' '
155 git checkout -f master &&
156 git reset --hard fourth &&
157 test_tick &&
158 git revert fourth fourth~1 fourth~2 &&
159 git diff --quiet first &&
160 git diff --cached --quiet first &&
161 git diff --quiet HEAD first
164 test_expect_success 'cherry-pick -3 fourth works' '
165 git checkout -f master &&
166 git reset --hard first &&
167 test_tick &&
168 git cherry-pick -3 fourth &&
169 git diff --quiet other &&
170 git diff --quiet HEAD other &&
171 check_head_differs_from fourth
174 test_expect_success 'cherry-pick --stdin works' '
175 git checkout -f master &&
176 git reset --hard first &&
177 test_tick &&
178 git rev-list --reverse first..fourth | git cherry-pick --stdin &&
179 git diff --quiet other &&
180 git diff --quiet HEAD other &&
181 check_head_differs_from fourth
184 test_done