Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368370

Summary: Repository#resolve() methods returns invalid objectIds when using params like refs/heads/0.1-0^{tree}:admin/appdemo/Main.tpl
Product: [Technology] JGit Reporter: Daniel Pacak <pacak.daniel>
Component: JGitAssignee: Kevin Sawicki <kevin>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 1.2   
Target Milestone: 1.3-M1   
Hardware: All   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Test Git repo and java unit test showing a bug. none

Description Daniel Pacak CLA 2012-01-11 12:10:05 EST
Created attachment 209322 [details]
Test Git repo and java unit test showing a bug.

I found the case when the org.eclipse.jgit.lib.Repository#resolve() methods returns invalid objectId(s).

Attached you can find a small Git repository and a maven project with the unit test which demonstrates invalid behavior.
Note that in the test repo I have a branch named '0.1-0' and I want to retrieve the content of a file from this branch under the admin/appdemo/Main.tpl path.
It means that somewhere in my code I'm calling:

org.eclipse.jgit.lib.Repository#resolve("refs/heads/0.1-0^{tree}:admin/appdemo/Main.tpl");

which returns pointer to a tree object instead of a blob with Main.tpl content!!

When using other Git clients (Eclipse Git plugin or command line git-scm) I can retrieve the content of all files without any problems.

What is more, when I'm using a bit different API the problem disappears (there are two methods in my Java class which are supposed to do exactly the same thing but are using slightly different API: RepositoryManager#getResourceAsString() and RepositoryManager#getResourceAsString2()).

Could you take a look at that issue please?
Thanks in advance,
Daniel Pacak
Comment 1 Kevin Sawicki CLA 2012-01-13 16:28:20 EST
Proposed fix pushed to: http://egit.eclipse.org/r/#change,4956
Comment 2 Kevin Sawicki CLA 2012-01-15 19:19:44 EST
Merged into master as commit 03b5416a35ad78773fb0a97a98686fec18c0c05e