1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 01:06:12 +02:00
git/t/t0025-crlf-renormalize.sh
Torsten Bögershausen 9472935d81 add: introduce "--renormalize"
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>
2017-11-17 10:31:05 +09:00

31 lines
725 B
Bash
Executable File

#!/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