Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
index 206d4062b7..05f59950ff 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
@@ -56,6 +56,7 @@ import org.eclipse.jgit.dircache.DirCacheEditor;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
@@ -267,6 +268,7 @@ public class ResetCommand extends GitCommand<Ref> {
tw.addTree(new DirCacheIterator(dc));
tw.addTree(commit.getTree());
tw.setFilter(PathFilterGroup.createFromStrings(filepaths));
+ tw.setRecursive(true);
while (tw.next()) {
final String path = tw.getPathString();
@@ -276,13 +278,18 @@ public class ResetCommand extends GitCommand<Ref> {
if (tree == null)
// file is not in the commit, remove from index
edit.add(new DirCacheEditor.DeletePath(path));
- else {
- // revert index to commit
+ else { // revert index to commit
+ // it seams that there is concurrent access to tree
+ // variable, therefore we need to keep references to
+ // entryFileMode and entryObjectId in local
+ // variables
+ final FileMode entryFileMode = tree.getEntryFileMode();
+ final ObjectId entryObjectId = tree.getEntryObjectId();
edit.add(new DirCacheEditor.PathEdit(path) {
@Override
public void apply(DirCacheEntry ent) {
- ent.setFileMode(tree.getEntryFileMode());
- ent.setObjectId(tree.getEntryObjectId());
+ ent.setFileMode(entryFileMode);
+ ent.setObjectId(entryObjectId);
ent.setLastModified(0);
}
});

Back to the top