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

Re: suggestion for improved docs on autocrlf

From
Torsten Bögershausen <tboegi@web.de>
Date
Aug 13, 2019, 03:24 UTC
Message-ID
<20190813032452.qg2ufgljm4bjeznr@tb-raspi4>
In-Reply-To
<xmqqo90u9ric.fsf@gitster-ct.c.googlers.com>
On Mon, Aug 12, 2019 at 11:18:35AM -0700, Junio C Hamano wrote:
Show 6 quoted lines
> "Yagnatinsky, Mark" <mark.yagnatinsky@bofa.com> writes:
>
> > ...  Assuming the repo has no .gitattributes,
> > is it possible to predict what line endings sample.txt will end up with in my repo?
> > Or does it depend on more information than what I've just written?
>
> Binary packagers can ship custom attributes and config that applies
> globally to the installation, which may affect operations in all of
> your repositories, can't they?
Let me try to split my answer into 3 parts:
- A Git distribution can ship with a global attributes file, but I am not aware of any
  distribution doing this.
  Especially Git for Windpws does not add any (global) .gitattributes file somewhere,
  as far as I know.
- The default value for the global core.autocrlf is typically unset in all
  Unix-like distributions, which does the same as core.autocrlf=false.
- The installer for Git for Windows allows the user to choose what the global
  core.autocrlf should be (false, true, input).
  The help text of the installer mentions what
  e.g. "false" means (line endings "as is"),
  and I don't rember the text for "true" and "input"  out of my head.
Now back to the original question:

Person A creates a repo with core.autocrlf=false and commite sample.txt with CRLF. Person B clones that repo with CRLF in the repo. When the worktree is checked out, sample.txt will have CRLF. Always.

Even if B uses core.autocrlf=input, sample.txt will keep the CRLF when it is commited. If the line endings need to be changed, there are 2 ways: Either user B runs dos2unix and commits file with LF. Or user B runs `git add --renormalize` sample.txt. That needs a `rm sample.txt && git checkout sample.txt` to update the working tree.

All this is predictable. A fresh clone does not have any "modified files"; all files with CRLF stay with CLRF unless they are normalized.

Our documentation mentions "files that any contributor introduces to the repository"

Is that part understandalble and the distincion between "existing" and "new" files clear enough ?

Previous: Yagnatinsky, MarkNext: Yagnatinsky, Mark
Message 15 of 23 in “suggestion for improved docs on autocrlf”
  1. Yagnatinsky, MarkAug 7, 2019
  2. Torsten BögershausenAug 8, 2019
  3. Yagnatinsky, MarkAug 8, 2019
  4. Yagnatinsky, MarkAug 8, 2019
  5. Torsten BögershausenAug 9, 2019
  6. Yagnatinsky, MarkAug 9, 2019
  7. Torsten BögershausenAug 11, 2019
  8. Yagnatinsky, MarkAug 12, 2019
  9. Junio C HamanoAug 12, 2019
  10. Yagnatinsky, MarkAug 12, 2019
  11. Torsten BögershausenAug 12, 2019
  12. Yagnatinsky, MarkAug 12, 2019
  13. Junio C HamanoAug 12, 2019
  14. Yagnatinsky, MarkAug 12, 2019
  15. Torsten BögershausenAug 13, 2019
  16. Yagnatinsky, MarkAug 13, 2019
  17. Torsten BögershausenAug 13, 2019
  18. Yagnatinsky, MarkAug 13, 2019
  19. Yagnatinsky, MarkAug 14, 2019
  20. Yagnatinsky, MarkAug 15, 2019
  21. Torsten BögershausenAug 16, 2019
  22. Yagnatinsky, MarkAug 16, 2019
  23. Junio C HamanoAug 13, 2019

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.