Git 2.46-rc1
[alt-git.git] / t / t4253-am-keep-cr-dos.sh
blob2bcdd9f34fad676af2d0287c16964d2159cbbd5f
1 #!/bin/sh
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
13 . ./test-lib.sh
15 # Three patches which will be added as files with dos line ending.
17 cat >file1 <<\EOF
18 line 1
19 EOF
21 cat >file1a <<\EOF
22 line 1
23 line 4
24 EOF
26 cat >file2 <<\EOF
27 line 1
28 line 2
29 EOF
31 cat >file3 <<\EOF
32 line 1
33 line 2
34 line 3
35 EOF
37 test_expect_success 'setup repository with dos files' '
38 append_cr <file1 >file &&
39 git add file &&
40 git commit -m Initial &&
41 git tag 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 &&
52 git am --abort &&
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 &&
76 git am --abort &&
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 &&
87 git add 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 &&
95 cp -f file1 file &&
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
102 test_done