Hi (again),
Following my previous email "Tracking vendor release with Git" [1][2], and the advice from Git users/developers, I'm trying to use .gitattributes to handle CRLF/LF conversion.
I'm following advices from:
- "Dealing with line endings"
https://help.github.com/articles/dealing-with-line-endings - "Tim's Blog, Mind the End of Your Line"
http://timclem.wordpress.com/2012/03/01/mind-the-end-of-your-line/ - "7.2 Customizing Git - Git Attributes"
http://git-scm.com/book/ch7-2.html - "gitattributes(5) Manual Page"
https://www.kernel.org/pub/software/scm/git/docs/gitattributes.htmlWhile testing the behavor of Git regarding CRLF handling, I've found git rebase fail when trying to apply a commit that's going to fix/convert CRLF to LF.
I'm using the following script:
A file with CRLF end of line (EOL) "test" is added and commited, then a file .gitattributes is added and commited. The .gitattributes has a single line "test text" to ask git to do EOL conversion. After adding this .gitattributes file, Git start complaining about the line ending to file "test". The file is fixed and commited.
Then this branch is rebased on top of another parent. And here come the failures:
Most of the time git rebase failed with the following error:
...
First, rewinding head to replay your work on top of it...
Applying: Commit raw
Applying: Added git attributes
Applying: Normalization
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten
by merge:
test
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0003 Normalization
...But sometime it failed with another error:
with core.safecrlf = warn:
... First, rewinding head to replay your work on top of it... Applying: Commit raw Applying: Added git attributes warning: CRLF will be replaced by LF in test. The file will have its original line endings in your working directory. Applying: Normalization fatal: unrecognized input Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0003 Normalization ...
with core.safecrlf = true:
... First, rewinding head to replay your work on top of it... Applying: Commit raw Applying: Added git attributes fatal: CRLF would be replaced by LF in test. Applying: Normalization fatal: unrecognized input Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0003 Normalization ...
In thoses two latter cases, running "git add" does not fail with a fatal error: it does nothing. I need to run "touch test" to make "git add" fail with error "fatal: CRLF would be replaced by LF in test.
I believe "git rebase" should not fail here, but more, it must not fail in a different fashion randomly.
Please find in reply to this email: - a shell script to demonstrate the behavor - a patch to t0020-crlf.sh to add two rebase tests.
1. <1370970410-7935-1-git-send-email-ydroneaud@opteya.com>
2. <http://thread.gmane.org/gmane.comp.version-control.git/227466>
<http://marc.info/?l=git&m=137097069115462&w=2>Regards
-- Yann Droneaud OPTEYA