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

Re: [PATCH] Respect crlf attribute even if core.autocrlf has not been set

From
Eyvind Bernhardsen <eyvind-git@orakel.ntnu.no>
Date
Jul 24, 2008, 21:30 UTC
Message-ID
<3B9933A6-9637-41AE-9133-9B6EA9204E6B@orakel.ntnu.no>
In-Reply-To
<alpine.DEB.1.00.0807232041570.8986@racer>
On 23. juli. 2008, at 21.44, Johannes Schindelin wrote:
[...]
Show 5 quoted lines
> I deem it not, uhm, magical.  By your reasoning there should be a  
> way for
> Git to convert a file to UTF-8 when some entertaining person  
> converted the
> working directory file to ISO-8859-15.

Um, what? This discussion is about figuring out when Git should mess with the line endings a user is trying to commit. Why are you bringing character encodings into it? Git does not (to my knowledge) have any "utf8" setting that converts all files to UTF-8, and certainly not one that is enabled by default on Windows.

Being able to mark a file with an "enforce crlf line endings on this file" flag is useful _given that Git messes with line endings_, and a "do not mess with line endings in this file" flag does not achieve the same purpose. Okay?

If you want my personal opinion on autocrlf, I was happier when Git left line endings alone so I didn't have to worry about the files I commit being mangled (however reversibly).

I think "autocrlf=input" can make sense on a per-repository basis, but I would have it somewhere versioned like .gitattributes, so that (a) it is propagated when the repository is cloned, and (b) it is possible to take an existing repository with checked-in CRLFs and do a one-time conversion that also adds the "autocrlf=input" setting to .gitattributes (or wherever the setting ends up going).

I don't use "autocrlf=true", even on Windows, so I don't have any opinion on it other than thinking it should be a per-user setting rather than per-repository (but with a per-platform default :). I don't see how it could work unless the repository has normalised line endings, though.

My background: I have a ton of repositories imported from CVS with a sordid mix of CR and CRLF (occasionally in the same file!). Using these repositories with "autocrlf=true" is a pain in the arse since CRLFs in the repository cause spurious changes after a clean checkout, merge troubles, etc. The code is supposed to build on Windows as well as Unix, so I got bit by this when msysgit changed the default autocrlf setting. [1]

My workaround is simply to set autocrlf=false; another solution might be to filter-branch all CRLFs out of the repository, but then I'd be messing with a lot of history, possibly breaking the files that actually need CRLFs, and for no real upside. No thanks.

Okay, this turned into a longer rant than I intended; what I'm trying to say is that I think autocrlf(=true) as it is currently implemented is pretty useless, and that a setting that is versioned and cloneable would be better. Phew!

-- 
Eyvind Bernhardsen


Footnote:
1. Your impression that people were rude when "autocrlf=true" was made  
the default on msysgit might be related to the fact that nobody had  
considered what would happen to existing repositories before making  
the change?  Steffen Prohaska wrote in response to one such complaint:

> Unfortunately, existing repositories that contain the wrong line  
> endings
> suffer from the problems you described above.  This can be handled
> either by switching off autocrlf, as you propose, or by cleaning up  
> the
> line endings.

(http://groups.google.com/group/msysgit/browse_thread/thread/978a3435c1cb0c81/70bac514a8b438ef?lnk=gst#70bac514a8b438ef 
)

Steffen went on to propose a patch to make autocrlf a sticky per- 
repository setting, but I think you shot it down.
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 28 of 58 in “Respect crlf attribute even if core.autocrlf has not been set”
  1. Respect crlf attribute even if core.autocrlf has not been setJohannes Schindelin, Jul 22, 2008
  2. Dmitry PotapovJul 22, 2008
  3. Johannes SchindelinJul 22, 2008
  4. Dmitry PotapovJul 23, 2008
  5. Junio C HamanoJul 23, 2008
  6. Johannes SchindelinJul 23, 2008
  7. Respect crlf attribute in "git add" even if core.autocrlf has not been setJohannes Schindelin, Jul 23, 2008
  8. Steffen ProhaskaJul 23, 2008
  9. Johannes SchindelinJul 23, 2008
  10. Dmitry PotapovJul 23, 2008
  11. Steffen ProhaskaJul 24, 2008
  12. Johannes SchindelinJul 24, 2008
  13. Dmitry PotapovJul 24, 2008
  14. Dmitry PotapovJul 24, 2008
  15. Johannes SchindelinJul 24, 2008
  16. Steffen ProhaskaJul 24, 2008
  17. Avery PennarunJul 24, 2008
  18. Johannes SchindelinJul 24, 2008
  19. Robin RosenbergJul 24, 2008
  20. Johannes SchindelinJul 24, 2008
  21. Junio C HamanoJul 23, 2008
  22. Johannes SchindelinJul 23, 2008
  23. Joshua JensenJul 23, 2008
  24. Avery PennarunJul 23, 2008
  25. Johannes SchindelinJul 23, 2008
  26. Eyvind BernhardsenJul 23, 2008
  27. Johannes SchindelinJul 23, 2008
  28. Eyvind BernhardsenJul 24, 2008
  29. Johannes SchindelinJul 25, 2008
  30. Eyvind BernhardsenJul 25, 2008
  31. Dmitry PotapovJul 25, 2008
  32. Eyvind BernhardsenJul 25, 2008
  33. Johannes SchindelinJul 26, 2008
  34. Eyvind BernhardsenJul 29, 2008
  35. Dmitry PotapovJul 29, 2008
  36. Eyvind BernhardsenJul 29, 2008
  37. Steffen ProhaskaJul 30, 2008
  38. Avery PennarunJul 30, 2008
  39. Steffen ProhaskaJul 30, 2008
  40. Avery PennarunJul 30, 2008
  41. Dmitry PotapovJul 30, 2008
  42. Avery PennarunJul 30, 2008
  43. TarmiganAug 3, 2008
  44. Dmitry PotapovAug 3, 2008
  45. TarmiganAug 3, 2008
  46. Dmitry PotapovAug 4, 2008
  47. Dmitry PotapovJul 30, 2008
  48. Eyvind BernhardsenAug 2, 2008
  49. Dmitry PotapovAug 3, 2008
  50. Robin RosenbergJul 23, 2008
  51. Junio C HamanoJul 23, 2008
  52. Johannes SchindelinJul 23, 2008
  53. Dmitry PotapovJul 23, 2008
  54. Junio C HamanoJul 23, 2008
  55. Johannes SchindelinJul 23, 2008
  56. Dmitry PotapovJul 24, 2008
  57. Johannes SchindelinJul 24, 2008
  58. Dmitry PotapovJul 24, 2008

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.