git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Regression (?) in core.safecrlf=false messaging

From
Anthony Sottile <asottile@umich.edu>
Date
Jun 4, 2018, 05:54 UTC
Message-ID
<CA+dzEBm_doNMjEs_OWwia_mm7u3ztAFpCpaFJP3DRpFhEo93jg@mail.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
Next: Torsten Bögershausen
Message 1 of 5 in “Regression (?) in core.safecrlf=false messaging”
  1. Anthony SottileJun 4, 2018
  2. Torsten BögershausenJun 4, 2018
  3. Torsten BögershausenJun 4, 2018
  4. Anthony SottileJun 4, 2018
  5. Torsten BögershausenJun 4, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.