{"thread":{"id":"30584","subject":"git stash destroys hard links","startedAt":"2012-05-22T04:24:01Z","lastAt":"2012-05-22T17:52:00Z","messageCount":3,"participants":["Steven Penny","Junio C Hamano","Angus Hammond"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"191868","messageId":"CAAXzdLWadNg9d_i8fZTawaxYm3ytcGCT4pzeth=LxrQYEO-3ww@mail.gmail.com","threadId":"30584","inReplyTo":null,"subject":"git stash destroys hard links","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-22T04:24:01Z","receivedAt":"2012-05-22T04:24:01Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"I dont know if this is even fixable, but I wanted to at least mention it.\nPerforming a git stash will destroy any hard links and replace them with simply\na copy of the file.\n\n$ mkdir test\n$ cd test\n$ git init\n$ touch foobar.sh\n$ git add -A\n$ git commit -m 'first commit'\n\n$ ln foobar.sh foobar-link.sh\n\n$ ls -l\ntotal 0\n-rw-r--r-- 2 Steven None 0 May 21 23:18 foobar.sh\n-rw-r--r-- 2 Steven None 0 May 21 23:18 foobar-link.sh\n\n$ git stash -u\n$ git stash pop\n\n$ ls -l\ntotal 0\n-rw-r--r-- 1 Steven None 0 May 21 23:18 foobar.sh\n-rw-r--r-- 1 Steven None 0 May 21 23:18 foobar-link.sh\n"},{"id":"191910","messageId":"7v62bo5d0z.fsf@alter.siamese.dyndns.org","threadId":"30584","inReplyTo":"CAAXzdLWadNg9d_i8fZTawaxYm3ytcGCT4pzeth=LxrQYEO-3ww@mail.gmail.com","subject":"Re: git stash destroys hard links","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-22T17:41:32Z","receivedAt":"2012-05-22T17:41:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> I dont know if this is even fixable, but I wanted to at least mention it.\n\nI do not think there is anything specific to stash.  Whenever we write out\nresults of an operation to a file in the working tree, we first unlink(2)\nand then creat(2), which essentially breaks hardlinked files and avoids\nupdating some _other_ paths that share the underlying file with the\nupdated path.\n"},{"id":"191912","messageId":"CAOBOgRYtMi38f63G2Nzd3--FsmN0F8geFi-AHxL2L2MMHWHFHA@mail.gmail.com","threadId":"30584","inReplyTo":"CAAXzdLWadNg9d_i8fZTawaxYm3ytcGCT4pzeth=LxrQYEO-3ww@mail.gmail.com","subject":"Re: git stash destroys hard links","fromName":"Angus Hammond","fromEmail":"angusgh@gmail.com","sentAt":"2012-05-22T17:52:00Z","receivedAt":"2012-05-22T17:52:00Z","isPatch":false,"sender":{"key":"angusgh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1839397?v=4"},"body":">From the very quick and unscientific test that I just did, it doesn't\nappear that git commits hard links, it just collapses them into\nseparate regular files (presumably to avoid changes in one place\nmucking things up elsewhere without git knowing about it). I don't\nthink it makes much sense to stash hardlinks if the policy is to\nforget them in commits.\nThanks\nAngus\n"}]}