3 test_description
='git am running'
7 test_expect_success
'setup: messages' '
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.
20 qz_to_tab_space <<-\EOF >>msg &&
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
29 Lorem ipsum dolor sit amet,
30 consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
31 laoreet dolore magna aliquam erat volutpat.
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.
45 cat >failmail <<-\EOF &&
46 From foo@example.com Fri May 23 10:43:49 2008
49 Subject: Re: [RFC/PATCH] git-foo.sh
50 Date: Fri, 23 May 2008 05:23:42 +0200
52 Sometimes we have to find out that there'\''s nothing left.
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>
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.
70 cat >scissors-msg <<-\EOF &&
71 Test git-am with scissors line
73 This line should be included in the commit message.
76 cat - scissors-msg >no-scissors-msg <<-\EOF &&
77 This line should not be included in the commit message with --scissors enabled.
79 - - >8 - - remove everything above this line - - >8 - -
83 signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
86 test_expect_success setup
'
90 git commit -m first &&
96 git commit -s -F msg &&
99 git format-patch --stdout first >patch1 &&
101 echo "Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru>" &&
102 echo "X-Fake-Field: Line One" &&
103 echo "X-Fake-Field: Line Two" &&
104 echo "X-Fake-Field: Line Three" &&
105 git format-patch --stdout first | sed -e "1d"
108 echo "X-Fake-Field: Line One" &&
109 echo "X-Fake-Field: Line Two" &&
110 echo "X-Fake-Field: Line Three" &&
111 git format-patch --stdout first | sed -e "1d"
112 } | append_cr >patch1-crlf.eml &&
115 echo "X-Fake-Field: Line One" &&
116 echo "X-Fake-Field: Line Two" &&
117 echo "X-Fake-Field: Line Three" &&
118 git format-patch --stdout first | sed -e "1d"
123 echo "From: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" &&
124 echo "Date: $GIT_AUTHOR_DATE" &&
128 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
130 git diff-tree --no-commit-id --stat -p second
131 } >patch1-stgit.eml &&
132 mkdir stgit-series &&
133 cp patch1-stgit.eml stgit-series/patch &&
135 echo "# This series applies on GIT commit $(git rev-parse first)" &&
137 } >stgit-series/series &&
139 echo "# HG changeset patch" &&
140 echo "# User $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" &&
141 echo "# Date $test_tick 25200" &&
142 echo "# $(git show --pretty="%aD" -s second)" &&
143 echo "# Node ID $_z40" &&
144 echo "# Parent $_z40" &&
147 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
149 git diff-tree --no-commit-id -p second
153 echo scissors-file >scissors-file &&
154 git add scissors-file &&
155 git commit -F scissors-msg &&
157 git format-patch --stdout scissors^ >scissors-patch.eml &&
158 git reset --hard HEAD^ &&
160 echo no-scissors-file >no-scissors-file &&
161 git add no-scissors-file &&
162 git commit -F no-scissors-msg &&
163 git tag no-scissors &&
164 git format-patch --stdout no-scissors^ >no-scissors-patch.eml &&
165 git reset --hard HEAD^ &&
167 sed -n -e "3,\$p" msg >file &&
170 git commit -m third &&
172 git format-patch --stdout first >patch2 &&
174 git checkout -b lorem &&
175 sed -n -e "11,\$p" msg >file &&
176 head -n 9 msg >>file &&
178 git commit -a -m "moved stuff" &&
180 echo goodbye >another &&
183 git commit -m "added another file" &&
185 git format-patch --stdout master >lorem-move.patch &&
186 git format-patch --no-prefix --stdout master >lorem-zero.patch &&
188 git checkout -b rename &&
189 git mv file renamed &&
190 git commit -m "renamed a file" &&
192 git format-patch -M --stdout lorem >rename.patch &&
194 git reset --soft lorem^ &&
195 git commit -m "renamed a file and added another" &&
197 git format-patch -M --stdout lorem^ >rename-add.patch &&
200 sane_unset test_tick &&
204 test_expect_success
'am applies patch correctly' '
205 rm -fr .git/rebase-apply &&
207 git checkout first &&
210 test_path_is_missing .git/rebase-apply &&
211 git diff --exit-code second &&
212 test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
213 test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
216 test_expect_success
'am fails if index is dirty' '
217 test_when_finished "rm -f dirtyfile" &&
218 rm -fr .git/rebase-apply &&
220 git checkout first &&
221 echo dirtyfile >dirtyfile &&
223 test_must_fail git am patch1 &&
224 test_path_is_dir .git/rebase-apply &&
225 test_cmp_rev first HEAD
228 test_expect_success
'am applies patch e-mail not in a mbox' '
229 rm -fr .git/rebase-apply &&
231 git checkout first &&
233 test_path_is_missing .git/rebase-apply &&
234 git diff --exit-code second &&
235 test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
236 test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
239 test_expect_success
'am applies patch e-mail not in a mbox with CRLF' '
240 rm -fr .git/rebase-apply &&
242 git checkout first &&
243 git am patch1-crlf.eml &&
244 test_path_is_missing .git/rebase-apply &&
245 git diff --exit-code second &&
246 test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
247 test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
250 test_expect_success
'am applies patch e-mail with preceding whitespace' '
251 rm -fr .git/rebase-apply &&
253 git checkout first &&
254 git am patch1-ws.eml &&
255 test_path_is_missing .git/rebase-apply &&
256 git diff --exit-code second &&
257 test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
258 test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
261 test_expect_success
'am applies stgit patch' '
262 rm -fr .git/rebase-apply &&
263 git checkout -f first &&
264 git am patch1-stgit.eml &&
265 test_path_is_missing .git/rebase-apply &&
266 git diff --exit-code second &&
267 test_cmp_rev second HEAD &&
268 test_cmp_rev second^ HEAD^
271 test_expect_success
'am --patch-format=stgit applies stgit patch' '
272 rm -fr .git/rebase-apply &&
273 git checkout -f first &&
274 git am --patch-format=stgit <patch1-stgit.eml &&
275 test_path_is_missing .git/rebase-apply &&
276 git diff --exit-code second &&
277 test_cmp_rev second HEAD &&
278 test_cmp_rev second^ HEAD^
281 test_expect_success
'am applies stgit series' '
282 rm -fr .git/rebase-apply &&
283 git checkout -f first &&
284 git am stgit-series/series &&
285 test_path_is_missing .git/rebase-apply &&
286 git diff --exit-code second &&
287 test_cmp_rev second HEAD &&
288 test_cmp_rev second^ HEAD^
291 test_expect_success
'am applies hg patch' '
292 rm -fr .git/rebase-apply &&
293 git checkout -f first &&
294 git am patch1-hg.eml &&
295 test_path_is_missing .git/rebase-apply &&
296 git diff --exit-code second &&
297 test_cmp_rev second HEAD &&
298 test_cmp_rev second^ HEAD^
301 test_expect_success
'am --patch-format=hg applies hg patch' '
302 rm -fr .git/rebase-apply &&
303 git checkout -f first &&
304 git am --patch-format=hg <patch1-hg.eml &&
305 test_path_is_missing .git/rebase-apply &&
306 git diff --exit-code second &&
307 test_cmp_rev second HEAD &&
308 test_cmp_rev second^ HEAD^
311 test_expect_success
'am with applypatch-msg hook' '
312 test_when_finished "rm -f .git/hooks/applypatch-msg" &&
313 rm -fr .git/rebase-apply &&
315 git checkout first &&
316 mkdir -p .git/hooks &&
317 write_script .git/hooks/applypatch-msg <<-\EOF &&
318 cat "$1" >actual-msg &&
319 echo hook-message >"$1"
322 test_path_is_missing .git/rebase-apply &&
323 git diff --exit-code second &&
324 echo hook-message >expected &&
325 git log -1 --format=format:%B >actual &&
326 test_cmp expected actual &&
327 git log -1 --format=format:%B second >expected &&
328 test_cmp expected actual-msg
331 test_expect_success
'am with failing applypatch-msg hook' '
332 test_when_finished "rm -f .git/hooks/applypatch-msg" &&
333 rm -fr .git/rebase-apply &&
335 git checkout first &&
336 mkdir -p .git/hooks &&
337 write_script .git/hooks/applypatch-msg <<-\EOF &&
340 test_must_fail git am patch1 &&
341 test_path_is_dir .git/rebase-apply &&
342 git diff --exit-code first &&
343 test_cmp_rev first HEAD
346 test_expect_success
'am with pre-applypatch hook' '
347 test_when_finished "rm -f .git/hooks/pre-applypatch" &&
348 rm -fr .git/rebase-apply &&
350 git checkout first &&
351 mkdir -p .git/hooks &&
352 write_script .git/hooks/pre-applypatch <<-\EOF &&
353 git diff first >diff.actual
357 test_path_is_missing .git/rebase-apply &&
358 git diff --exit-code second &&
359 test_cmp_rev second HEAD &&
360 git diff first..second >diff.expected &&
361 test_cmp diff.expected diff.actual
364 test_expect_success
'am with failing pre-applypatch hook' '
365 test_when_finished "rm -f .git/hooks/pre-applypatch" &&
366 rm -fr .git/rebase-apply &&
368 git checkout first &&
369 mkdir -p .git/hooks &&
370 write_script .git/hooks/pre-applypatch <<-\EOF &&
373 test_must_fail git am patch1 &&
374 test_path_is_dir .git/rebase-apply &&
375 git diff --exit-code second &&
376 test_cmp_rev first HEAD
379 test_expect_success
'am with post-applypatch hook' '
380 test_when_finished "rm -f .git/hooks/post-applypatch" &&
381 rm -fr .git/rebase-apply &&
383 git checkout first &&
384 mkdir -p .git/hooks &&
385 write_script .git/hooks/post-applypatch <<-\EOF &&
386 git rev-parse HEAD >head.actual
387 git diff second >diff.actual
391 test_path_is_missing .git/rebase-apply &&
392 test_cmp_rev second HEAD &&
393 git rev-parse second >head.expected &&
394 test_cmp head.expected head.actual &&
395 git diff second >diff.expected &&
396 test_cmp diff.expected diff.actual
399 test_expect_success
'am with failing post-applypatch hook' '
400 test_when_finished "rm -f .git/hooks/post-applypatch" &&
401 rm -fr .git/rebase-apply &&
403 git checkout first &&
404 mkdir -p .git/hooks &&
405 write_script .git/hooks/post-applypatch <<-\EOF &&
406 git rev-parse HEAD >head.actual
410 test_path_is_missing .git/rebase-apply &&
411 git diff --exit-code second &&
412 test_cmp_rev second HEAD &&
413 git rev-parse second >head.expected &&
414 test_cmp head.expected head.actual
417 test_expect_success
'am --scissors cuts the message at the scissors line' '
418 rm -fr .git/rebase-apply &&
420 git checkout second &&
421 git am --scissors scissors-patch.eml &&
422 test_path_is_missing .git/rebase-apply &&
423 git diff --exit-code scissors &&
424 test_cmp_rev scissors HEAD
427 test_expect_success
'am --no-scissors overrides mailinfo.scissors' '
428 rm -fr .git/rebase-apply &&
430 git checkout second &&
431 test_config mailinfo.scissors true &&
432 git am --no-scissors no-scissors-patch.eml &&
433 test_path_is_missing .git/rebase-apply &&
434 git diff --exit-code no-scissors &&
435 test_cmp_rev no-scissors HEAD
438 test_expect_success
'setup: new author and committer' '
439 GIT_AUTHOR_NAME="Another Thor" &&
440 GIT_AUTHOR_EMAIL="a.thor@example.com" &&
441 GIT_COMMITTER_NAME="Co M Miter" &&
442 GIT_COMMITTER_EMAIL="c.miter@example.com" &&
443 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
447 a
=$
(git cat-file commit
"$2" |
grep "^$1 ") &&
448 b
=$
(git cat-file commit
"$3" |
grep "^$1 ") &&
452 test_expect_success
'am changes committer and keeps author' '
454 rm -fr .git/rebase-apply &&
456 git checkout first &&
458 test_path_is_missing .git/rebase-apply &&
459 test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" &&
460 git diff --exit-code master..HEAD &&
461 git diff --exit-code master^..HEAD^ &&
462 compare author master HEAD &&
463 compare author master^ HEAD^ &&
464 test "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" = \
465 "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)"
468 test_expect_success
'am --signoff adds Signed-off-by: line' '
469 rm -fr .git/rebase-apply &&
471 git checkout -b master2 first &&
472 git am --signoff <patch2 &&
473 printf "%s\n" "$signoff" >expected &&
474 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected &&
475 git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
476 test_cmp expected actual &&
477 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
478 git cat-file commit HEAD | grep "Signed-off-by:" >actual &&
479 test_cmp expected actual
482 test_expect_success
'am stays in branch' '
483 echo refs/heads/master2 >expected &&
484 git symbolic-ref HEAD >actual &&
485 test_cmp expected actual
488 test_expect_success
'am --signoff does not add Signed-off-by: line if already there' '
489 git format-patch --stdout HEAD^ >patch3 &&
490 sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2] [foo," patch3 >patch4 &&
491 rm -fr .git/rebase-apply &&
493 git checkout HEAD^ &&
494 git am --signoff patch4 &&
495 git cat-file commit HEAD >actual &&
496 test $(grep -c "^Signed-off-by:" actual) -eq 1
499 test_expect_success
'am without --keep removes Re: and [PATCH] stuff' '
500 git rev-parse HEAD >expected &&
501 git rev-parse master2 >actual &&
502 test_cmp expected actual
505 test_expect_success
'am --keep really keeps the subject' '
506 rm -fr .git/rebase-apply &&
508 git checkout HEAD^ &&
509 git am --keep patch4 &&
510 test_path_is_missing .git/rebase-apply &&
511 git cat-file commit HEAD >actual &&
512 grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
515 test_expect_success
'am --keep-non-patch really keeps the non-patch part' '
516 rm -fr .git/rebase-apply &&
518 git checkout HEAD^ &&
519 git am --keep-non-patch patch4 &&
520 test_path_is_missing .git/rebase-apply &&
521 git cat-file commit HEAD >actual &&
522 grep "^\[foo\] third" actual
525 test_expect_success
'setup am -3' '
526 rm -fr .git/rebase-apply &&
528 git checkout -b base3way master2 &&
529 sed -n -e "3,\$p" msg >file &&
530 head -n 9 msg >>file &&
533 git commit -m "copied stuff"
536 test_expect_success
'am -3 falls back to 3-way merge' '
537 rm -fr .git/rebase-apply &&
539 git checkout -b lorem2 base3way &&
540 git am -3 lorem-move.patch &&
541 test_path_is_missing .git/rebase-apply &&
542 git diff --exit-code lorem
545 test_expect_success
'am -3 -p0 can read --no-prefix patch' '
546 rm -fr .git/rebase-apply &&
548 git checkout -b lorem3 base3way &&
549 git am -3 -p0 lorem-zero.patch &&
550 test_path_is_missing .git/rebase-apply &&
551 git diff --exit-code lorem
554 test_expect_success
'am with config am.threeWay falls back to 3-way merge' '
555 rm -fr .git/rebase-apply &&
557 git checkout -b lorem4 base3way &&
558 test_config am.threeWay 1 &&
559 git am lorem-move.patch &&
560 test_path_is_missing .git/rebase-apply &&
561 git diff --exit-code lorem
564 test_expect_success
'am with config am.threeWay overridden by --no-3way' '
565 rm -fr .git/rebase-apply &&
567 git checkout -b lorem5 base3way &&
568 test_config am.threeWay 1 &&
569 test_must_fail git am --no-3way lorem-move.patch &&
570 test_path_is_dir .git/rebase-apply
573 test_expect_success
'am can rename a file' '
574 grep "^rename from" rename.patch &&
575 rm -fr .git/rebase-apply &&
577 git checkout lorem^0 &&
578 git am rename.patch &&
579 test_path_is_missing .git/rebase-apply &&
580 git update-index --refresh &&
581 git diff --exit-code rename
584 test_expect_success
'am -3 can rename a file' '
585 grep "^rename from" rename.patch &&
586 rm -fr .git/rebase-apply &&
588 git checkout lorem^0 &&
589 git am -3 rename.patch &&
590 test_path_is_missing .git/rebase-apply &&
591 git update-index --refresh &&
592 git diff --exit-code rename
595 test_expect_success
'am -3 can rename a file after falling back to 3-way merge' '
596 grep "^rename from" rename-add.patch &&
597 rm -fr .git/rebase-apply &&
599 git checkout lorem^0 &&
600 git am -3 rename-add.patch &&
601 test_path_is_missing .git/rebase-apply &&
602 git update-index --refresh &&
603 git diff --exit-code rename
606 test_expect_success
'am -3 -q is quiet' '
607 rm -fr .git/rebase-apply &&
608 git checkout -f lorem2 &&
609 git reset base3way --hard &&
610 git am -3 -q lorem-move.patch >output.out 2>&1 &&
614 test_expect_success
'am pauses on conflict' '
615 rm -fr .git/rebase-apply &&
617 git checkout lorem2^^ &&
618 test_must_fail git am lorem-move.patch &&
619 test -d .git/rebase-apply
622 test_expect_success
'am --skip works' '
623 echo goodbye >expected &&
625 test_path_is_missing .git/rebase-apply &&
626 git diff --exit-code lorem2^^ -- file &&
627 test_cmp expected another
630 test_expect_success
'am --abort removes a stray directory' '
631 mkdir .git/rebase-apply &&
633 test_path_is_missing .git/rebase-apply
636 test_expect_success
'am refuses patches when paused' '
637 rm -fr .git/rebase-apply &&
639 git checkout lorem2^^ &&
641 test_must_fail git am lorem-move.patch &&
642 test_path_is_dir .git/rebase-apply &&
643 test_cmp_rev lorem2^^ HEAD &&
645 test_must_fail git am <lorem-move.patch &&
646 test_path_is_dir .git/rebase-apply &&
647 test_cmp_rev lorem2^^ HEAD
650 test_expect_success
'am --resolved works' '
651 echo goodbye >expected &&
652 rm -fr .git/rebase-apply &&
654 git checkout lorem2^^ &&
655 test_must_fail git am lorem-move.patch &&
656 test -d .git/rebase-apply &&
657 echo resolved >>file &&
660 test_path_is_missing .git/rebase-apply &&
661 test_cmp expected another
664 test_expect_success
'am --resolved fails if index has no changes' '
665 rm -fr .git/rebase-apply &&
667 git checkout lorem2^^ &&
668 test_must_fail git am lorem-move.patch &&
669 test_path_is_dir .git/rebase-apply &&
670 test_cmp_rev lorem2^^ HEAD &&
671 test_must_fail git am --resolved &&
672 test_path_is_dir .git/rebase-apply &&
673 test_cmp_rev lorem2^^ HEAD
676 test_expect_success
'am --resolved fails if index has unmerged entries' '
677 rm -fr .git/rebase-apply &&
679 git checkout second &&
680 test_must_fail git am -3 lorem-move.patch &&
681 test_path_is_dir .git/rebase-apply &&
682 test_cmp_rev second HEAD &&
683 test_must_fail git am --resolved >err &&
684 test_path_is_dir .git/rebase-apply &&
685 test_cmp_rev second HEAD &&
686 test_i18ngrep "still have unmerged paths" err
689 test_expect_success
'am takes patches from a Pine mailbox' '
690 rm -fr .git/rebase-apply &&
692 git checkout first &&
693 cat pine patch1 | git am &&
694 test_path_is_missing .git/rebase-apply &&
695 git diff --exit-code master^..HEAD
698 test_expect_success
'am fails on mail without patch' '
699 rm -fr .git/rebase-apply &&
701 test_must_fail git am <failmail &&
703 test_path_is_missing .git/rebase-apply
706 test_expect_success
'am fails on empty patch' '
707 rm -fr .git/rebase-apply &&
709 echo "---" >>failmail &&
710 test_must_fail git am <failmail &&
712 test_path_is_missing .git/rebase-apply
715 test_expect_success
'am works from stdin in subdirectory' '
717 rm -fr .git/rebase-apply &&
719 git checkout first &&
725 git diff --exit-code second
728 test_expect_success
'am works from file (relative path given) in subdirectory' '
730 rm -fr .git/rebase-apply &&
732 git checkout first &&
738 git diff --exit-code second
741 test_expect_success
'am works from file (absolute path given) in subdirectory' '
743 rm -fr .git/rebase-apply &&
745 git checkout first &&
752 git diff --exit-code second
755 test_expect_success
'am --committer-date-is-author-date' '
756 rm -fr .git/rebase-apply &&
758 git checkout first &&
760 git am --committer-date-is-author-date patch1 &&
761 git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
762 sed -ne "/^author /s/.*> //p" head1 >at &&
763 sed -ne "/^committer /s/.*> //p" head1 >ct &&
767 test_expect_success
'am without --committer-date-is-author-date' '
768 rm -fr .git/rebase-apply &&
770 git checkout first &&
773 git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
774 sed -ne "/^author /s/.*> //p" head1 >at &&
775 sed -ne "/^committer /s/.*> //p" head1 >ct &&
779 # This checks for +0000 because TZ is set to UTC and that should
780 # show up when the current time is used. The date in message is set
781 # by test_tick that uses -0700 timezone; if this feature does not
782 # work, we will see that instead of +0000.
783 test_expect_success
'am --ignore-date' '
784 rm -fr .git/rebase-apply &&
786 git checkout first &&
788 git am --ignore-date patch1 &&
789 git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
790 sed -ne "/^author /s/.*> //p" head1 >at &&
794 test_expect_success
'am into an unborn branch' '
795 git rev-parse first^{tree} >expected &&
796 rm -fr .git/rebase-apply &&
800 git format-patch --numbered-files -o subdir -1 first &&
808 git rev-parse HEAD^{tree} >../actual
810 test_cmp expected actual
813 test_expect_success
'am newline in subject' '
814 rm -fr .git/rebase-apply &&
816 git checkout first &&
818 sed -e "s/second/second \\\n foo/" patch1 >patchnl &&
819 git am <patchnl >output.out 2>&1 &&
820 test_i18ngrep "^Applying: second \\\n foo$" output.out
823 test_expect_success
'am -q is quiet' '
824 rm -fr .git/rebase-apply &&
826 git checkout first &&
828 git am -q <patch1 >output.out 2>&1 &&
832 test_expect_success
'am empty-file does not infloop' '
833 rm -fr .git/rebase-apply &&
837 test_must_fail git am empty-file 2>actual &&
838 echo Patch format detection failed. >expected &&
839 test_i18ncmp expected actual
842 test_expect_success
'am --message-id really adds the message id' '
843 rm -fr .git/rebase-apply &&
845 git checkout HEAD^ &&
846 git am --message-id patch1.eml &&
847 test_path_is_missing .git/rebase-apply &&
848 git cat-file commit HEAD | tail -n1 >actual &&
849 grep Message-Id patch1.eml >expected &&
850 test_cmp expected actual
853 test_expect_success
'am.messageid really adds the message id' '
854 rm -fr .git/rebase-apply &&
856 git checkout HEAD^ &&
857 test_config am.messageid true &&
859 test_path_is_missing .git/rebase-apply &&
860 git cat-file commit HEAD | tail -n1 >actual &&
861 grep Message-Id patch1.eml >expected &&
862 test_cmp expected actual
865 test_expect_success
'am --message-id -s signs off after the message id' '
866 rm -fr .git/rebase-apply &&
868 git checkout HEAD^ &&
869 git am -s --message-id patch1.eml &&
870 test_path_is_missing .git/rebase-apply &&
871 git cat-file commit HEAD | tail -n2 | head -n1 >actual &&
872 grep Message-Id patch1.eml >expected &&
873 test_cmp expected actual