gitattributes.txt: document how to normalize the line endings
The instructions how to normalize the line endings should have been updated as part of commit 6523728499e 'convert: unify the "auto" handling of CRLF', (but that part never made it into the commit). Update the documentation in Documentation/gitattributes.txt and add a test case in t0025. Reported by Kristian Adrup https://github.com/git-for-windows/git/issues/954 Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Torsten Bögershausen committed
Apr 12, 2017 at 13:48 UTC
85999743e74e35b9100cbeb94112a8ac39ab5a0e
2 files changed
+28
-4
Documentation/gitattributes.txt
+2
-4
@@ -227,11 +227,9 @@ From a clean working directory:
227
228
-------------------------------------------------
229
$ echo "* text=auto" >.gitattributes
230
-$ rm .git/index # Remove the index to force Git to
231
-$ git reset # re-scan the working directory
230
+$ rm .git/index # Remove the index to re-scan the working directory
231
+$ git add .
232
$ git status # Show files that will be normalized
233
-$ git add -u
234
-$ git add .gitattributes
233
$ git commit -m "Introduce end-of-line normalization"
234
-------------------------------------------------
235
t/t0025-crlf-auto.sh
+26
@@ -152,4 +152,30 @@ test_expect_success 'eol=crlf _does_ normalize binary files' '
152
test -z "$LFwithNULdiff"
153
'
154
155
+test_expect_success 'prepare unnormalized' '
156
+ > .gitattributes &&
157
+ git config core.autocrlf false &&
158
+ printf "LINEONE\nLINETWO\r\n" >mixed &&
159
+ git add mixed .gitattributes &&
160
+ git commit -m "Add mixed" &&
161
+ git ls-files --eol | egrep "i/crlf" &&
162
+ git ls-files --eol | egrep "i/mixed"
163
+'
164
+
165
+test_expect_success 'normalize unnormalized' '
166
+ echo "* text=auto" >.gitattributes &&
167
+ rm .git/index &&
168
+ git add . &&
169
+ git commit -m "Introduce end-of-line normalization" &&
170
+ git ls-files --eol | tr "\\t" " " | sort >act &&
171
+cat >exp <<EOF &&
172
+i/-text w/-text attr/text=auto LFwithNUL
173
+i/lf w/crlf attr/text=auto CRLFonly
174
+i/lf w/crlf attr/text=auto LFonly
175
+i/lf w/lf attr/text=auto .gitattributes
176
+i/lf w/mixed attr/text=auto mixed
177
+EOF
178
+ test_cmp exp act
179
+'
180
+
181
test_done