Skip to content

Commit 848d9a9

Browse files
committed
Merge branch 'tb/doc-eol-normalization'
Doc update. * tb/doc-eol-normalization: gitattributes.txt: document how to normalize the line endings
2 parents 6b51cb6 + 8599974 commit 848d9a9

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

Documentation/gitattributes.txt

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

230230
-------------------------------------------------
231231
$ echo "* text=auto" >.gitattributes
232-
$ rm .git/index # Remove the index to force Git to
233-
$ git reset # re-scan the working directory
232+
$ rm .git/index # Remove the index to re-scan the working directory
233+
$ git add .
234234
$ git status # Show files that will be normalized
235-
$ git add -u
236-
$ git add .gitattributes
237235
$ git commit -m "Introduce end-of-line normalization"
238236
-------------------------------------------------
239237

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)