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

Bug 339609

Summary: [server] NPE on unstage in a new repository
Product: [ECD] Orion Reporter: John Arthorne <john.arthorne>
Component: GitAssignee: Project Inbox <orion.git-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: simon_kaegi, Szymon.Brandys, tomasz.zarna
Version: 0.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 339610    
Bug Blocks:    

Description John Arthorne CLA 2011-03-10 17:22:45 EST
Steps:

1) Create a new project using a new git repository (such as the auto-git-repo setting we're using on orion.eclipse.org)
2) Create a file in the project
3) Go to git status page.
4) Stage the change, and then unstage the change.

-> NPE occurs:

java.lang.NullPointerException
	at org.eclipse.jgit.lib.ObjectIdSubclassMap.index(ObjectIdSubclassMap.java:213)
	at org.eclipse.jgit.lib.ObjectIdSubclassMap.get(ObjectIdSubclassMap.java:89)
	at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:809)
	at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:724)
	at org.eclipse.jgit.api.ResetCommand.call(ResetCommand.java:149)
	at org.eclipse.orion.server.git.servlets.GitIndexHandlerV1.handlePost(GitIndexHandlerV1.java:130)
	at org.eclipse.orion.server.git.servlets.GitIndexHandlerV1.handleRequest(GitIndexHandlerV1.java:69)
	at org.eclipse.orion.server.git.servlets.GitIndexHandlerV1.handleRequest(GitIndexHandlerV1.java:1)
	at org.eclipse.orion.server.git.servlets.GitHandlerV1.handleRequest(GitHandlerV1.java:56)
	at org.eclipse.orion.server.git.servlets.GitHandlerV1.handleRequest(GitHandlerV1.java:1)
	at org.eclipse.orion.server.git.servlets.ServletGitHandler.handleRequest(ServletGitHandler.java:49)
	at org.eclipse.orion.server.git.servlets.ServletGitHandler.handleRequest(ServletGitHandler.java:1)
	at org.eclipse.orion.server.git.servlets.GitServlet.doGet(GitServlet.java:39)
	at org.eclipse.orion.server.git.servlets.GitServlet.doPost(GitServlet.java:58)
Comment 1 John Arthorne CLA 2011-03-10 17:28:28 EST
I have entered bug 339610 against JGit. As a workaround, Tomasz suggested we do an initial commit for free when creating the repository:

               File root = new File(new File(location), Constants.DOT_GIT);
               FileRepository repo = new FileRepository(root);
               repo.create();
               Git git = new Git(repo);
               git.add().addFilepattern(".").call();
               git.commit().setMessage("Initial commit").call();
Comment 2 John Arthorne CLA 2011-03-11 09:21:20 EST
Simon and I discussed this yesterday and decided to go ahead with the workaround. I'm leaving this open so we can remove this when the JGit bug is fixed.
Comment 3 John Arthorne CLA 2015-05-05 14:47:34 EDT
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:

https://dev.eclipse.org/mhonarc/lists/orion-dev/msg03444.html