public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] .gitattributes: disable crlf translation
@ 2024-05-23  3:49 Peter Damianov
  2024-05-23 12:01 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Damianov @ 2024-05-23  3:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Peter Damianov

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 <peter0x44@disroot.org>
---
 .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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] .gitattributes: disable crlf translation
  2024-05-23  3:49 [PATCH] .gitattributes: disable crlf translation Peter Damianov
@ 2024-05-23 12:01 ` Richard Biener
  2024-05-24 15:47   ` Peter0x44
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2024-05-23 12:01 UTC (permalink / raw)
  To: Peter Damianov; +Cc: gcc-patches

On Thu, May 23, 2024 at 5:50 AM Peter Damianov <peter0x44@disroot.org> 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 <peter0x44@disroot.org>
> ---
>  .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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] .gitattributes: disable crlf translation
  2024-05-23 12:01 ` Richard Biener
@ 2024-05-24 15:47   ` Peter0x44
  0 siblings, 0 replies; 3+ messages in thread
From: Peter0x44 @ 2024-05-24 15:47 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On 2024-05-23 05:01, Richard Biener wrote:
> On Thu, May 23, 2024 at 5:50 AM Peter Damianov <peter0x44@disroot.org> 
> 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 <peter0x44@disroot.org>
>> ---
>>  .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
>> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-24 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-23  3:49 [PATCH] .gitattributes: disable crlf translation Peter Damianov
2024-05-23 12:01 ` Richard Biener
2024-05-24 15:47   ` Peter0x44

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).