Re: CRLF problems with Git on Win32
From: Dmitry Potapov <hidden>
Date: 2016-06-15 22:44:04
Hi Gregory, On Wed, Jan 09, 2008 at 05:37:07PM +0000, Gregory Jefferis wrote:
If LF text files checked in on Windows get turned into CRLF files on checkout by default then I think plenty of people would be surprised and probably unhappy.
LF text cannot be checked in with autocrlf=safe without marking that there is no CRLF conversation for this file. So, what you describe is impossible. IOW, you *always* get back what you put in the repository.
Similarly I think it would be a bad thing if a binary file that looked like LF only text got mangled on checkout by LF->CRLF conversion - although I agree that it would be possible to recover from this situation with a bit of juggling.
Again, you can't do that with autocrlf=safe. Yes, it is possible that someone else on Unix to put a file like this, but it is a rare event and easy to recover. So, it is a very small price to pay for cross-platform projects, and those who use the same platform are not affected at all!
The only way to prevent collateral damage is to consult .gitattributes on checkout (as Dmitry seemed to be assuming above)
Yes, I assumed this. Isn't it how it is implemented now?
static int crlf_to_worktree(const char *path, const char *src, size_t len,
struct strbuf *buf, int action)
{
char *to_free = NULL;
struct text_stat stats;
if ((action == CRLF_BINARY) || (action == CRLF_INPUT) ||
auto_crlf <= 0)
return 0;
If crlf=false for some file then action will be CRLF_BINARY, and
crlf_to_worktree will not convert LF to CRLF. Did I miss somthing?
Dmitry