{"thread":{"id":"38419","subject":"git index containing tree extension for unknown path","startedAt":"2015-01-21T16:14:19Z","lastAt":"2015-01-23T06:23:45Z","messageCount":3,"participants":["Christian Halstrick","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"254992","messageId":"CAENte7gqKpqr=ENOEN_3s3Fz6gc-Kt70OJyZojbgwhR7YVX6Zg@mail.gmail.com","threadId":"38419","inReplyTo":null,"subject":"git index containing tree extension for unknown path","fromName":"Christian Halstrick","fromEmail":"christian.halstrick@gmail.com","sentAt":"2015-01-21T16:14:19Z","receivedAt":"2015-01-21T16:14:19Z","isPatch":false,"sender":{"key":"christian.halstrick@gmail.com","avatar":"https://gravatar.com/avatar/3598bf518644c7dc32d4dcd8e0554b6a313e12103011862402c83ae2854203ce?d=mp&s=160"},"body":"Is it allowed that the git index contains a tree extension mentioning\npatch 'x/y/z' while the only entry in the index is a '.gitattributes'\nfiles in the root?\n\nI have such a repo in a bug report against JGit [1]. Native git has no\nproblems with this repo but JGit can't read such an index. I am\nwondering whether such a index is valid.\n\n[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=457152\n"},{"id":"255028","messageId":"xmqqr3unx40n.fsf@gitster.dls.corp.google.com","threadId":"38419","inReplyTo":"CAENte7gqKpqr=ENOEN_3s3Fz6gc-Kt70OJyZojbgwhR7YVX6Zg@mail.gmail.com","subject":"Re: git index containing tree extension for unknown path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-21T20:39:04Z","receivedAt":"2015-01-21T20:39:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Halstrick <christian.halstrick@gmail.com> writes:\n\n> Is it allowed that the git index contains a tree extension mentioning\n> patch 'x/y/z' while the only entry in the index is a '.gitattributes'\n> files in the root?\n\nDepends on the definition of \"mention\", but it is not unexpected\nthat you see \"x\", \"y\", and \"z\" in the cache-tree extension as\ninvalidated nodes after you do something like this:\n\n\trm -fr test &&\n        git init test &&\n        cd test\n        mkdir -p x/y/z &&\n        >x/y/z/1 &&\n        git add x &&\n        git write-tree && # cache-tree is fully valid\n        mv x/y/z x/y/a &&\n        git add x # cache-tree invalidated\n\n\"z\", if appears, should still know that \"y\" is its parent and \"y\",\nif appears, should still know that \"x\" is its parent.  All of the\nthree should say they have been invalidated by showing a negative\nentry-count and show the \"correct\" subtree count that appear in the\nextension (i.e. if \"z\" is there as an invalidated leaf, it should\nsay \"-1 0\" to indicate an invalidated entry by a negative entry count,\nwith zero subtrees, and \"y\" would show \"-1 1\" to indicate an\ninvalidated entry with one subtree, namely \"z\", etc.).\n"},{"id":"255164","messageId":"CAENte7jr6mjz_xCuWpYKW7VzNcYhqEi5Nf_8JdDtyM46pVnfDg@mail.gmail.com","threadId":"38419","inReplyTo":"xmqqr3unx40n.fsf@gitster.dls.corp.google.com","subject":"Re: git index containing tree extension for unknown path","fromName":"Christian Halstrick","fromEmail":"christian.halstrick@gmail.com","sentAt":"2015-01-23T06:23:45Z","receivedAt":"2015-01-23T06:23:45Z","isPatch":false,"sender":{"key":"christian.halstrick@gmail.com","avatar":"https://gravatar.com/avatar/3598bf518644c7dc32d4dcd8e0554b6a313e12103011862402c83ae2854203ce?d=mp&s=160"},"body":"Thanks for the explanation. In my case it seems we have an invalid\nindex. I modified the gin script [1] to inspect the index and found\nvalid cached trees in the index for pathes for which the index has no\nentries. Will try to find out who/how the index was corrupted.\n\n[1] https://raw.githubusercontent.com/chalstrick/gin/master/gin\n\nOutput of the script\n\n> gin.py\n[header]\n  signature = DIRC\n  version = 2\n  entries = 1\n\n[entry]\n  entry = 1\n  ctime = 1421834321.9923096\n  mtime = 1420815554.0\n  dev = 2049\n  ino = 658461\n  mode = 100644\n  uid = 1000\n  gid = 1000\n  size = 42\n  sha1 = 6c6909e2b92e763e890a9a42695680762802a50a\n  flags = 14\n  assume-valid = False\n  extended = False\n  stage = (False, False)\n  name = .gitattributes\n\n[extension]\n  extension = 1\n  signature = TREE\n  size = 103\n\n[cachedTree]\n  name =\n  entryCnt = 2\n  subtreeCnt = 1\n  id = f59374e16868ce8385b4ee602c737f917da4af1b\n\n[cachedTree]\n  name = a\n  entryCnt = 1\n  subtreeCnt = 1\n  id = 4b5e60c30485a91ee60bd869ecc3b4d2b892fc3f\n\n[cachedTree]\n  name = b\n  entryCnt = 1\n  subtreeCnt = 1\n  id = 50bd519cc418878d4b0ffc27348afd710c188d6d\n\n[cachedTree]\n  name = c\n  entryCnt = 1\n  subtreeCnt = 0\n  id = 2b230fa0f3d19b497d3dd24e835691e3a921657f\n\n[checksum]\n  checksum = True\n  sha1 = 124680d4dec4758ee1ae28f546659d282952ebff\nCiao\n  Chris\nCiao\n  Chris\n\n\nOn Wed, Jan 21, 2015 at 9:39 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Christian Halstrick <christian.halstrick@gmail.com> writes:\n>\n>> Is it allowed that the git index contains a tree extension mentioning\n>> patch 'x/y/z' while the only entry in the index is a '.gitattributes'\n>> files in the root?\n>\n> Depends on the definition of \"mention\", but it is not unexpected\n> that you see \"x\", \"y\", and \"z\" in the cache-tree extension as\n> invalidated nodes after you do something like this:\n>\n>         rm -fr test &&\n>         git init test &&\n>         cd test\n>         mkdir -p x/y/z &&\n>         >x/y/z/1 &&\n>         git add x &&\n>         git write-tree && # cache-tree is fully valid\n>         mv x/y/z x/y/a &&\n>         git add x # cache-tree invalidated\n>\n> \"z\", if appears, should still know that \"y\" is its parent and \"y\",\n> if appears, should still know that \"x\" is its parent.  All of the\n> three should say they have been invalidated by showing a negative\n> entry-count and show the \"correct\" subtree count that appear in the\n> extension (i.e. if \"z\" is there as an invalidated leaf, it should\n> say \"-1 0\" to indicate an invalidated entry by a negative entry count,\n> with zero subtrees, and \"y\" would show \"-1 1\" to indicate an\n> invalidated entry with one subtree, namely \"z\", etc.).\n>\n>\n"}]}