Merge branch 'jk/mailmap-from-blob'
[git/gitweb.git] / t / t6038-merge-text-auto.sh
blobd9c2d386ddf8caff4b87fa457c23757f76c293c7
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_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b
19 test_expect_success setup '
20 git config core.autocrlf false &&
22 echo first line | append_cr >file &&
23 echo first line >control_file &&
24 echo only line >inert_file &&
26 git add file control_file inert_file &&
27 test_tick &&
28 git commit -m "Initial" &&
29 git tag initial &&
30 git branch side &&
32 echo "* text=auto" >.gitattributes &&
33 touch file &&
34 git add .gitattributes file &&
35 test_tick &&
36 git commit -m "normalize file" &&
38 echo same line | append_cr >>file &&
39 echo same line >>control_file &&
40 git add file control_file &&
41 test_tick &&
42 git commit -m "add line from a" &&
43 git tag a &&
45 git rm .gitattributes &&
46 rm file &&
47 git checkout file &&
48 test_tick &&
49 git commit -m "remove .gitattributes" &&
50 git tag c &&
52 git checkout side &&
53 echo same line | append_cr >>file &&
54 echo same line >>control_file &&
55 git add file control_file &&
56 test_tick &&
57 git commit -m "add line from b" &&
58 git tag b &&
60 git checkout master
63 test_expect_success 'set up fuzz_conflict() helper' '
64 fuzz_conflict() {
65 sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@"
69 test_expect_success 'Merge after setting text=auto' '
70 cat <<-\EOF >expected &&
71 first line
72 same line
73 EOF
75 git config merge.renormalize true &&
76 git rm -fr . &&
77 rm -f .gitattributes &&
78 git reset --hard a &&
79 git merge b &&
80 test_cmp expected file
83 test_expect_success 'Merge addition of text=auto' '
84 cat <<-\EOF >expected &&
85 first line
86 same line
87 EOF
89 git config merge.renormalize true &&
90 git rm -fr . &&
91 rm -f .gitattributes &&
92 git reset --hard b &&
93 git merge a &&
94 test_cmp expected file
97 test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
98 q_to_cr <<-\EOF >expected &&
99 <<<<<<<
100 first line
101 same line
102 =======
103 first lineQ
104 same lineQ
105 >>>>>>>
108 git config merge.renormalize false &&
109 rm -f .gitattributes &&
110 git reset --hard a &&
111 test_must_fail git merge b &&
112 fuzz_conflict file >file.fuzzy &&
113 test_cmp expected file.fuzzy
116 test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
117 q_to_cr <<-\EOF >expected &&
118 <<<<<<<
119 first lineQ
120 same lineQ
121 =======
122 first line
123 same line
124 >>>>>>>
127 git config merge.renormalize false &&
128 rm -f .gitattributes &&
129 git reset --hard b &&
130 test_must_fail git merge a &&
131 fuzz_conflict file >file.fuzzy &&
132 test_cmp expected file.fuzzy
135 test_expect_failure 'checkout -m after setting text=auto' '
136 cat <<-\EOF >expected &&
137 first line
138 same line
141 git config merge.renormalize true &&
142 git rm -fr . &&
143 rm -f .gitattributes &&
144 git reset --hard initial &&
145 git checkout a -- . &&
146 git checkout -m b &&
147 test_cmp expected file
150 test_expect_failure 'checkout -m addition of text=auto' '
151 cat <<-\EOF >expected &&
152 first line
153 same line
156 git config merge.renormalize true &&
157 git rm -fr . &&
158 rm -f .gitattributes file &&
159 git reset --hard initial &&
160 git checkout b -- . &&
161 git checkout -m a &&
162 test_cmp expected file
165 test_expect_failure 'cherry-pick patch from after text=auto was added' '
166 append_cr <<-\EOF >expected &&
167 first line
168 same line
171 git config merge.renormalize true &&
172 git rm -fr . &&
173 git reset --hard b &&
174 test_must_fail git cherry-pick a >err 2>&1 &&
175 grep "[Nn]othing added" err &&
176 test_cmp expected file
179 test_expect_success 'Test delete/normalize conflict' '
180 git checkout -f side &&
181 git rm -fr . &&
182 rm -f .gitattributes &&
183 git reset --hard initial &&
184 git rm file &&
185 git commit -m "remove file" &&
186 git checkout master &&
187 git reset --hard a^ &&
188 git merge side
191 test_done