Browse Source
Make it safer to normalize the line endings in a repository. Files that had been commited with CRLF will be commited with LF. The old way to normalize a repo was like this: # Make sure that there are not untracked files $ echo "* text=auto" >.gitattributes $ git read-tree --empty $ git add . $ git commit -m "Introduce end-of-line normalization" The user must make sure that there are no untracked files, otherwise they would have been added and tracked from now on. The new "add --renormalize" does not add untracked files: $ echo "* text=auto" >.gitattributes $ git add --renormalize . $ git commit -m "Introduce end-of-line normalization" Note that "git add --renormalize <pathspec>" is the short form for "git add -u --renormalize <pathspec>". While at it, document that the same renormalization may be needed, whenever a clean filter is added or changed. Helped-By: Junio C Hamano <gitster@pobox.com> Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
Torsten Bögershausen
7 years ago
committed by
Junio C Hamano
7 changed files with 102 additions and 18 deletions
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh |
||||
|
||||
test_description='CRLF renormalization' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
test_expect_success setup ' |
||||
git config core.autocrlf false && |
||||
printf "LINEONE\nLINETWO\nLINETHREE\n" >LF.txt && |
||||
printf "LINEONE\r\nLINETWO\r\nLINETHREE\r\n" >CRLF.txt && |
||||
printf "LINEONE\r\nLINETWO\nLINETHREE\n" >CRLF_mix_LF.txt && |
||||
git add . && |
||||
git commit -m initial |
||||
' |
||||
|
||||
test_expect_success 'renormalize CRLF in repo' ' |
||||
echo "*.txt text=auto" >.gitattributes && |
||||
git add --renormalize "*.txt" && |
||||
cat >expect <<-\EOF && |
||||
i/lf w/crlf attr/text=auto CRLF.txt |
||||
i/lf w/lf attr/text=auto LF.txt |
||||
i/lf w/mixed attr/text=auto CRLF_mix_LF.txt |
||||
EOF |
||||
git ls-files --eol | |
||||
sed -e "s/ / /g" -e "s/ */ /g" | |
||||
sort >actual && |
||||
test_cmp expect actual |
||||
' |
||||
|
||||
test_done |
Loading…
Reference in new issue