gitattributes.txt: document how to normalize the line endings
authorTorsten Bögershausen <tboegi@web.de>
Wed, 12 Apr 2017 11:48:09 +0000 (13:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Apr 2017 22:53:41 +0000 (15:53 -0700)
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>
Documentation/gitattributes.txt
t/t0025-crlf-auto.sh
index e0b66c1220a7d22ef5b8eb960a4e2e389a71f884..0b03d91e6bdc544ff3be4e4748b1f96fb00877f8 100644 (file)
@@ -227,11 +227,9 @@ From a clean working directory:
 
 -------------------------------------------------
 $ echo "* text=auto" >.gitattributes
-$ rm .git/index     # Remove the index to force Git to
-$ git reset         # re-scan the working directory
+$ rm .git/index     # Remove the index to re-scan the working directory
+$ git add .
 $ git status        # Show files that will be normalized
-$ git add -u
-$ git add .gitattributes
 $ git commit -m "Introduce end-of-line normalization"
 -------------------------------------------------
 
index d0bee08b2e2add3caa82967e120157e7112385a4..89826c568b14659df98c1150fc3d021d375f4d9c 100755 (executable)
@@ -152,4 +152,30 @@ test_expect_success 'eol=crlf _does_ normalize binary files' '
        test -z "$LFwithNULdiff"
 '
 
+test_expect_success 'prepare unnormalized' '
+       > .gitattributes &&
+       git config core.autocrlf false &&
+       printf "LINEONE\nLINETWO\r\n"     >mixed &&
+       git add mixed .gitattributes &&
+       git commit -m "Add mixed" &&
+       git ls-files --eol | egrep "i/crlf" &&
+       git ls-files --eol | egrep "i/mixed"
+'
+
+test_expect_success 'normalize unnormalized' '
+       echo "* text=auto" >.gitattributes &&
+       rm .git/index &&
+       git add . &&
+       git commit -m "Introduce end-of-line normalization" &&
+       git ls-files --eol | tr "\\t" " " | sort >act &&
+cat >exp <<EOF &&
+i/-text w/-text attr/text=auto         LFwithNUL
+i/lf    w/crlf  attr/text=auto         CRLFonly
+i/lf    w/crlf  attr/text=auto         LFonly
+i/lf    w/lf    attr/text=auto         .gitattributes
+i/lf    w/mixed attr/text=auto         mixed
+EOF
+       test_cmp exp act
+'
+
 test_done