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
12 TEST_PASSES_SANITIZE_LEAK
=true
15 # Three patches which will be added as files with dos line ending.
37 test_expect_success
'setup repository with dos files' '
38 append_cr <file1 >file &&
40 git commit -m Initial &&
42 append_cr <file2 >file &&
43 git commit -a -m Second &&
44 append_cr <file3 >file &&
45 git commit -a -m Third
48 test_expect_success
'am with dos files without --keep-cr' '
49 git checkout -b dosfiles initial &&
50 git format-patch -k initial..main &&
51 test_must_fail git am -k -3 000*.patch &&
53 rm -rf .git/rebase-apply 000*.patch
56 test_expect_success
'am with dos files with --keep-cr' '
57 git checkout -b dosfiles-keep-cr initial &&
58 git format-patch -k --stdout initial..main >output &&
59 git am --keep-cr -k -3 output &&
60 git diff --exit-code main
63 test_expect_success
'am with dos files config am.keepcr' '
64 git config am.keepcr 1 &&
65 git checkout -b dosfiles-conf-keepcr initial &&
66 git format-patch -k --stdout initial..main >output &&
67 git am -k -3 output &&
68 git diff --exit-code main
71 test_expect_success
'am with dos files config am.keepcr overridden by --no-keep-cr' '
72 git config am.keepcr 1 &&
73 git checkout -b dosfiles-conf-keepcr-override initial &&
74 git format-patch -k initial..main &&
75 test_must_fail git am -k -3 --no-keep-cr 000*.patch &&
77 rm -rf .git/rebase-apply 000*.patch
80 test_expect_success
'am with dos files with --keep-cr continue' '
81 git checkout -b dosfiles-keep-cr-continue initial &&
82 git format-patch -k initial..main &&
83 append_cr <file1a >file &&
84 git commit -m "different patch" file &&
85 test_must_fail git am --keep-cr -k -3 000*.patch &&
86 append_cr <file2 >file &&
88 git am -3 --resolved &&
89 git diff --exit-code main
92 test_expect_success
'am with unix files config am.keepcr overridden by --no-keep-cr' '
93 git config am.keepcr 1 &&
94 git checkout -b unixfiles-conf-keepcr-override initial &&
96 git commit -m "line ending to unix" file &&
97 git format-patch -k initial..main &&
98 git am -k -3 --no-keep-cr 000*.patch &&
99 git diff --exit-code -w main