{"thread":{"id":"16294","subject":"Why is TreeWalk.forPath(...) returning null","startedAt":"2008-11-12T22:24:30Z","lastAt":"2008-11-12T22:52:54Z","messageCount":3,"participants":["Farrukh Najmi","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"95635","messageId":"491B579E.6050408@wellfleetsoftware.com","threadId":"16294","inReplyTo":null,"subject":"Why is TreeWalk.forPath(...) returning null","fromName":"Farrukh Najmi","fromEmail":"farrukh@wellfleetsoftware.com","sentAt":"2008-11-12T22:24:30Z","receivedAt":"2008-11-12T22:24:30Z","isPatch":false,"sender":{"key":"farrukh@wellfleetsoftware.com","avatar":"https://gravatar.com/avatar/92ea2740412df69f91bfc2c8a6aae915e01802f2bba9d646689e0ee3aa2d7d3f?d=mp&s=160"},"body":"\nMy \"git status\" command shows:\n\n# On branch master\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#    modified:   xml/minDB/SubmitObjectsRequest_CMSScheme.xml\n\nThe file above was committed and then modified. I want to use jgit to \nfind the comitted version of that file.\n\nWhen I do the following code I get a null treeWalk? Why is that? What \nshould I specify for path instead?\n\n            String path = \"xml/minDB/SubmitObjectsRequest_CMSScheme.xml\";\n            String versionName = Constants.HEAD;\n\n            Commit commit = repository.mapCommit(versionName);\n\n            if (commit == null) {\n                log.trace(\"Did not find Commit. versionName:\" + \nversionName);\n            } else {\n                ObjectId[] ids = {commit.getTree().getId()};\n                TreeWalk treeWalk = TreeWalk.forPath(repository, path, ids);\n            }\n\nThanks.\n\n-- \nRegards,\nFarrukh Najmi\n\nWeb: http://www.wellfleetsoftware.com\n"},{"id":"95638","messageId":"20081112224236.GX2932@spearce.org","threadId":"16294","inReplyTo":"491B579E.6050408@wellfleetsoftware.com","subject":"Re: Why is TreeWalk.forPath(...) returning null","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-11-12T22:42:36Z","receivedAt":"2008-11-12T22:42:36Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Farrukh Najmi <farrukh@wellfleetsoftware.com> wrote:\n>\n> My \"git status\" command shows:\n>\n> # On branch master\n> # Changed but not updated:\n> #   (use \"git add <file>...\" to update what will be committed)\n> #\n> #    modified:   xml/minDB/SubmitObjectsRequest_CMSScheme.xml\n>\n> The file above was committed and then modified. I want to use jgit to  \n> find the comitted version of that file.\n>\n> When I do the following code I get a null treeWalk? Why is that? What  \n> should I specify for path instead?\n>\n>            String path = \"xml/minDB/SubmitObjectsRequest_CMSScheme.xml\";\n>            String versionName = Constants.HEAD;\n>\n>            Commit commit = repository.mapCommit(versionName);\n>\n>            if (commit == null) {\n>                log.trace(\"Did not find Commit. versionName:\" +  \n> versionName);\n>            } else {\n>                ObjectId[] ids = {commit.getTree().getId()};\n>                TreeWalk treeWalk = TreeWalk.forPath(repository, path, ids);\n>            }\n\nHuh.  That should have worked.\n\nTreeWalk.forPath returns null if the path doesn't get found.  So\nit sounds like jgit isn't matching the path.  Its a pretty simple\noperation, I'm not sure why its failing here.  I'd run it through\na debugger to try and see why the TreeWalk didn't match your path.\n\nYour code is logically the same as:\n\n  git rev-parse HEAD:$path\n\nso it should find the blob if Git would have found it.\n\n-- \nShawn.\n"},{"id":"95641","messageId":"491B5E46.6000706@wellfleetsoftware.com","threadId":"16294","inReplyTo":"20081112224236.GX2932@spearce.org","subject":"Re: Why is TreeWalk.forPath(...) returning null","fromName":"Farrukh Najmi","fromEmail":"farrukh@wellfleetsoftware.com","sentAt":"2008-11-12T22:52:54Z","receivedAt":"2008-11-12T22:52:54Z","isPatch":false,"sender":{"key":"farrukh@wellfleetsoftware.com","avatar":"https://gravatar.com/avatar/92ea2740412df69f91bfc2c8a6aae915e01802f2bba9d646689e0ee3aa2d7d3f?d=mp&s=160"},"body":"Shawn O. Pearce wrote:\n> Farrukh Najmi <farrukh@wellfleetsoftware.com> wrote:\n>   \n>> My \"git status\" command shows:\n>>\n>> # On branch master\n>> # Changed but not updated:\n>> #   (use \"git add <file>...\" to update what will be committed)\n>> #\n>> #    modified:   xml/minDB/SubmitObjectsRequest_CMSScheme.xml\n>>\n>> The file above was committed and then modified. I want to use jgit to  \n>> find the comitted version of that file.\n>>\n>> When I do the following code I get a null treeWalk? Why is that? What  \n>> should I specify for path instead?\n>>\n>>            String path = \"xml/minDB/SubmitObjectsRequest_CMSScheme.xml\";\n>>            String versionName = Constants.HEAD;\n>>\n>>            Commit commit = repository.mapCommit(versionName);\n>>\n>>            if (commit == null) {\n>>                log.trace(\"Did not find Commit. versionName:\" +  \n>> versionName);\n>>            } else {\n>>                ObjectId[] ids = {commit.getTree().getId()};\n>>                TreeWalk treeWalk = TreeWalk.forPath(repository, path, ids);\n>>            }\n>>     \n>\n> Huh.  That should have worked.\n>\n> TreeWalk.forPath returns null if the path doesn't get found.  So\n> it sounds like jgit isn't matching the path.  Its a pretty simple\n> operation, I'm not sure why its failing here.  I'd run it through\n> a debugger to try and see why the TreeWalk didn't match your path.\n>\n> Your code is logically the same as:\n>\n>   git rev-parse HEAD:$path\n>\n> so it should find the blob if Git would have found it.\n>\n>   \n\nMy bad. I had a type in the path in my junit test  :-[\nIts working as expected. Thanks.\n\n-- \nRegards,\nFarrukh Najmi\n\nWeb: http://www.wellfleetsoftware.com\n"}]}