Skip to content

Commit 8599974

Browse files
tboegigitster
authored andcommitted
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 6523728 '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 git-for-windows#954 Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 49800c9 commit 8599974

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

Documentation/gitattributes.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,9 @@ From a clean working directory:
227227

228228
-------------------------------------------------
229229
$ 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 .
232232
$ git status # Show files that will be normalized
233-
$ git add -u
234-
$ git add .gitattributes
235233
$ git commit -m "Introduce end-of-line normalization"
236234
-------------------------------------------------
237235

t/t0025-crlf-auto.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,30 @@ test_expect_success 'eol=crlf _does_ normalize binary files' '
152152
test -z "$LFwithNULdiff"
153153
'
154154

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+
155181
test_done

0 commit comments

Comments
 (0)