3 # Copyright (c) 2010 Stefan-W. Hahn
6 test_description
='git-am mbox with dos line ending.
9 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
14 # Three patches which will be added as files with dos line ending.
36 test_expect_success
'setup repository with dos files' '
37 append_cr <file1 >file &&
39 git commit -m Initial &&
41 append_cr <file2 >file &&
42 git commit -a -m Second &&
43 append_cr <file3 >file &&
44 git commit -a -m Third
47 test_expect_success
'am with dos files without --keep-cr' '
48 git checkout -b dosfiles initial &&
49 git format-patch -k initial..main &&
50 test_must_fail git am -k -3 000*.patch &&
52 rm -rf .git/rebase-apply 000*.patch
55 test_expect_success
'am with dos files with --keep-cr' '
56 git checkout -b dosfiles-keep-cr initial &&
57 git format-patch -k --stdout initial..main >output &&
58 git am --keep-cr -k -3 output &&
59 git diff --exit-code main
62 test_expect_success
'am with dos files config am.keepcr' '
63 git config am.keepcr 1 &&
64 git checkout -b dosfiles-conf-keepcr initial &&
65 git format-patch -k --stdout initial..main >output &&
66 git am -k -3 output &&
67 git diff --exit-code main
70 test_expect_success
'am with dos files config am.keepcr overridden by --no-keep-cr' '
71 git config am.keepcr 1 &&
72 git checkout -b dosfiles-conf-keepcr-override initial &&
73 git format-patch -k initial..main &&
74 test_must_fail git am -k -3 --no-keep-cr 000*.patch &&
76 rm -rf .git/rebase-apply 000*.patch
79 test_expect_success
'am with dos files with --keep-cr continue' '
80 git checkout -b dosfiles-keep-cr-continue initial &&
81 git format-patch -k initial..main &&
82 append_cr <file1a >file &&
83 git commit -m "different patch" file &&
84 test_must_fail git am --keep-cr -k -3 000*.patch &&
85 append_cr <file2 >file &&
87 git am -3 --resolved &&
88 git diff --exit-code main
91 test_expect_success
'am with unix files config am.keepcr overridden by --no-keep-cr' '
92 git config am.keepcr 1 &&
93 git checkout -b unixfiles-conf-keepcr-override initial &&
95 git commit -m "line ending to unix" file &&
96 git format-patch -k initial..main &&
97 git am -k -3 --no-keep-cr 000*.patch &&
98 git diff --exit-code -w main