Re: [PATCH] .gitattributes: disable crlf translation
On 2024-05-23 05:01, Richard Biener wrote: On Thu, May 23, 2024 at 5:50 AM Peter Damianov wrote: By default, git has the "autocrlf" """feature""" enabled. This causes the files to have CRLF line endings when checked out on windows, which in the case of configure, causes confusing errors like: ./gcc/configure: line 14: $'\r': command not found ./gcc/configure: line 29: syntax error near unexpected token `newline' '/gcc/configure: line 29: ` ;; when it is invoked. Any files damaged in this way can be fixed with: $ git config core.autocrlf false $ git reset $ git checkout . But, it's better to simply avoid this problem in the first place. This behavior is never helpful or desired for gcc. For files added/edited on Windows does this then also strip the \r (upon which action?)? Otherwise I think this looks good but I'm not a git expert. From what I can tell, the \r doesn't get stripped from the files, but the commit itself acts as if it isn't there. In the working directory, if an editor introduces a CRLF it remains, but any commits created won't include it. I am finding the git documentation a bit confusing on this point though, so I'm not certain. I'm far from a git export as well. I checked and I couldn't find any CRLFs in gcc right now. I tried the commands here: https://git-scm.com/docs/gitattributes $ git add --renormalize . $ git status# Show files that will be normalized And git status showed no changes. As far as I can tell, this change is okay. I would still feel more confident if others looked at it, though. Thanks, Peter D. Richard. Signed-off-by: Peter Damianov --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index e75bfc595bf..1e116987c98 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,6 @@ ChangeLog whitespace=indent-with-non-tab,space-before-tab,trailing-space # Use together with git config diff.md.xfuncname '^\(define.*$' # which is run by contrib/gcc-git-customization.sh too. *.md diff=md + +# Disable lf -> crlf translation on windows. +* -crlf -- 2.39.2
Re: [PATCH] .gitattributes: disable crlf translation
On Thu, May 23, 2024 at 5:50 AM Peter Damianov wrote: > > By default, git has the "autocrlf" """feature""" enabled. This causes the > files > to have CRLF line endings when checked out on windows, which in the case of > configure, causes confusing errors like: > > ./gcc/configure: line 14: $'\r': command not found > ./gcc/configure: line 29: syntax error near unexpected token `newline' > '/gcc/configure: line 29: ` ;; > > when it is invoked. > > Any files damaged in this way can be fixed with: > $ git config core.autocrlf false > $ git reset > $ git checkout . > > But, it's better to simply avoid this problem in the first place. > This behavior is never helpful or desired for gcc. For files added/edited on Windows does this then also strip the \r (upon which action?)? Otherwise I think this looks good but I'm not a git expert. Richard. > Signed-off-by: Peter Damianov > --- > .gitattributes | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/.gitattributes b/.gitattributes > index e75bfc595bf..1e116987c98 100644 > --- a/.gitattributes > +++ b/.gitattributes > @@ -8,3 +8,6 @@ ChangeLog > whitespace=indent-with-non-tab,space-before-tab,trailing-space > # Use together with git config diff.md.xfuncname '^\(define.*$' > # which is run by contrib/gcc-git-customization.sh too. > *.md diff=md > + > +# Disable lf -> crlf translation on windows. > +* -crlf > -- > 2.39.2 >
[PATCH] .gitattributes: disable crlf translation
By default, git has the "autocrlf" """feature""" enabled. This causes the files to have CRLF line endings when checked out on windows, which in the case of configure, causes confusing errors like: ./gcc/configure: line 14: $'\r': command not found ./gcc/configure: line 29: syntax error near unexpected token `newline' '/gcc/configure: line 29: ` ;; when it is invoked. Any files damaged in this way can be fixed with: $ git config core.autocrlf false $ git reset $ git checkout . But, it's better to simply avoid this problem in the first place. This behavior is never helpful or desired for gcc. Signed-off-by: Peter Damianov --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index e75bfc595bf..1e116987c98 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,6 @@ ChangeLog whitespace=indent-with-non-tab,space-before-tab,trailing-space # Use together with git config diff.md.xfuncname '^\(define.*$' # which is run by contrib/gcc-git-customization.sh too. *.md diff=md + +# Disable lf -> crlf translation on windows. +* -crlf -- 2.39.2