Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347574 - NPE in Git Reset Hard fails with added files that exists in index, but not on disk
Summary: NPE in Git Reset Hard fails with added files that exists in index, but not on...
Status: VERIFIED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 1.0   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 350880 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-29 06:59 EDT by Robin Rosenberg CLA
Modified: 2011-10-20 09:17 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Rosenberg CLA 2011-05-29 06:59:09 EDT
What steps will reproduce the problem?
1. Add a new source file to a java project
2. Add it to the git repo with Team>Add
3. Remove the added resource from the file system (outside of eclipse)
   (optinally refresh project)
4. Use Team>Reset with the Hard option
5. NPE

If you instead add the file to the repository root, you will end up with an index that still contains the
extra entry after reset.

Running code coverage on Jgit reveals that we have a number of code paths in DirCacheCheckout that
are not covered by any test. According to Murphy's law untested code does not work.


-- Error Details --
Date: Sun May 29 11:36:47 CEST 2011
Message: An internal error occurred during: "Resetting to refs/heads/master".
Severity: Error
Product: Eclipse SDK 3.6.2.v201102101200 (org.eclipse.sdk.ide)
Plugin: org.eclipse.core.jobs
Session Data:
eclipse.buildId=M20110210-1200
java.version=1.6.0_25
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=sv_SE
Framework arguments:  -product org.eclipse.sdk.ide
Command-line arguments:  -product org.eclipse.sdk.ide -data /Users/me/SW/myegit -dev file:/Users/me/SW/egitcontrib/.metadata/.plugins/org.eclipse.pde.core/New_configuration (1)/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog


Exception Stack Trace:
java.lang.NullPointerException
at org.eclipse.jgit.dircache.DirCacheCheckout.processEntry(DirCacheCheckout.java:358)
at org.eclipse.jgit.dircache.DirCacheCheckout.prescanOneTree(DirCacheCheckout.java:282)
at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:382)
at org.eclipse.egit.core.op.ResetOperation.checkoutIndex(ResetOperation.java:250)
at org.eclipse.egit.core.op.ResetOperation.reset(ResetOperation.java:138)
at org.eclipse.egit.core.op.ResetOperation.access$0(ResetOperation.java:115)
at org.eclipse.egit.core.op.ResetOperation$1.run(ResetOperation.java:105)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1957)
at org.eclipse.egit.core.op.ResetOperation.execute(ResetOperation.java:109)
at org.eclipse.egit.ui.internal.job.JobUtil$1.run(JobUtil.java:50)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Christian Halstrick CLA 2011-10-12 04:32:29 EDT
Robin, tried hard to reproduce this on windows and linux. I even switched with jgit/egit to commits d203485/7bf4841 (which where in master 29.05.2011). But I can't reproduce this. Can you still reproduce this?
Comment 2 Robin Rosenberg CLA 2011-10-12 18:28:55 EDT
(In reply to comment #1)
> Robin, tried hard to reproduce this on windows and linux. I even switched with
> jgit/egit to commits d203485/7bf4841 (which where in master 29.05.2011). But I
> can't reproduce this. Can you still reproduce this?


I still get an NPE, but not in the same location, strangely I'm not 

java.lang.NullPointerException
	at org.eclipse.egit.core.ContainerTreeIterator.<init>(ContainerTreeIterator.java:124)
	at org.eclipse.egit.core.ContainerTreeIterator.createSubtreeIterator(ContainerTreeIterator.java:132)
	at org.eclipse.jgit.treewalk.AbstractTreeIterator.createSubtreeIterator(AbstractTreeIterator.java:527)
	at org.eclipse.jgit.treewalk.TreeWalk.enterSubtree(TreeWalk.java:907)
	at org.eclipse.jgit.treewalk.TreeWalk.next(TreeWalk.java:566)
	at org.eclipse.jgit.lib.IndexDiff.diff(IndexDiff.java:281)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry.calcIndexDiff(IndexDiffCacheEntry.java:263)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry.access$2(IndexDiffCacheEntry.java:254)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry$3.run(IndexDiffCacheEntry.java:149)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 3 Robin Rosenberg CLA 2011-10-16 16:10:13 EDT
See http://egit.eclipse.org/r/#change,4357 for JUnit Demo
Comment 4 Robin Rosenberg CLA 2011-10-17 17:31:09 EDT
*** Bug 350880 has been marked as a duplicate of this bug. ***
Comment 5 Robin Rosenberg CLA 2011-10-17 17:49:35 EDT
Patch posted: http://egit.eclipse.org/r/#change,4358
Comment 6 Matthias Sohn CLA 2011-10-19 08:39:47 EDT
merged as 2e43dcd6454d49d733d114a6c40ced05a3e93b8d
Comment 7 Dani Megert CLA 2011-10-20 09:17:10 EDT
Verified in 1.2.0.201110190928.