read-tree: narrow scope of index expansion for '--prefix'
[alt-git.git] / t / t4253-am-keep-cr-dos.sh
blob0ee69d2a0c4e0d21c14290f166eebd563f81be7c
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-lib.sh
14 # Three patches which will be added as files with dos line ending.
16 cat >file1 <<\EOF
17 line 1
18 EOF
20 cat >file1a <<\EOF
21 line 1
22 line 4
23 EOF
25 cat >file2 <<\EOF
26 line 1
27 line 2
28 EOF
30 cat >file3 <<\EOF
31 line 1
32 line 2
33 line 3
34 EOF
36 test_expect_success 'setup repository with dos files' '
37 append_cr <file1 >file &&
38 git add file &&
39 git commit -m Initial &&
40 git tag 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 &&
51 git am --abort &&
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 &&
75 git am --abort &&
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 &&
86 git add 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 &&
94 cp -f file1 file &&
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
101 test_done