{"thread":{"id":"16695","subject":"Unable to index file","startedAt":"2008-12-12T14:47:29Z","lastAt":"2008-12-12T20:33:42Z","messageCount":5,"participants":["Ramon Tayag","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"97695","messageId":"f25d5ad20812120647m646698d7t9849c8ccb08c465e@mail.gmail.com","threadId":"16695","inReplyTo":null,"subject":"Unable to index file","fromName":"Ramon Tayag","fromEmail":"ramon.tayag@gmail.com","sentAt":"2008-12-12T14:47:29Z","receivedAt":"2008-12-12T14:47:29Z","isPatch":false,"sender":{"key":"ramon.tayag@gmail.com","avatar":null},"body":"Hi everyone,\n\nI've come across a problem that I don't believe lies in Rails.  You\nneedn't be familiar, I think, with Rails to see what's wrong.\n\nI can't seem to add the files that are in\nhttp://dev.rubyonrails.org/archive/rails_edge.zip\n\n1) Unpack the zip\n2) Initialize a git repo inside the folder that was unpacked\n3) git add .\n\nSee the errors.. :o http://pastie.org/337571\n\nThanks,\nRamon Tayag\n"},{"id":"97716","messageId":"alpine.LFD.2.00.0812120956050.3340@localhost.localdomain","threadId":"16695","inReplyTo":"f25d5ad20812120647m646698d7t9849c8ccb08c465e@mail.gmail.com","subject":"Re: Unable to index file","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-12-12T18:07:51Z","receivedAt":"2008-12-12T18:07:51Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 12 Dec 2008, Ramon Tayag wrote:\n> \n> I've come across a problem that I don't believe lies in Rails.  You\n> needn't be familiar, I think, with Rails to see what's wrong.\n> \n> I can't seem to add the files that are in\n> http://dev.rubyonrails.org/archive/rails_edge.zip\n> \n> 1) Unpack the zip\n> 2) Initialize a git repo inside the folder that was unpacked\n> 3) git add .\n> \n> See the errors.. :o http://pastie.org/337571\n\nWhat platform/filesystem is this?\n\nGit is rather particular about symlinks, and it looks like your platform \ndoes something odd, and that makes git unhappy about your symlink.\n\nIn particular:\n\n\tls -l vendor/rails/actionpack/test/fixtures/layout_tests/layouts/ \n\t...\n\tlrwxrwxrwx 1 root root 48 2008-12-12 18:22 symlinked -> ../../symlink_parent\n\nnotice how the symlink content is \"../../symlink_parent\", but then take a \nlook at the _size_ of the symlink: 48 bytes.\n\nGit expects the lstat() information to match the return from readlink(), \nand it doesn't.\n\nFor exact details, see \"index_path()\" in sha1_file.c:\n\n        case S_IFLNK:   \n                len = xsize_t(st->st_size);\n                target = xmalloc(len + 1);\n                if (readlink(path, target, len + 1) != st->st_size) {\n                        char *errstr = strerror(errno);\n\nie we consider it an error if we get less than st_size characters back \nfrom readlink().\n\nNow, admittedly git is probably being really annoyingly anal about this \nall, and we probably should loosen the restrictions on it a bit, but I'd \nlike to know why it happens. I cannot recall this having been reported \nbefore, so it's some specific filesystem or OS that causes this, I think.\n\n\t\tLinus\n"},{"id":"97717","messageId":"alpine.LFD.2.00.0812121013560.3340@localhost.localdomain","threadId":"16695","inReplyTo":"alpine.LFD.2.00.0812120956050.3340@localhost.localdomain","subject":"Re: Unable to index file","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-12-12T18:15:58Z","receivedAt":"2008-12-12T18:15:58Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 12 Dec 2008, Linus Torvalds wrote:\n> \n> Now, admittedly git is probably being really annoyingly anal about this \n> all, and we probably should loosen the restrictions on it a bit, but I'd \n> like to know why it happens. I cannot recall this having been reported \n> before, so it's some specific filesystem or OS that causes this, I think.\n\nAnyway, the \"loosen the symlink lstat() requirements\" patch would likely \nlook something like this. I can't really test it, though, since I only \nhave filesystems that have matching lstat()/readlink() sizes.\n\n\t\tLinus\n---\n sha1_file.c |   11 ++++++-----\n 1 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 0e021c5..222c793 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2522,9 +2522,9 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n \n int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object)\n {\n-\tint fd;\n+\tint fd, len;\n \tchar *target;\n-\tsize_t len;\n+\tsize_t bufsize;\n \n \tswitch (st->st_mode & S_IFMT) {\n \tcase S_IFREG:\n@@ -2537,9 +2537,10 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write\n \t\t\t\t     path);\n \t\tbreak;\n \tcase S_IFLNK:\n-\t\tlen = xsize_t(st->st_size);\n-\t\ttarget = xmalloc(len + 1);\n-\t\tif (readlink(path, target, len + 1) != st->st_size) {\n+\t\tbufsize = 1+xsize_t(st->st_size);\n+\t\ttarget = xmalloc(bufsize);\n+\t\tlen = readlink(path, target, bufsize);\n+\t\tif (len < 0) {\n \t\t\tchar *errstr = strerror(errno);\n \t\t\tfree(target);\n \t\t\treturn error(\"readlink(\\\"%s\\\"): %s\", path,\n"},{"id":"97736","messageId":"f25d5ad20812121227o77cf2bw34e6bc15d9801215@mail.gmail.com","threadId":"16695","inReplyTo":"alpine.LFD.2.00.0812120956050.3340@localhost.localdomain","subject":"Re: Unable to index file","fromName":"Ramon Tayag","fromEmail":"ramon.tayag@gmail.com","sentAt":"2008-12-12T20:27:59Z","receivedAt":"2008-12-12T20:27:59Z","isPatch":false,"sender":{"key":"ramon.tayag@gmail.com","avatar":null},"body":"Oh thank you for your very detailed explanation.  I was bothering\npeople on #rubyonrails and #git but got no answers.\n\nI'm on Ubuntu 8.10.  The files I'm working on live on an NTFS drive\n(my \"storage\" drive; yes, I still have to boot into Windows).  If it\nbeing on NTFS makes a difference I'll try this on ext3 and let you\nknow what happens :)\n\nThanks,\nRamon Tayag\n\n\n\nOn Sat, Dec 13, 2008 at 2:07 AM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n>\n>\n> On Fri, 12 Dec 2008, Ramon Tayag wrote:\n>>\n>> I've come across a problem that I don't believe lies in Rails.  You\n>> needn't be familiar, I think, with Rails to see what's wrong.\n>>\n>> I can't seem to add the files that are in\n>> http://dev.rubyonrails.org/archive/rails_edge.zip\n>>\n>> 1) Unpack the zip\n>> 2) Initialize a git repo inside the folder that was unpacked\n>> 3) git add .\n>>\n>> See the errors.. :o http://pastie.org/337571\n>\n> What platform/filesystem is this?\n>\n> Git is rather particular about symlinks, and it looks like your platform\n> does something odd, and that makes git unhappy about your symlink.\n>\n> In particular:\n>\n>        ls -l vendor/rails/actionpack/test/fixtures/layout_tests/layouts/\n>        ...\n>        lrwxrwxrwx 1 root root 48 2008-12-12 18:22 symlinked -> ../../symlink_parent\n>\n> notice how the symlink content is \"../../symlink_parent\", but then take a\n> look at the _size_ of the symlink: 48 bytes.\n>\n> Git expects the lstat() information to match the return from readlink(),\n> and it doesn't.\n>\n> For exact details, see \"index_path()\" in sha1_file.c:\n>\n>        case S_IFLNK:\n>                len = xsize_t(st->st_size);\n>                target = xmalloc(len + 1);\n>                if (readlink(path, target, len + 1) != st->st_size) {\n>                        char *errstr = strerror(errno);\n>\n> ie we consider it an error if we get less than st_size characters back\n> from readlink().\n>\n> Now, admittedly git is probably being really annoyingly anal about this\n> all, and we probably should loosen the restrictions on it a bit, but I'd\n> like to know why it happens. I cannot recall this having been reported\n> before, so it's some specific filesystem or OS that causes this, I think.\n>\n>                Linus\n>\n"},{"id":"97737","messageId":"alpine.LFD.2.00.0812121232561.3340@localhost.localdomain","threadId":"16695","inReplyTo":"f25d5ad20812121227o77cf2bw34e6bc15d9801215@mail.gmail.com","subject":"Re: Unable to index file","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-12-12T20:33:42Z","receivedAt":"2008-12-12T20:33:42Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 13 Dec 2008, Ramon Tayag wrote:\n> \n> I'm on Ubuntu 8.10.  The files I'm working on live on an NTFS drive\n> (my \"storage\" drive; yes, I still have to boot into Windows).  If it\n> being on NTFS makes a difference I'll try this on ext3 and let you\n> know what happens :)\n\nOk, it's almost certainly the NTFS part.\n\nAnd at the same time, I'm almost certain that my patch should fix it and \nis the right thing for git to do anyway. \n\n\t\tLinus\n"}]}