send-email: handle Windows paths for display just like we do for processing
[git/mingw/4msysgit.git] / t / t3508-cherry-pick-many-commits.sh
blob340afc760de030879fff496dca3db8432a6b992b
1 #!/bin/sh
3 test_description='test cherry-picking many commits'
5 . ./test-lib.sh
7 check_head_differs_from() {
8 head=$(git rev-parse --verify HEAD) &&
9 arg=$(git rev-parse --verify "$1") &&
10 test "$head" != "$arg"
13 check_head_equals() {
14 head=$(git rev-parse --verify HEAD) &&
15 arg=$(git rev-parse --verify "$1") &&
16 test "$head" = "$arg"
19 test_expect_success setup '
20 echo first > file1 &&
21 git add file1 &&
22 test_tick &&
23 git commit -m "first" &&
24 git tag first &&
26 git checkout -b other &&
27 for val in second third fourth
29 echo $val >> file1 &&
30 git add file1 &&
31 test_tick &&
32 git commit -m "$val" &&
33 git tag $val
34 done
37 test_expect_success 'cherry-pick first..fourth works' '
38 git checkout -f master &&
39 git reset --hard first &&
40 test_tick &&
41 git cherry-pick first..fourth &&
42 git diff --quiet other &&
43 git diff --quiet HEAD other &&
44 check_head_differs_from fourth
47 test_expect_success 'cherry-pick three one two works' '
48 git checkout -f first &&
49 test_commit one &&
50 test_commit two &&
51 test_commit three &&
52 git checkout -f master &&
53 git reset --hard first &&
54 git cherry-pick three one two &&
55 git diff --quiet three &&
56 git diff --quiet HEAD three &&
57 test "$(git log --reverse --format=%s first..)" = "three
58 one
59 two"
62 test_expect_success 'output to keep user entertained during multi-pick' '
63 cat <<-\EOF >expected &&
64 [master OBJID] second
65 Author: A U Thor <author@example.com>
66 1 file changed, 1 insertion(+)
67 [master OBJID] third
68 Author: A U Thor <author@example.com>
69 1 file changed, 1 insertion(+)
70 [master OBJID] fourth
71 Author: A U Thor <author@example.com>
72 1 file changed, 1 insertion(+)
73 EOF
75 git checkout -f master &&
76 git reset --hard first &&
77 test_tick &&
78 git cherry-pick first..fourth >actual &&
79 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
80 test_line_count -ge 3 actual.fuzzy &&
81 test_i18ncmp expected actual.fuzzy
84 test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
85 git checkout -f master &&
86 git reset --hard first &&
87 test_tick &&
88 git cherry-pick --strategy resolve first..fourth &&
89 git diff --quiet other &&
90 git diff --quiet HEAD other &&
91 check_head_differs_from fourth
94 test_expect_success 'output during multi-pick indicates merge strategy' '
95 cat <<-\EOF >expected &&
96 Trying simple merge.
97 [master OBJID] second
98 Author: A U Thor <author@example.com>
99 1 file changed, 1 insertion(+)
100 Trying simple merge.
101 [master OBJID] third
102 Author: A U Thor <author@example.com>
103 1 file changed, 1 insertion(+)
104 Trying simple merge.
105 [master OBJID] fourth
106 Author: A U Thor <author@example.com>
107 1 file changed, 1 insertion(+)
110 git checkout -f master &&
111 git reset --hard first &&
112 test_tick &&
113 git cherry-pick --strategy resolve first..fourth >actual &&
114 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
115 test_i18ncmp expected actual.fuzzy
118 test_expect_success 'cherry-pick --ff first..fourth works' '
119 git checkout -f master &&
120 git reset --hard first &&
121 test_tick &&
122 git cherry-pick --ff first..fourth &&
123 git diff --quiet other &&
124 git diff --quiet HEAD other &&
125 check_head_equals fourth
128 test_expect_success 'cherry-pick -n first..fourth works' '
129 git checkout -f master &&
130 git reset --hard first &&
131 test_tick &&
132 git cherry-pick -n first..fourth &&
133 git diff --quiet other &&
134 git diff --cached --quiet other &&
135 git diff --quiet HEAD first
138 test_expect_success 'revert first..fourth works' '
139 git checkout -f master &&
140 git reset --hard fourth &&
141 test_tick &&
142 git revert first..fourth &&
143 git diff --quiet first &&
144 git diff --cached --quiet first &&
145 git diff --quiet HEAD first
148 test_expect_success 'revert ^first fourth works' '
149 git checkout -f master &&
150 git reset --hard fourth &&
151 test_tick &&
152 git revert ^first fourth &&
153 git diff --quiet first &&
154 git diff --cached --quiet first &&
155 git diff --quiet HEAD first
158 test_expect_success 'revert fourth fourth~1 fourth~2 works' '
159 git checkout -f master &&
160 git reset --hard fourth &&
161 test_tick &&
162 git revert fourth fourth~1 fourth~2 &&
163 git diff --quiet first &&
164 git diff --cached --quiet first &&
165 git diff --quiet HEAD first
168 test_expect_success 'cherry-pick -3 fourth works' '
169 git checkout -f master &&
170 git reset --hard first &&
171 test_tick &&
172 git cherry-pick -3 fourth &&
173 git diff --quiet other &&
174 git diff --quiet HEAD other &&
175 check_head_differs_from fourth
178 test_expect_success 'cherry-pick --stdin works' '
179 git checkout -f master &&
180 git reset --hard first &&
181 test_tick &&
182 git rev-list --reverse first..fourth | git cherry-pick --stdin &&
183 git diff --quiet other &&
184 git diff --quiet HEAD other &&
185 check_head_differs_from fourth
188 test_done