Last active
August 28, 2015 08:07
-
-
Save larsxschneider/2bf4ef41c06d60c12039 to your computer and use it in GitHub Desktop.
git line ending bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# !!! Please run this test on Windows !!! | |
# | |
# Unexpected result confirmed with the following versions: | |
# $ git --version | |
# git version 1.9.5.msysgit.1 | |
# git version 2.5.0.windows.1 | |
# | |
rm -rf git-test | |
mkdir git-test | |
# | |
# Setup | |
# | |
cd git-test | |
git init | |
git config core.autocrlf true | |
cat >.gitattributes <<-\EOF | |
#* text=auto | |
before-binary.txt binary | |
*.txt text | |
after-binary.txt binary | |
EOF | |
git add . | |
git commit -m "Setup" | |
# | |
# Add files | |
# | |
printf "\n" >middle-text.txt | |
printf "\n" >before-binary.txt | |
printf "\n" >after-binary.txt | |
git add . | |
git commit -m "Add files" | |
# | |
# Normalize line endings | |
# | |
git rm --cached -r . | |
git reset --hard | |
git add . | |
git commit -m "Normalize line endings" | |
# | |
# Results | |
# | |
printf "\r\n" >expect-middle | |
cmp expect-middle middle-text.txt | |
# !!! UNEXPECTED !!! | |
# "before-binary.txt" is marked as binary in .gitattributes but line conversions are performed | |
printf "\r\n" >expect-before | |
cmp expect-before before-binary.txt | |
printf "\n" >expect-after | |
cmp expect-after after-binary.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment