]>
Commit | Line | Data |
---|---|---|
d3a7b8f5 SB |
1 | #!/bin/sh |
2 | ||
3 | test_description='git am running' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
800f1104 JN |
7 | test_expect_success 'setup: messages' ' |
8 | cat >msg <<-\EOF && | |
9 | second | |
10 | ||
11 | Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy | |
12 | eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam | |
13 | voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita | |
14 | kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem | |
15 | ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod | |
16 | tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At | |
17 | vero eos et accusam et justo duo dolores et ea rebum. | |
18 | ||
19 | EOF | |
250b3c6c | 20 | qz_to_tab_space <<-\EOF >>msg && |
800f1104 JN |
21 | QDuis autem vel eum iriure dolor in hendrerit in vulputate velit |
22 | Qesse molestie consequat, vel illum dolore eu feugiat nulla facilisis | |
23 | Qat vero eros et accumsan et iusto odio dignissim qui blandit | |
24 | Qpraesent luptatum zzril delenit augue duis dolore te feugait nulla | |
25 | Qfacilisi. | |
26 | EOF | |
27 | cat >>msg <<-\EOF && | |
28 | ||
29 | Lorem ipsum dolor sit amet, | |
30 | consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut | |
31 | laoreet dolore magna aliquam erat volutpat. | |
32 | ||
33 | git | |
34 | --- | |
35 | +++ | |
36 | ||
37 | Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit | |
38 | lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure | |
39 | dolor in hendrerit in vulputate velit esse molestie consequat, vel illum | |
40 | dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio | |
41 | dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te | |
42 | feugait nulla facilisi. | |
43 | EOF | |
44 | ||
45 | cat >failmail <<-\EOF && | |
46 | From foo@example.com Fri May 23 10:43:49 2008 | |
47 | From: foo@example.com | |
48 | To: bar@example.com | |
49 | Subject: Re: [RFC/PATCH] git-foo.sh | |
50 | Date: Fri, 23 May 2008 05:23:42 +0200 | |
51 | ||
52 | Sometimes we have to find out that there'\''s nothing left. | |
53 | ||
54 | EOF | |
55 | ||
56 | cat >pine <<-\EOF && | |
57 | From MAILER-DAEMON Fri May 23 10:43:49 2008 | |
58 | Date: 23 May 2008 05:23:42 +0200 | |
59 | From: Mail System Internal Data <MAILER-DAEMON@example.com> | |
60 | Subject: DON'\''T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA | |
61 | Message-ID: <foo-0001@example.com> | |
62 | ||
63 | This text is part of the internal format of your mail folder, and is not | |
64 | a real message. It is created automatically by the mail system software. | |
65 | If deleted, important folder data will be lost, and it will be re-created | |
66 | with the data reset to initial values. | |
67 | ||
68 | EOF | |
69 | ||
70 | signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" | |
71 | ' | |
d3a7b8f5 SB |
72 | |
73 | test_expect_success setup ' | |
74 | echo hello >file && | |
75 | git add file && | |
76 | test_tick && | |
77 | git commit -m first && | |
78 | git tag first && | |
800f1104 | 79 | |
d3a7b8f5 SB |
80 | echo world >>file && |
81 | git add file && | |
82 | test_tick && | |
83 | git commit -s -F msg && | |
84 | git tag second && | |
800f1104 | 85 | |
d3a7b8f5 | 86 | git format-patch --stdout first >patch1 && |
0fcb2caf JH |
87 | { |
88 | echo "X-Fake-Field: Line One" && | |
89 | echo "X-Fake-Field: Line Two" && | |
90 | echo "X-Fake-Field: Line Three" && | |
91 | git format-patch --stdout first | sed -e "1d" | |
92 | } > patch1.eml && | |
e3f67d30 SB |
93 | { |
94 | echo "X-Fake-Field: Line One" && | |
95 | echo "X-Fake-Field: Line Two" && | |
96 | echo "X-Fake-Field: Line Three" && | |
97 | git format-patch --stdout first | sed -e "1d" | |
98 | } | append_cr >patch1-crlf.eml && | |
0e8341f2 DB |
99 | { |
100 | printf "%255s\\n" "" | |
101 | echo "X-Fake-Field: Line One" && | |
102 | echo "X-Fake-Field: Line Two" && | |
103 | echo "X-Fake-Field: Line Three" && | |
104 | git format-patch --stdout first | sed -e "1d" | |
105 | } > patch1-ws.eml && | |
800f1104 | 106 | |
d3a7b8f5 SB |
107 | sed -n -e "3,\$p" msg >file && |
108 | git add file && | |
109 | test_tick && | |
110 | git commit -m third && | |
800f1104 | 111 | |
d3a7b8f5 | 112 | git format-patch --stdout first >patch2 && |
800f1104 | 113 | |
d3a7b8f5 SB |
114 | git checkout -b lorem && |
115 | sed -n -e "11,\$p" msg >file && | |
116 | head -n 9 msg >>file && | |
117 | test_tick && | |
118 | git commit -a -m "moved stuff" && | |
800f1104 | 119 | |
d3a7b8f5 SB |
120 | echo goodbye >another && |
121 | git add another && | |
122 | test_tick && | |
123 | git commit -m "added another file" && | |
d3a7b8f5 | 124 | |
800f1104 | 125 | git format-patch --stdout master >lorem-move.patch && |
a61ba26a | 126 | git format-patch --no-prefix --stdout master >lorem-zero.patch && |
18cdf802 JH |
127 | |
128 | git checkout -b rename && | |
129 | git mv file renamed && | |
130 | git commit -m "renamed a file" && | |
131 | ||
132 | git format-patch -M --stdout lorem >rename.patch && | |
133 | ||
134 | git reset --soft lorem^ && | |
135 | git commit -m "renamed a file and added another" && | |
136 | ||
137 | git format-patch -M --stdout lorem^ >rename-add.patch && | |
138 | ||
800f1104 | 139 | # reset time |
1f5ad6b1 | 140 | sane_unset test_tick && |
800f1104 JN |
141 | test_tick |
142 | ' | |
d3a7b8f5 SB |
143 | |
144 | test_expect_success 'am applies patch correctly' ' | |
5d274859 JN |
145 | rm -fr .git/rebase-apply && |
146 | git reset --hard && | |
d3a7b8f5 SB |
147 | git checkout first && |
148 | test_tick && | |
149 | git am <patch1 && | |
61e0eb9d | 150 | test_path_is_missing .git/rebase-apply && |
800f1104 | 151 | git diff --exit-code second && |
d3a7b8f5 SB |
152 | test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && |
153 | test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" | |
0fcb2caf JH |
154 | ' |
155 | ||
156 | test_expect_success 'am applies patch e-mail not in a mbox' ' | |
5d274859 JN |
157 | rm -fr .git/rebase-apply && |
158 | git reset --hard && | |
0fcb2caf JH |
159 | git checkout first && |
160 | git am patch1.eml && | |
61e0eb9d | 161 | test_path_is_missing .git/rebase-apply && |
800f1104 | 162 | git diff --exit-code second && |
0fcb2caf JH |
163 | test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && |
164 | test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" | |
e3f67d30 SB |
165 | ' |
166 | ||
167 | test_expect_success 'am applies patch e-mail not in a mbox with CRLF' ' | |
5d274859 JN |
168 | rm -fr .git/rebase-apply && |
169 | git reset --hard && | |
e3f67d30 SB |
170 | git checkout first && |
171 | git am patch1-crlf.eml && | |
61e0eb9d | 172 | test_path_is_missing .git/rebase-apply && |
800f1104 | 173 | git diff --exit-code second && |
e3f67d30 SB |
174 | test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && |
175 | test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" | |
d3a7b8f5 SB |
176 | ' |
177 | ||
0e8341f2 DB |
178 | test_expect_success 'am applies patch e-mail with preceding whitespace' ' |
179 | rm -fr .git/rebase-apply && | |
180 | git reset --hard && | |
181 | git checkout first && | |
182 | git am patch1-ws.eml && | |
61e0eb9d | 183 | test_path_is_missing .git/rebase-apply && |
0e8341f2 DB |
184 | git diff --exit-code second && |
185 | test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && | |
186 | test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" | |
187 | ' | |
188 | ||
800f1104 JN |
189 | test_expect_success 'setup: new author and committer' ' |
190 | GIT_AUTHOR_NAME="Another Thor" && | |
191 | GIT_AUTHOR_EMAIL="a.thor@example.com" && | |
192 | GIT_COMMITTER_NAME="Co M Miter" && | |
193 | GIT_COMMITTER_EMAIL="c.miter@example.com" && | |
194 | export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL | |
195 | ' | |
d3a7b8f5 SB |
196 | |
197 | compare () { | |
800f1104 JN |
198 | a=$(git cat-file commit "$2" | grep "^$1 ") && |
199 | b=$(git cat-file commit "$3" | grep "^$1 ") && | |
200 | test "$a" = "$b" | |
d3a7b8f5 SB |
201 | } |
202 | ||
203 | test_expect_success 'am changes committer and keeps author' ' | |
204 | test_tick && | |
5d274859 JN |
205 | rm -fr .git/rebase-apply && |
206 | git reset --hard && | |
d3a7b8f5 SB |
207 | git checkout first && |
208 | git am patch2 && | |
61e0eb9d | 209 | test_path_is_missing .git/rebase-apply && |
d3a7b8f5 | 210 | test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" && |
800f1104 JN |
211 | git diff --exit-code master..HEAD && |
212 | git diff --exit-code master^..HEAD^ && | |
d3a7b8f5 SB |
213 | compare author master HEAD && |
214 | compare author master^ HEAD^ && | |
215 | test "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" = \ | |
216 | "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)" | |
217 | ' | |
218 | ||
219 | test_expect_success 'am --signoff adds Signed-off-by: line' ' | |
5d274859 JN |
220 | rm -fr .git/rebase-apply && |
221 | git reset --hard && | |
d3a7b8f5 SB |
222 | git checkout -b master2 first && |
223 | git am --signoff <patch2 && | |
800f1104 | 224 | printf "%s\n" "$signoff" >expected && |
d3a7b8f5 SB |
225 | echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected && |
226 | git cat-file commit HEAD^ | grep "Signed-off-by:" >actual && | |
800f1104 | 227 | test_cmp expected actual && |
d3a7b8f5 SB |
228 | echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected && |
229 | git cat-file commit HEAD | grep "Signed-off-by:" >actual && | |
800f1104 | 230 | test_cmp expected actual |
d3a7b8f5 SB |
231 | ' |
232 | ||
233 | test_expect_success 'am stays in branch' ' | |
800f1104 JN |
234 | echo refs/heads/master2 >expected && |
235 | git symbolic-ref HEAD >actual && | |
236 | test_cmp expected actual | |
d3a7b8f5 SB |
237 | ' |
238 | ||
239 | test_expect_success 'am --signoff does not add Signed-off-by: line if already there' ' | |
240 | git format-patch --stdout HEAD^ >patch3 && | |
f7e5ea17 | 241 | sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2] [foo," patch3 >patch4 && |
5d274859 JN |
242 | rm -fr .git/rebase-apply && |
243 | git reset --hard && | |
d3a7b8f5 SB |
244 | git checkout HEAD^ && |
245 | git am --signoff patch4 && | |
800f1104 JN |
246 | git cat-file commit HEAD >actual && |
247 | test $(grep -c "^Signed-off-by:" actual) -eq 1 | |
d3a7b8f5 SB |
248 | ' |
249 | ||
250 | test_expect_success 'am without --keep removes Re: and [PATCH] stuff' ' | |
800f1104 JN |
251 | git rev-parse HEAD >expected && |
252 | git rev-parse master2 >actual && | |
253 | test_cmp expected actual | |
d3a7b8f5 SB |
254 | ' |
255 | ||
256 | test_expect_success 'am --keep really keeps the subject' ' | |
5d274859 JN |
257 | rm -fr .git/rebase-apply && |
258 | git reset --hard && | |
d3a7b8f5 SB |
259 | git checkout HEAD^ && |
260 | git am --keep patch4 && | |
61e0eb9d | 261 | test_path_is_missing .git/rebase-apply && |
800f1104 | 262 | git cat-file commit HEAD >actual && |
f7e5ea17 TR |
263 | grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual |
264 | ' | |
265 | ||
ee2d1cb4 | 266 | test_expect_success 'am --keep-non-patch really keeps the non-patch part' ' |
f7e5ea17 TR |
267 | rm -fr .git/rebase-apply && |
268 | git reset --hard && | |
269 | git checkout HEAD^ && | |
270 | git am --keep-non-patch patch4 && | |
61e0eb9d | 271 | test_path_is_missing .git/rebase-apply && |
f7e5ea17 TR |
272 | git cat-file commit HEAD >actual && |
273 | grep "^\[foo\] third" actual | |
d3a7b8f5 SB |
274 | ' |
275 | ||
276 | test_expect_success 'am -3 falls back to 3-way merge' ' | |
5d274859 JN |
277 | rm -fr .git/rebase-apply && |
278 | git reset --hard && | |
d3a7b8f5 SB |
279 | git checkout -b lorem2 master2 && |
280 | sed -n -e "3,\$p" msg >file && | |
281 | head -n 9 msg >>file && | |
282 | git add file && | |
283 | test_tick && | |
284 | git commit -m "copied stuff" && | |
285 | git am -3 lorem-move.patch && | |
61e0eb9d | 286 | test_path_is_missing .git/rebase-apply && |
800f1104 | 287 | git diff --exit-code lorem |
d3a7b8f5 SB |
288 | ' |
289 | ||
a61ba26a JH |
290 | test_expect_success 'am -3 -p0 can read --no-prefix patch' ' |
291 | rm -fr .git/rebase-apply && | |
292 | git reset --hard && | |
293 | git checkout -b lorem3 master2 && | |
294 | sed -n -e "3,\$p" msg >file && | |
295 | head -n 9 msg >>file && | |
296 | git add file && | |
297 | test_tick && | |
298 | git commit -m "copied stuff" && | |
299 | git am -3 -p0 lorem-zero.patch && | |
61e0eb9d | 300 | test_path_is_missing .git/rebase-apply && |
a61ba26a JH |
301 | git diff --exit-code lorem |
302 | ' | |
303 | ||
18cdf802 JH |
304 | test_expect_success 'am can rename a file' ' |
305 | grep "^rename from" rename.patch && | |
306 | rm -fr .git/rebase-apply && | |
307 | git reset --hard && | |
308 | git checkout lorem^0 && | |
309 | git am rename.patch && | |
61e0eb9d | 310 | test_path_is_missing .git/rebase-apply && |
18cdf802 JH |
311 | git update-index --refresh && |
312 | git diff --exit-code rename | |
313 | ' | |
314 | ||
315 | test_expect_success 'am -3 can rename a file' ' | |
316 | grep "^rename from" rename.patch && | |
317 | rm -fr .git/rebase-apply && | |
318 | git reset --hard && | |
319 | git checkout lorem^0 && | |
320 | git am -3 rename.patch && | |
61e0eb9d | 321 | test_path_is_missing .git/rebase-apply && |
18cdf802 JH |
322 | git update-index --refresh && |
323 | git diff --exit-code rename | |
324 | ' | |
325 | ||
326 | test_expect_success 'am -3 can rename a file after falling back to 3-way merge' ' | |
327 | grep "^rename from" rename-add.patch && | |
328 | rm -fr .git/rebase-apply && | |
329 | git reset --hard && | |
330 | git checkout lorem^0 && | |
331 | git am -3 rename-add.patch && | |
61e0eb9d | 332 | test_path_is_missing .git/rebase-apply && |
18cdf802 JH |
333 | git update-index --refresh && |
334 | git diff --exit-code rename | |
335 | ' | |
336 | ||
0e987a12 | 337 | test_expect_success 'am -3 -q is quiet' ' |
5d274859 | 338 | rm -fr .git/rebase-apply && |
18cdf802 | 339 | git checkout -f lorem2 && |
0e987a12 SB |
340 | git reset master2 --hard && |
341 | sed -n -e "3,\$p" msg >file && | |
342 | head -n 9 msg >>file && | |
343 | git add file && | |
344 | test_tick && | |
345 | git commit -m "copied stuff" && | |
800f1104 | 346 | git am -3 -q lorem-move.patch >output.out 2>&1 && |
0e987a12 SB |
347 | ! test -s output.out |
348 | ' | |
349 | ||
d3a7b8f5 | 350 | test_expect_success 'am pauses on conflict' ' |
5d274859 JN |
351 | rm -fr .git/rebase-apply && |
352 | git reset --hard && | |
d3a7b8f5 | 353 | git checkout lorem2^^ && |
d492b31c | 354 | test_must_fail git am lorem-move.patch && |
51ef1daa | 355 | test -d .git/rebase-apply |
d3a7b8f5 SB |
356 | ' |
357 | ||
358 | test_expect_success 'am --skip works' ' | |
800f1104 | 359 | echo goodbye >expected && |
d3a7b8f5 | 360 | git am --skip && |
61e0eb9d | 361 | test_path_is_missing .git/rebase-apply && |
800f1104 JN |
362 | git diff --exit-code lorem2^^ -- file && |
363 | test_cmp expected another | |
d3a7b8f5 SB |
364 | ' |
365 | ||
b141f3c9 RR |
366 | test_expect_success 'am --abort removes a stray directory' ' |
367 | mkdir .git/rebase-apply && | |
368 | git am --abort && | |
369 | test_path_is_missing .git/rebase-apply | |
370 | ' | |
371 | ||
d3a7b8f5 | 372 | test_expect_success 'am --resolved works' ' |
800f1104 | 373 | echo goodbye >expected && |
5d274859 JN |
374 | rm -fr .git/rebase-apply && |
375 | git reset --hard && | |
d3a7b8f5 | 376 | git checkout lorem2^^ && |
d492b31c | 377 | test_must_fail git am lorem-move.patch && |
51ef1daa | 378 | test -d .git/rebase-apply && |
d3a7b8f5 SB |
379 | echo resolved >>file && |
380 | git add file && | |
381 | git am --resolved && | |
61e0eb9d | 382 | test_path_is_missing .git/rebase-apply && |
800f1104 | 383 | test_cmp expected another |
d3a7b8f5 SB |
384 | ' |
385 | ||
386 | test_expect_success 'am takes patches from a Pine mailbox' ' | |
5d274859 JN |
387 | rm -fr .git/rebase-apply && |
388 | git reset --hard && | |
d3a7b8f5 SB |
389 | git checkout first && |
390 | cat pine patch1 | git am && | |
61e0eb9d | 391 | test_path_is_missing .git/rebase-apply && |
800f1104 | 392 | git diff --exit-code master^..HEAD |
d3a7b8f5 SB |
393 | ' |
394 | ||
395 | test_expect_success 'am fails on mail without patch' ' | |
5d274859 JN |
396 | rm -fr .git/rebase-apply && |
397 | git reset --hard && | |
d492b31c | 398 | test_must_fail git am <failmail && |
5d274859 | 399 | git am --abort && |
61e0eb9d | 400 | test_path_is_missing .git/rebase-apply |
d3a7b8f5 SB |
401 | ' |
402 | ||
403 | test_expect_success 'am fails on empty patch' ' | |
5d274859 JN |
404 | rm -fr .git/rebase-apply && |
405 | git reset --hard && | |
d3a7b8f5 | 406 | echo "---" >>failmail && |
d492b31c | 407 | test_must_fail git am <failmail && |
d3a7b8f5 | 408 | git am --skip && |
61e0eb9d | 409 | test_path_is_missing .git/rebase-apply |
d3a7b8f5 SB |
410 | ' |
411 | ||
8ec00d05 SB |
412 | test_expect_success 'am works from stdin in subdirectory' ' |
413 | rm -fr subdir && | |
5d274859 JN |
414 | rm -fr .git/rebase-apply && |
415 | git reset --hard && | |
8ec00d05 SB |
416 | git checkout first && |
417 | ( | |
418 | mkdir -p subdir && | |
419 | cd subdir && | |
420 | git am <../patch1 | |
421 | ) && | |
800f1104 | 422 | git diff --exit-code second |
8ec00d05 SB |
423 | ' |
424 | ||
425 | test_expect_success 'am works from file (relative path given) in subdirectory' ' | |
426 | rm -fr subdir && | |
5d274859 JN |
427 | rm -fr .git/rebase-apply && |
428 | git reset --hard && | |
8ec00d05 SB |
429 | git checkout first && |
430 | ( | |
431 | mkdir -p subdir && | |
432 | cd subdir && | |
433 | git am ../patch1 | |
434 | ) && | |
800f1104 | 435 | git diff --exit-code second |
8ec00d05 SB |
436 | ' |
437 | ||
438 | test_expect_success 'am works from file (absolute path given) in subdirectory' ' | |
439 | rm -fr subdir && | |
5d274859 JN |
440 | rm -fr .git/rebase-apply && |
441 | git reset --hard && | |
8ec00d05 SB |
442 | git checkout first && |
443 | P=$(pwd) && | |
444 | ( | |
445 | mkdir -p subdir && | |
446 | cd subdir && | |
447 | git am "$P/patch1" | |
448 | ) && | |
800f1104 | 449 | git diff --exit-code second |
8ec00d05 SB |
450 | ' |
451 | ||
3f01ad66 | 452 | test_expect_success 'am --committer-date-is-author-date' ' |
5d274859 JN |
453 | rm -fr .git/rebase-apply && |
454 | git reset --hard && | |
3f01ad66 JH |
455 | git checkout first && |
456 | test_tick && | |
457 | git am --committer-date-is-author-date patch1 && | |
9524cf29 | 458 | git cat-file commit HEAD | sed -e "/^\$/q" >head1 && |
800f1104 JN |
459 | sed -ne "/^author /s/.*> //p" head1 >at && |
460 | sed -ne "/^committer /s/.*> //p" head1 >ct && | |
461 | test_cmp at ct | |
3f01ad66 JH |
462 | ' |
463 | ||
464 | test_expect_success 'am without --committer-date-is-author-date' ' | |
5d274859 JN |
465 | rm -fr .git/rebase-apply && |
466 | git reset --hard && | |
3f01ad66 JH |
467 | git checkout first && |
468 | test_tick && | |
469 | git am patch1 && | |
9524cf29 | 470 | git cat-file commit HEAD | sed -e "/^\$/q" >head1 && |
800f1104 JN |
471 | sed -ne "/^author /s/.*> //p" head1 >at && |
472 | sed -ne "/^committer /s/.*> //p" head1 >ct && | |
473 | ! test_cmp at ct | |
3f01ad66 JH |
474 | ' |
475 | ||
a79ec62d NS |
476 | # This checks for +0000 because TZ is set to UTC and that should |
477 | # show up when the current time is used. The date in message is set | |
478 | # by test_tick that uses -0700 timezone; if this feature does not | |
479 | # work, we will see that instead of +0000. | |
480 | test_expect_success 'am --ignore-date' ' | |
5d274859 JN |
481 | rm -fr .git/rebase-apply && |
482 | git reset --hard && | |
a79ec62d NS |
483 | git checkout first && |
484 | test_tick && | |
485 | git am --ignore-date patch1 && | |
9524cf29 | 486 | git cat-file commit HEAD | sed -e "/^\$/q" >head1 && |
800f1104 JN |
487 | sed -ne "/^author /s/.*> //p" head1 >at && |
488 | grep "+0000" at | |
a79ec62d NS |
489 | ' |
490 | ||
f79d4c8a | 491 | test_expect_success 'am into an unborn branch' ' |
800f1104 | 492 | git rev-parse first^{tree} >expected && |
5d274859 JN |
493 | rm -fr .git/rebase-apply && |
494 | git reset --hard && | |
f79d4c8a | 495 | rm -fr subdir && |
800f1104 | 496 | mkdir subdir && |
f79d4c8a NS |
497 | git format-patch --numbered-files -o subdir -1 first && |
498 | ( | |
499 | cd subdir && | |
500 | git init && | |
501 | git am 1 | |
502 | ) && | |
800f1104 JN |
503 | ( |
504 | cd subdir && | |
505 | git rev-parse HEAD^{tree} >../actual | |
f79d4c8a | 506 | ) && |
800f1104 | 507 | test_cmp expected actual |
f79d4c8a NS |
508 | ' |
509 | ||
b3c32ead | 510 | test_expect_success 'am newline in subject' ' |
5d274859 JN |
511 | rm -fr .git/rebase-apply && |
512 | git reset --hard && | |
b3c32ead SB |
513 | git checkout first && |
514 | test_tick && | |
800f1104 JN |
515 | sed -e "s/second/second \\\n foo/" patch1 >patchnl && |
516 | git am <patchnl >output.out 2>&1 && | |
dff1a983 | 517 | test_i18ngrep "^Applying: second \\\n foo$" output.out |
b3c32ead SB |
518 | ' |
519 | ||
0e987a12 | 520 | test_expect_success 'am -q is quiet' ' |
5d274859 JN |
521 | rm -fr .git/rebase-apply && |
522 | git reset --hard && | |
0e987a12 SB |
523 | git checkout first && |
524 | test_tick && | |
800f1104 | 525 | git am -q <patch1 >output.out 2>&1 && |
0e987a12 SB |
526 | ! test -s output.out |
527 | ' | |
528 | ||
f0c5793b JM |
529 | test_expect_success 'am empty-file does not infloop' ' |
530 | rm -fr .git/rebase-apply && | |
531 | git reset --hard && | |
532 | touch empty-file && | |
533 | test_tick && | |
948065a4 | 534 | test_must_fail git am empty-file 2>actual && |
f0c5793b | 535 | echo Patch format detection failed. >expected && |
b1f5b783 | 536 | test_i18ncmp expected actual |
f0c5793b JM |
537 | ' |
538 | ||
d3a7b8f5 | 539 | test_done |