# Regression (?) in core.safecrlf=false messaging

5 messages from 2018-06-04 to 2018-06-04. Participants: Anthony Sottile, Torsten Bögershausen.
Thread: https://gitlist.dev/t/48641

## Anthony Sottile, 2018-06-04 05:54

Subject: Regression (?) in core.safecrlf=false messaging
Message-ID: <CA+dzEBm_doNMjEs_OWwia_mm7u3ztAFpCpaFJP3DRpFhEo93jg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BdzEBm_doNMjEs_OWwia_mm7u3ztAFpCpaFJP3DRpFhEo93jg%40mail.gmail.com

```
I'm a bit unclear if I was depending on undocumented behaviour or not
here but it seems the messaging has recently changed with respect to
`core.safecrlf`

My reading of the documentation
https://git-scm.com/docs/git-config#git-config-coresafecrlf (I might
be wrong here)

- core.safecrlf = true -> fail hard when converting
- core.safecrlf = warn -> produce message when converting
- core.safecrlf = false -> convert silently

(note that these are all only relevant when `core.autocrlf = true`)

I've created a small script to demonstrate:

ˋˋˋ
set -euxo pipefail

git --version

rm -rf repo
git init repo
cd repo
git config core.autocrlf input
git config core.safecrlf false
echo -en 'foo\r\nbar\r\n' > f
git add f
ˋˋˋ

When run against 2.16.4:

ˋˋˋ
$ PATH=$PWD/prefix/bin:$PATH bash test.sh
+ git --version
git version 2.16.4
+ rm -rf repo
+ git init repo
Initialized empty Git repository in /tmp/git/repo/.git/
+ cd repo
+ git config core.autocrlf input
+ git config core.safecrlf false
+ echo -en 'foo\r\nbar\r\n'
+ git add f
ˋˋˋ

(notice how there are no messages about crlf conversion while adding
-- this is what I expect given I have core.safecrlf=false)


When run against master:

ˋˋˋconsole
$ PATH=$PWD/prefix/bin:$PATH bash test.sh
+ git --version
git version 2.18.0.rc0.42.gc2c7d17
+ rm -rf repo
+ git init repo
Initialized empty Git repository in /tmp/git/repo/.git/
+ cd repo
+ git config core.autocrlf input
+ git config core.safecrlf false
+ echo -en 'foo\r\nbar\r\n'
+ git add f
warning: CRLF will be replaced by LF in f.
The file will have its original line endings in your working directory.
ˋˋˋ

A `git bisect` shows this as the first commit which breaks this
behaviour: 8462ff43e42ab67cecd16fdfb59451a53cc8a945

https://github.com/git/git/commit/8462ff43e42ab67cecd16fdfb59451a53cc8a945

The commit appears to be a refactor (?) that shouldn't have changed behaviour?

Here's the script I was using to bisect:
https://i.fluffy.cc/2L4ZtqV3cHfzNRkKPbHgTcz43HMQJxdK.html

ˋˋˋ
git bisect start
git bisect bad v2.17.0
git bisect good v2.16.4
git bisect run ./test.sh
ˋˋˋ

Noticed this due to test failures here:
https://github.com/pre-commit/pre-commit/pull/762#issuecomment-394236625

Thanks,

Anthony

```

## Torsten Bögershausen, 2018-06-04 07:38

Subject: Re: Regression (?) in core.safecrlf=false messaging
Message-ID: <20180604073855.GA20922@tor.lan>
URL: https://gitlist.dev/e/20180604073855.GA20922%40tor.lan
In-Reply-To: <CA+dzEBm_doNMjEs_OWwia_mm7u3ztAFpCpaFJP3DRpFhEo93jg@mail.gmail.com>

```
(as usual, no top-posting here, please see my answers at the end)

On Sun, Jun 03, 2018 at 10:54:00PM -0700, Anthony Sottile wrote:
> I'm a bit unclear if I was depending on undocumented behaviour or not
> here but it seems the messaging has recently changed with respect to
> `core.safecrlf`
> 
> My reading of the documentation
> https://git-scm.com/docs/git-config#git-config-coresafecrlf (I might
> be wrong here)
> 
> - core.safecrlf = true -> fail hard when converting
> - core.safecrlf = warn -> produce message when converting
> - core.safecrlf = false -> convert silently
> 
> (note that these are all only relevant when `core.autocrlf = true`)
> 
> I've created a small script to demonstrate:
> 
> ˋˋˋ
> set -euxo pipefail
> 
> git --version
> 
> rm -rf repo
> git init repo
> cd repo
> git config core.autocrlf input
> git config core.safecrlf false
> echo -en 'foo\r\nbar\r\n' > f
> git add f
> ˋˋˋ
> 
> When run against 2.16.4:
> 
> ˋˋˋ
> $ PATH=$PWD/prefix/bin:$PATH bash test.sh
> + git --version
> git version 2.16.4
> + rm -rf repo
> + git init repo
> Initialized empty Git repository in /tmp/git/repo/.git/
> + cd repo
> + git config core.autocrlf input
> + git config core.safecrlf false
> + echo -en 'foo\r\nbar\r\n'
> + git add f
> ˋˋˋ
> 
> (notice how there are no messages about crlf conversion while adding
> -- this is what I expect given I have core.safecrlf=false)
> 
> 
> When run against master:
> 
> ˋˋˋconsole
> $ PATH=$PWD/prefix/bin:$PATH bash test.sh
> + git --version
> git version 2.18.0.rc0.42.gc2c7d17
> + rm -rf repo
> + git init repo
> Initialized empty Git repository in /tmp/git/repo/.git/
> + cd repo
> + git config core.autocrlf input
> + git config core.safecrlf false
> + echo -en 'foo\r\nbar\r\n'
> + git add f
> warning: CRLF will be replaced by LF in f.
> The file will have its original line endings in your working directory.
> ˋˋˋ
> 
> A `git bisect` shows this as the first commit which breaks this
> behaviour: 8462ff43e42ab67cecd16fdfb59451a53cc8a945
> 
> https://github.com/git/git/commit/8462ff43e42ab67cecd16fdfb59451a53cc8a945
> 
> The commit appears to be a refactor (?) that shouldn't have changed behaviour?
> 
> Here's the script I was using to bisect:
> https://i.fluffy.cc/2L4ZtqV3cHfzNRkKPbHgTcz43HMQJxdK.html
> 
> ˋˋˋ
> git bisect start
> git bisect bad v2.17.0
> git bisect good v2.16.4
> git bisect run ./test.sh
> ˋˋˋ
> 
> Noticed this due to test failures here:
> https://github.com/pre-commit/pre-commit/pull/762#issuecomment-394236625
> 
> Thanks,
> 
> Anthony

Thanks so much for the report, and the detailed analyzes that has been done.
Good work, I would say.

This looks very much as an (unplanned) regression.
I will have a look within the next days, as soon as my time allows it.

```

## Torsten Bögershausen, 2018-06-04 07:55

Subject: Re: Regression (?) in core.safecrlf=false messaging
Message-ID: <20180604075549.GA21063@tor.lan>
URL: https://gitlist.dev/e/20180604075549.GA21063%40tor.lan
In-Reply-To: <20180604073855.GA20922@tor.lan>

```

Does the following patch fix your problem ?

diff --git a/config.c b/config.c
index 6f8f1d8c11..c625aec96a 100644
--- a/config.c
+++ b/config.c
@@ -1233,7 +1233,7 @@ static int git_default_core_config(const char *var, const char *value)
 		}
 		eol_rndtrp_die = git_config_bool(var, value);
 		global_conv_flags_eol = eol_rndtrp_die ?
-			CONV_EOL_RNDTRP_DIE : CONV_EOL_RNDTRP_WARN;
+			CONV_EOL_RNDTRP_DIE : 0;
 		return 0;
 	}
 

```

## Anthony Sottile, 2018-06-04 15:43

Subject: Re: Regression (?) in core.safecrlf=false messaging
Message-ID: <CA+dzEBn7cCey-LDa1Y-PUeFQs7JiucS30FFiLfw4sfu6ZX34JQ@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BdzEBn7cCey-LDa1Y-PUeFQs7JiucS30FFiLfw4sfu6ZX34JQ%40mail.gmail.com
In-Reply-To: <20180604075549.GA21063@tor.lan>

```
On Mon, Jun 4, 2018 at 12:55 AM, Torsten Bögershausen <tboegi@web.de> wrote:
>
> Does the following patch fix your problem ?
>
> diff --git a/config.c b/config.c
> index 6f8f1d8c11..c625aec96a 100644
> --- a/config.c
> +++ b/config.c
> @@ -1233,7 +1233,7 @@ static int git_default_core_config(const char *var, const char *value)
>                 }
>                 eol_rndtrp_die = git_config_bool(var, value);
>                 global_conv_flags_eol = eol_rndtrp_die ?
> -                       CONV_EOL_RNDTRP_DIE : CONV_EOL_RNDTRP_WARN;
> +                       CONV_EOL_RNDTRP_DIE : 0;
>                 return 0;
>         }
>


Yes!  After applying that patch:

ˋˋˋ

$ PATH=$PWD/prefix/bin:$PATH bash test.sh
+ git --version
git version 2.18.0.rc1.dirty
+ rm -rf repo
+ git init repo
Initialized empty Git repository in /tmp/git/repo/.git/
+ cd repo
+ git config core.autocrlf input
+ git config core.safecrlf false
+ echo -en 'foo\r\nbar\r\n'
+ git add f

ˋˋˋ

Anthony

```

## Torsten Bögershausen, 2018-06-04 19:15

Subject: Re: Regression (?) in core.safecrlf=false messaging
Message-ID: <81c6709d-8f8d-9387-1649-6bdc80c30ae8@web.de>
URL: https://gitlist.dev/e/81c6709d-8f8d-9387-1649-6bdc80c30ae8%40web.de
In-Reply-To: <CA+dzEBn7cCey-LDa1Y-PUeFQs7JiucS30FFiLfw4sfu6ZX34JQ@mail.gmail.com>

```
On 04.06.18 17:43, Anthony Sottile wrote:
> On Mon, Jun 4, 2018 at 12:55 AM, Torsten Bögershausen <tboegi@web.de> wrote:
>>
>> Does the following patch fix your problem ?
>>
>> diff --git a/config.c b/config.c
>> index 6f8f1d8c11..c625aec96a 100644
>> --- a/config.c
>> +++ b/config.c
>> @@ -1233,7 +1233,7 @@ static int git_default_core_config(const char *var, const char *value)
>>                 }
>>                 eol_rndtrp_die = git_config_bool(var, value);
>>                 global_conv_flags_eol = eol_rndtrp_die ?
>> -                       CONV_EOL_RNDTRP_DIE : CONV_EOL_RNDTRP_WARN;
>> +                       CONV_EOL_RNDTRP_DIE : 0;
>>                 return 0;
>>         }
>>
> 
> 
> Yes!  After applying that patch:
> 
> ˋˋˋ
> 
> $ PATH=$PWD/prefix/bin:$PATH bash test.sh
> + git --version
> git version 2.18.0.rc1.dirty
> + rm -rf repo
> + git init repo
> Initialized empty Git repository in /tmp/git/repo/.git/
> + cd repo
> + git config core.autocrlf input
> + git config core.safecrlf false
> + echo -en 'foo\r\nbar\r\n'
> + git add f
> 
> ˋˋˋ
> 
> Anthony
> 
Good.
Do you want to send the patch to the list ?
(You don't have too, if you don't want,
but as you already did all the work...)



```
