{"thread":{"id":"19636","subject":"Cygwin: Initial clone of repo containing .gitattributes has modified files","startedAt":"2009-06-02T12:47:34Z","lastAt":"2009-06-02T15:56:22Z","messageCount":3,"participants":["Raman Gupta","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115240","messageId":"4A251F66.2020809@fastmail.fm","threadId":"19636","inReplyTo":null,"subject":"Cygwin: Initial clone of repo containing .gitattributes has modified files","fromName":"Raman Gupta","fromEmail":"rocketraman@fastmail.fm","sentAt":"2009-06-02T12:47:34Z","receivedAt":"2009-06-02T12:47:34Z","isPatch":false,"sender":{"key":"rocketraman@fastmail.fm","avatar":null},"body":"When a repository containing a .gitattributes file, which contains\nother files with -crlf set is cloned on cygwin, with autocrlf = true,\nthe initial checkout of the working copy sets the line endings for the\n-crlf files incorrectly (it ignores the .gitattributes, presumably\nbecause it hasn't been checked out yet).\n\nAfter the checkout has been done, git does correctly mark the files\nwith -crlf as \"modified\" and a simple reset --hard fixes it, but this\nis very confusing for the user as the user has not done anything -- it\nis git itself that has \"modified\" the file by not assigning the\ncorrect line endings.\n\nReproduction recipe (on a cygwin binmode mount):\n\n---------------------------------------------------\n$ git --version\ngit version 1.6.1.2\n$ git config --global core.autocrlf true\n$ git config --global core.safecrlf true\n$ mkdir temp.git; cd temp.git; git init\n$ cat | unix2dos > file_dos\nDOS\nline\nendings\n^D\n$ cat > file_unix\nUNIX\nline\nendings\n^D\n$ cat > .gitattributes\n.gitattributes -crlf\nfile_unix -crlf\n^D\n$ git add .gitattributes *\n$ git commit -m \"Test\"\n$ cd ..\n$ git clone temp.git tempclone.git\n$ cd tempclone.git\n$ git status\n...\n#      modified:  .gitattributes\n#      modified:  file_unix\n...\n---------------------------------------------------\n\nAlso, in a related issue, git on cygwin requires .gitattributes itself\nto be included in .gitattributes, otherwise with safecrlf = true you get:\n\n$ git add .gitattributes\nfatal: LF would be replaced by CRLF in .gitattributes\n\n(since .gitattributes created with a cygwin editor on a binmode mount\nuses unix line endings)\n\nCheers,\nRaman Gupta\n"},{"id":"115258","messageId":"7vd49mfxcv.fsf@alter.siamese.dyndns.org","threadId":"19636","inReplyTo":"4A251F66.2020809@fastmail.fm","subject":"Re: Cygwin: Initial clone of repo containing .gitattributes has modified files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-02T15:50:56Z","receivedAt":"2009-06-02T15:50:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Raman Gupta <rocketraman@fastmail.fm> writes:\n\n> When a repository containing a .gitattributes file, which contains\n> other files with -crlf set is cloned on cygwin, with autocrlf = true,\n> the initial checkout of the working copy sets the line endings for the\n> -crlf files incorrectly (it ignores the .gitattributes, presumably\n> because it hasn't been checked out yet).\n\nI think this is what v1.6.3-rc0~83^2~1 (Read attributes from the index\nthat is being checked out, 2009-03-13) was about.\n\nI see you are using a version based on 1.6.1.2; isn't there a newer Cygwin\npackaged one available?\n"},{"id":"115259","messageId":"4A254BA6.3080601@fastmail.fm","threadId":"19636","inReplyTo":"7vd49mfxcv.fsf@alter.siamese.dyndns.org","subject":"Re: Cygwin: Initial clone of repo containing .gitattributes has modified files","fromName":"Raman Gupta","fromEmail":"rocketraman@fastmail.fm","sentAt":"2009-06-02T15:56:22Z","receivedAt":"2009-06-02T15:56:22Z","isPatch":false,"sender":{"key":"rocketraman@fastmail.fm","avatar":null},"body":"Junio C Hamano wrote:\n> Raman Gupta <rocketraman@fastmail.fm> writes:\n> \n>> When a repository containing a .gitattributes file, which contains\n>> other files with -crlf set is cloned on cygwin, with autocrlf = true,\n>> the initial checkout of the working copy sets the line endings for the\n>> -crlf files incorrectly (it ignores the .gitattributes, presumably\n>> because it hasn't been checked out yet).\n> \n> I think this is what v1.6.3-rc0~83^2~1 (Read attributes from the index\n> that is being checked out, 2009-03-13) was about.\n\nThanks! I looked for the fix but didn't find any reference to it. Sorry.\n\n> I see you are using \n\nActually, I use Linux -- its my coworkers that use cygwin! Bleh! :)\n\n> a version based on 1.6.1.2; isn't there a newer Cygwin\n> packaged one available?\n\nNope. That is the latest available as of this morning (at least in the\ncygwin non-experimental branch).\n\nCheers,\nRaman\n"}]}