exec_cmd: remove unused extern
[git/dscho.git] / t / t6038-merge-text-auto.sh
blob52d0dc4bb8f80393c79935f9c951b5323287e41c
1 #!/bin/sh
3 test_description='CRLF merge conflict across text=auto change
5 * [master] remove .gitattributes
6 ! [side] add line from b
7 --
8 + [side] add line from b
9 * [master] remove .gitattributes
10 * [master^] add line from a
11 * [master~2] normalize file
12 *+ [side^] Initial
15 . ./test-lib.sh
17 test_expect_success setup '
18 git config core.autocrlf false &&
20 echo first line | append_cr >file &&
21 echo first line >control_file &&
22 echo only line >inert_file &&
24 git add file control_file inert_file &&
25 test_tick &&
26 git commit -m "Initial" &&
27 git tag initial &&
28 git branch side &&
30 echo "* text=auto" >.gitattributes &&
31 touch file &&
32 git add .gitattributes file &&
33 test_tick &&
34 git commit -m "normalize file" &&
36 echo same line | append_cr >>file &&
37 echo same line >>control_file &&
38 git add file control_file &&
39 test_tick &&
40 git commit -m "add line from a" &&
41 git tag a &&
43 git rm .gitattributes &&
44 rm file &&
45 git checkout file &&
46 test_tick &&
47 git commit -m "remove .gitattributes" &&
48 git tag c &&
50 git checkout side &&
51 echo same line | append_cr >>file &&
52 echo same line >>control_file &&
53 git add file control_file &&
54 test_tick &&
55 git commit -m "add line from b" &&
56 git tag b &&
58 git checkout master
61 test_expect_success 'set up fuzz_conflict() helper' '
62 fuzz_conflict() {
63 sed -e "s/^\([<>=]......\) .*/\1/" "$@"
67 test_expect_success 'Merge after setting text=auto' '
68 cat <<-\EOF >expected &&
69 first line
70 same line
71 EOF
73 git config merge.renormalize true &&
74 git rm -fr . &&
75 rm -f .gitattributes &&
76 git reset --hard a &&
77 git merge b &&
78 test_cmp expected file
81 test_expect_success 'Merge addition of text=auto' '
82 cat <<-\EOF >expected &&
83 first line
84 same line
85 EOF
87 git config merge.renormalize true &&
88 git rm -fr . &&
89 rm -f .gitattributes &&
90 git reset --hard b &&
91 git merge a &&
92 test_cmp expected file
95 test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
96 q_to_cr <<-\EOF >expected &&
97 <<<<<<<
98 first line
99 same line
100 =======
101 first lineQ
102 same lineQ
103 >>>>>>>
106 git config merge.renormalize false &&
107 rm -f .gitattributes &&
108 git reset --hard a &&
109 test_must_fail git merge b &&
110 fuzz_conflict file >file.fuzzy &&
111 test_cmp expected file.fuzzy
114 test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
115 q_to_cr <<-\EOF >expected &&
116 <<<<<<<
117 first lineQ
118 same lineQ
119 =======
120 first line
121 same line
122 >>>>>>>
125 git config merge.renormalize false &&
126 rm -f .gitattributes &&
127 git reset --hard b &&
128 test_must_fail git merge a &&
129 fuzz_conflict file >file.fuzzy &&
130 test_cmp expected file.fuzzy
133 test_expect_failure 'checkout -m after setting text=auto' '
134 cat <<-\EOF >expected &&
135 first line
136 same line
139 git config merge.renormalize true &&
140 git rm -fr . &&
141 rm -f .gitattributes &&
142 git reset --hard initial &&
143 git checkout a -- . &&
144 git checkout -m b &&
145 test_cmp expected file
148 test_expect_failure 'checkout -m addition of text=auto' '
149 cat <<-\EOF >expected &&
150 first line
151 same line
154 git config merge.renormalize true &&
155 git rm -fr . &&
156 rm -f .gitattributes file &&
157 git reset --hard initial &&
158 git checkout b -- . &&
159 git checkout -m a &&
160 test_cmp expected file
163 test_expect_failure 'cherry-pick patch from after text=auto was added' '
164 append_cr <<-\EOF >expected &&
165 first line
166 same line
169 git config merge.renormalize true &&
170 git rm -fr . &&
171 git reset --hard b &&
172 test_must_fail git cherry-pick a >err 2>&1 &&
173 grep "[Nn]othing added" err &&
174 test_cmp expected file
177 test_expect_success 'Test delete/normalize conflict' '
178 git checkout -f side &&
179 git rm -fr . &&
180 rm -f .gitattributes &&
181 git reset --hard initial &&
182 git rm file &&
183 git commit -m "remove file" &&
184 git checkout master &&
185 git reset --hard a^ &&
186 git merge side
189 test_done