]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4253-am-keep-cr-dos.sh
The sixth batch
[thirdparty/git.git] / t / t4253-am-keep-cr-dos.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Stefan-W. Hahn
4 #
5
6 test_description='git-am mbox with dos line ending.
7
8 '
9 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11
12 . ./test-lib.sh
13
14 # Three patches which will be added as files with dos line ending.
15
16 cat >file1 <<\EOF
17 line 1
18 EOF
19
20 cat >file1a <<\EOF
21 line 1
22 line 4
23 EOF
24
25 cat >file2 <<\EOF
26 line 1
27 line 2
28 EOF
29
30 cat >file3 <<\EOF
31 line 1
32 line 2
33 line 3
34 EOF
35
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
45 '
46
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
53 '
54
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
60 '
61
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
68 '
69
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
77 '
78
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
89 '
90
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
99 '
100
101 test_done