Puphpet: CRLF Warnings from Git

Created on 14 Aug 2014  路  6Comments  路  Source: puphpet/puphpet

Whenever I run git add within my PuPHPet project, I get a bunch of warnings for the PNGs in the directory.

warning: CRLF will be replaced by LF in puphpet/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/rabbitmq/files/plugins/amqp_client-2.3.1.ez.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/rvm/spec/fixtures/modules/concat/spec/acceptance/quoted_paths_spec.rb.
The file will have its original line endings in your working directory.
gwarning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/border.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/controls.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading_background.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_green.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_red.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_yellow.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/magnify.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png.
The file will have its original line endings in your working directory.

I can prevent most of the errors by adding *.png binary to puphpet/.gitattributes. But I still get these:

warning: CRLF will be replaced by LF in puphpet/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/rabbitmq/files/plugins/amqp_client-2.3.1.ez.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in puphpet/puppet/modules/rvm/spec/fixtures/modules/concat/spec/acceptance/quoted_paths_spec.rb.
The file will have its original line endings in your working directory.

Can we add gitattributes rules for these files? Can I make a pull-request for that?

Most helpful comment

Hi guys, Hi @jtreminio,

I know that this issue is closed, but as I spent a lot of time to understand what was going on, I made some researches and I can explain why this happen, and you can fix it.

Using git config core.autocrlf true can help, but not on a multi-developpers project.
This command has to be the same on each developper machine, and that's not always the case.

You have to use the .gitattributes provided in the puphpet archive and edit it as follow (carefull, this file need to be in your project root)
You also need to use an IDE that allow you to save/edit files as LF (like phpstorm). You can check the type of the file in the bottom right corner, in the status bar (you'll see LF or CRLF while a file is opened)

.gitattributes

# These settings are for any web project

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

# Force the following filetypes to have unix eols, so Windows does not break them
*.* text eol=lf

# Windows forced line-endings
/.idea/* text eol=crlf

#
## These files are binary and should be left untouched
#

# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary
*.ez binary
*.bz2 binary
*.swp binary

Do not not forget to specify the binary files, or your files will suffer line-ending modifications while pushing to git.
The link provided by @kungfuse76 explain this really clearly.

@jtreminio Maybe could you provide a fully configured .gitattributes file inside your puphpet archive, so Windows users wouldn't be confused by that messages about CRLF conversion, or by strange errors like $'\r': command not found https://github.com/puphpet/puphpet/issues/266, https://github.com/puphpet/puphpet/issues/1962#issuecomment-156526644

Cheers, and thanks again for that wonderful box and tools.

All 6 comments

I could be wrong, but I think this in issue when using a *nix guest on a windows host. Windows uses CRLF, and *nix uses LF. If you use an editor like Phpstorm, and again, if you are on windows, you can change the line feeds from CRLF to LF, which may make your git add * statements behave as expected.
Otherwise, as a second possibility, this may be attributed to using Git bash in windows. Again, it might be possible that windows edited files produce the line feed conflict when moving to *nix formats.
...Just an idea...

@kungfuse76 The box is running under a Linux host OS. My understanding of the problem is that the gitattributes file that PuPHPet generates is causing Git to recognize binary files as text, and therefoxe it's generating warnings when it sees bytes that would normally be new lines, but are in fact not encoded as text.

@jonahbron Perhaps here, but not sure if this will address binaries or not:
Dealing with line endings

Per http://stackoverflow.com/a/9094476

git config core.autocrlf true

When I ran Windows this is what I did.

Hi guys, Hi @jtreminio,

I know that this issue is closed, but as I spent a lot of time to understand what was going on, I made some researches and I can explain why this happen, and you can fix it.

Using git config core.autocrlf true can help, but not on a multi-developpers project.
This command has to be the same on each developper machine, and that's not always the case.

You have to use the .gitattributes provided in the puphpet archive and edit it as follow (carefull, this file need to be in your project root)
You also need to use an IDE that allow you to save/edit files as LF (like phpstorm). You can check the type of the file in the bottom right corner, in the status bar (you'll see LF or CRLF while a file is opened)

.gitattributes

# These settings are for any web project

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

# Force the following filetypes to have unix eols, so Windows does not break them
*.* text eol=lf

# Windows forced line-endings
/.idea/* text eol=crlf

#
## These files are binary and should be left untouched
#

# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary
*.ez binary
*.bz2 binary
*.swp binary

Do not not forget to specify the binary files, or your files will suffer line-ending modifications while pushing to git.
The link provided by @kungfuse76 explain this really clearly.

@jtreminio Maybe could you provide a fully configured .gitattributes file inside your puphpet archive, so Windows users wouldn't be confused by that messages about CRLF conversion, or by strange errors like $'\r': command not found https://github.com/puphpet/puphpet/issues/266, https://github.com/puphpet/puphpet/issues/1962#issuecomment-156526644

Cheers, and thanks again for that wonderful box and tools.

Do not not forget to specify the binary files, or your files will suffer line-ending modifications while pushing to git.

Thanks this gave me a lot of headaches..

Was this page helpful?
0 / 5 - 0 ratings