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

Re: CRLF problems with Git on Win32

From
Steffen Prohaska <prohaska@zib.de>
Date
Jan 11, 2008, 07:10 UTC
Message-ID
<7EAB1DA8-627D-455E-AA23-C404FDC615D9@zib.de>
In-Reply-To
<alpine.LFD.1.00.0801101556380.3148@woody.linux-foundation.org>
On Jan 11, 2008, at 1:02 AM, Linus Torvalds wrote:
Show 20 quoted lines
>
>
> On Thu, 10 Jan 2008, Gregory Jefferis wrote:
>>
>> So this is what has to be accommodated.  But instead of having  
>> autocrlf
>> always set on Windows and always converting to LF in the  
>> repository, why not
>> do nothing by default [ .. ]
>
> Why? You can screw yourself more, and much more easily (and much more
> subtly), by leaving CRLF alone on Windows.
>
> The thing is, 99.9% of all people will be *much* better off with
> autocrlf=true on Windows than with it defaulting to off (or even  
> fail).
>
> Isn't *that* the whole point of having a default? Pick the thing  
> that is
> the right thing for almost everybody?

Are you also for "autocrlf=input" as the default on Unix? This is the second half of the solution to the cross-platform problem ...

Show 12 quoted lines
> And no, "but think of the children.." is not a valid argument.  
> Sure, you
> *can* corrupt binary imags with CRLF conversion. But it's really quite
> hard, since the git heuristics for guessing are rather good. You  
> really
> have to work at it, and if you do, you're pretty damn likely to  
> know about
> the issue, so that 0.1% that really needs to not convert (and it's  
> usually
> one specific file type!) would probably not even turn off CRLF, but  
> rather
> add a .gitattributes entry for that one filetype!

... and then Windows and Unix users would have the same chance of data corruption.

Which is very low, yes, but unfortunately it already hit me once and I didn't immediately recognized what happend. I guess that less experienced git used would have a harder time to understand. However, I don't have a test case at hand. I should probably better go and find one. So for now, you may just want to ignore this comment.

Yet, I'm a bit paranoid about the potential data corruption. The way data would be corrupted during commit can't be easily fixed. You only have a chance for fixing this if you recognize the problem before you delete the file in your work tree. But because git is extremely good at preserving your data once you committed a file, I tend to feel _very_ safe after I committed and I am teaching all people that once they committed data to git they'll not loose it until the reflog expires (well and obviously they must not delete .git).

Show 6 quoted lines
> (Side note: if there are known filetype extensions that have  
> problems with
> the git guessing, we sure as heck could take the filename into account
> when guessing! There's absolutely nothing that says that we only  
> have to
> look at the contents when guessing about the text/binary thing!)

Looking on the content seems the right thing to do. The filetype extension could be misleading.

Maybe a mechanism similar to the file command would be more valuable. I guess a stripped down variant should be sufficient.

	Steffen
Previous: Junio C HamanoNext: Linus Torvalds
Message 58 of 113 in “CRLF problems with Git on Win32”
  1. Peter KarlssonJan 7, 2008
  2. Steffen ProhaskaJan 7, 2008
  3. Junio C HamanoJan 7, 2008
  4. Steffen ProhaskaJan 7, 2008
  5. Jeff KingJan 7, 2008
  6. Robin RosenbergJan 7, 2008
  7. Johannes SchindelinJan 7, 2008
  8. Robin RosenbergJan 7, 2008
  9. Johannes SchindelinJan 7, 2008
  10. Steffen ProhaskaJan 7, 2008
  11. Linus TorvaldsJan 7, 2008
  12. Peter KarlssonJan 8, 2008
  13. Johannes SchindelinJan 9, 2008
  14. Steffen ProhaskaJan 9, 2008
  15. Gregory JefferisJan 9, 2008
  16. Johannes SchindelinJan 9, 2008
  17. Dmitry PotapovJan 9, 2008
  18. Dmitry PotapovJan 9, 2008
  19. Gregory JefferisJan 9, 2008
  20. Dmitry PotapovJan 9, 2008
  21. Thomas NeumannJan 7, 2008
  22. Peter KarlssonJan 8, 2008
  23. Jeff KingJan 8, 2008
  24. Johannes SchindelinJan 8, 2008
  25. Johannes SchindelinJan 8, 2008
  26. Peter HarrisJan 8, 2008
  27. Peter KarlssonJan 8, 2008
  28. Kelvie WongJan 8, 2008
  29. Dmitry PotapovJan 8, 2008
  30. Jan HudecJan 9, 2008
  31. Peter KlavinsJan 7, 2008
  32. Steffen ProhaskaJan 7, 2008
  33. Peter KarlssonJan 7, 2008
  34. Peter KlavinsJan 7, 2008
  35. Steffen ProhaskaJan 7, 2008
  36. Junio C HamanoJan 7, 2008
  37. Linus TorvaldsJan 7, 2008
  38. Gregory JefferisJan 7, 2008
  39. git and unicodeGonzalo Garramuño, Jan 8, 2008
  40. Remi VanicatJan 8, 2008
  41. Robin RosenbergJan 8, 2008
  42. Steffen ProhaskaJan 8, 2008
  43. Junio C HamanoJan 8, 2008
  44. Jeff KingJan 8, 2008
  45. Junio C HamanoJan 8, 2008
  46. Gregory JefferisJan 8, 2008
  47. Marius Storm-OlsenJan 8, 2008
  48. J. Bruce FieldsJan 8, 2008
  49. Steffen ProhaskaJan 8, 2008
  50. Junio C HamanoJan 8, 2008
  51. Junio C HamanoJan 8, 2008
  52. Gregory JefferisJan 10, 2008
  53. Linus TorvaldsJan 10, 2008
  54. Gregory JefferisJan 10, 2008
  55. Dmitry PotapovJan 10, 2008
  56. Linus TorvaldsJan 11, 2008
  57. Junio C HamanoJan 11, 2008
  58. Steffen ProhaskaJan 11, 2008
  59. Linus TorvaldsJan 11, 2008
  60. Steffen ProhaskaJan 11, 2008
  61. Linus TorvaldsJan 11, 2008
  62. Steffen ProhaskaJan 11, 2008
  63. Linus TorvaldsJan 11, 2008
  64. Steffen ProhaskaJan 11, 2008
  65. Linus TorvaldsJan 11, 2008
  66. Sam RavnborgJan 11, 2008
  67. Johannes SchindelinJan 11, 2008
  68. Sam RavnborgJan 11, 2008
  69. Dmitry PotapovJan 12, 2008
  70. [WIP] safecrlf: Add mechanism to warn about irreversible crlf conversionsSteffen Prohaska, Jan 12, 2008
  71. Dmitry PotapovJan 12, 2008
  72. [WIP v2] safecrlf: Add mechanism to warn about irreversible crlf conversionsSteffen Prohaska, Jan 13, 2008
  73. Christer WeinigelJan 11, 2008
  74. David KågedalJan 14, 2008
  75. Gregory JefferisJan 11, 2008
  76. Dmitry PotapovJan 12, 2008
  77. Rogan DawesJan 10, 2008
  78. Gregory JefferisJan 10, 2008
  79. Junio C HamanoJan 11, 2008
  80. Steffen ProhaskaJan 8, 2008
  81. J. Bruce FieldsJan 8, 2008
  82. Junio C HamanoJan 8, 2008
  83. Steffen ProhaskaJan 8, 2008
  84. Junio C HamanoJan 8, 2008
  85. Dmitry PotapovJan 8, 2008
  86. Steffen ProhaskaJan 8, 2008
  87. Junio C HamanoJan 8, 2008
  88. Steffen ProhaskaJan 8, 2008
  89. Steffen ProhaskaJan 8, 2008
  90. Linus TorvaldsJan 8, 2008
  91. Junio C HamanoJan 9, 2008
  92. Junio C HamanoJan 8, 2008
  93. Robin RosenbergJan 8, 2008
  94. Linus TorvaldsJan 8, 2008
  95. SeanJan 8, 2008
  96. Dmitry PotapovJan 8, 2008
  97. Linus TorvaldsJan 9, 2008
  98. Abdelrazak YounesJan 9, 2008
  99. Johannes SchindelinJan 9, 2008
  100. Junio C HamanoJan 9, 2008
  101. Johannes SchindelinJan 9, 2008
  102. Steffen ProhaskaJan 9, 2008
  103. Johannes SchindelinJan 9, 2008
  104. Johannes SchindelinJan 9, 2008
  105. Steffen ProhaskaJan 9, 2008
  106. Peter KarlssonJan 10, 2008
  107. Johannes SchindelinJan 10, 2008
  108. Miles BaderJan 11, 2008
  109. Miles BaderJan 11, 2008
  110. Peter KarlssonJan 10, 2008
  111. Peter HarrisJan 10, 2008
  112. Peter KarlssonJan 11, 2008
  113. Peter HarrisJan 11, 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.