]>
Commit | Line | Data |
---|---|---|
f217f0e8 EB |
1 | #!/bin/sh |
2 | ||
18acb30e JN |
3 | test_description='CRLF merge conflict across text=auto change |
4 | ||
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 | |
13 | ' | |
f217f0e8 EB |
14 | |
15 | . ./test-lib.sh | |
16 | ||
a31d0665 | 17 | test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b |
ca02ad34 | 18 | |
f217f0e8 | 19 | test_expect_success setup ' |
f217f0e8 | 20 | git config core.autocrlf false && |
18acb30e | 21 | |
f217f0e8 EB |
22 | echo first line | append_cr >file && |
23 | echo first line >control_file && | |
24 | echo only line >inert_file && | |
18acb30e | 25 | |
f217f0e8 | 26 | git add file control_file inert_file && |
18acb30e | 27 | test_tick && |
f217f0e8 EB |
28 | git commit -m "Initial" && |
29 | git tag initial && | |
30 | git branch side && | |
18acb30e | 31 | |
f217f0e8 EB |
32 | echo "* text=auto" >.gitattributes && |
33 | touch file && | |
34 | git add .gitattributes file && | |
18acb30e | 35 | test_tick && |
f217f0e8 | 36 | git commit -m "normalize file" && |
18acb30e | 37 | |
f217f0e8 EB |
38 | echo same line | append_cr >>file && |
39 | echo same line >>control_file && | |
40 | git add file control_file && | |
18acb30e | 41 | test_tick && |
f217f0e8 EB |
42 | git commit -m "add line from a" && |
43 | git tag a && | |
18acb30e | 44 | |
f217f0e8 EB |
45 | git rm .gitattributes && |
46 | rm file && | |
47 | git checkout file && | |
18acb30e | 48 | test_tick && |
f217f0e8 EB |
49 | git commit -m "remove .gitattributes" && |
50 | git tag c && | |
18acb30e | 51 | |
f217f0e8 EB |
52 | git checkout side && |
53 | echo same line | append_cr >>file && | |
54 | echo same line >>control_file && | |
55 | git add file control_file && | |
18acb30e | 56 | test_tick && |
f217f0e8 EB |
57 | git commit -m "add line from b" && |
58 | git tag b && | |
18acb30e | 59 | |
f217f0e8 EB |
60 | git checkout master |
61 | ' | |
62 | ||
beeeb454 JN |
63 | test_expect_success 'set up fuzz_conflict() helper' ' |
64 | fuzz_conflict() { | |
ca02ad34 | 65 | sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@" |
beeeb454 JN |
66 | } |
67 | ' | |
68 | ||
18acb30e JN |
69 | test_expect_success 'Merge after setting text=auto' ' |
70 | cat <<-\EOF >expected && | |
71 | first line | |
72 | same line | |
73 | EOF | |
74 | ||
beeeb454 | 75 | git config merge.renormalize true && |
18acb30e JN |
76 | git rm -fr . && |
77 | rm -f .gitattributes && | |
f217f0e8 EB |
78 | git reset --hard a && |
79 | git merge b && | |
18acb30e | 80 | test_cmp expected file |
f217f0e8 EB |
81 | ' |
82 | ||
18acb30e JN |
83 | test_expect_success 'Merge addition of text=auto' ' |
84 | cat <<-\EOF >expected && | |
85 | first line | |
86 | same line | |
87 | EOF | |
88 | ||
beeeb454 | 89 | git config merge.renormalize true && |
18acb30e JN |
90 | git rm -fr . && |
91 | rm -f .gitattributes && | |
f217f0e8 EB |
92 | git reset --hard b && |
93 | git merge a && | |
18acb30e | 94 | test_cmp expected file |
f217f0e8 EB |
95 | ' |
96 | ||
beeeb454 JN |
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 | >>>>>>> | |
106 | EOF | |
107 | ||
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 | |
114 | ' | |
115 | ||
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 | >>>>>>> | |
125 | EOF | |
126 | ||
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 | |
133 | ' | |
134 | ||
d347cee4 JN |
135 | test_expect_failure 'checkout -m after setting text=auto' ' |
136 | cat <<-\EOF >expected && | |
137 | first line | |
138 | same line | |
139 | EOF | |
140 | ||
beeeb454 | 141 | git config merge.renormalize true && |
d347cee4 JN |
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 | |
148 | ' | |
149 | ||
150 | test_expect_failure 'checkout -m addition of text=auto' ' | |
151 | cat <<-\EOF >expected && | |
152 | first line | |
153 | same line | |
154 | EOF | |
155 | ||
beeeb454 | 156 | git config merge.renormalize true && |
d347cee4 JN |
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 | |
163 | ' | |
164 | ||
165 | test_expect_failure 'cherry-pick patch from after text=auto was added' ' | |
166 | append_cr <<-\EOF >expected && | |
167 | first line | |
168 | same line | |
169 | EOF | |
170 | ||
beeeb454 | 171 | git config merge.renormalize true && |
d347cee4 JN |
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 | |
177 | ' | |
178 | ||
331a1838 | 179 | test_expect_success 'Test delete/normalize conflict' ' |
18acb30e JN |
180 | git checkout -f side && |
181 | git rm -fr . && | |
182 | rm -f .gitattributes && | |
f217f0e8 EB |
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 | |
189 | ' | |
190 | ||
191 | test_done |