Browse Source

Cleanup TreeWalk creation/release inside StashApplyCommand

The TreeWalk constructor doesn't throw in a meaninful way that
requires cleanup of the not-yet-created TreeWalk.

Hoist the constructor outside of the try/finally and remove the
now unnecessary != null check during the finally.

Change-Id: If5b8bb91562715df0699726648123a47426b9850
stable-3.6
Shawn Pearce 10 years ago
parent
commit
b88f3a2a2c
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java

6
org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java

@ -329,9 +329,8 @@ public class StashApplyCommand extends GitCommand<ObjectId> {
private void resetUntracked(RevTree tree) throws CheckoutConflictException,
IOException {
TreeWalk walk = null;
TreeWalk walk = new TreeWalk(repo); // maybe NameConflictTreeWalk;
try {
walk = new TreeWalk(repo); // maybe NameConflictTreeWalk?
walk.addTree(tree);
walk.addTree(new FileTreeIterator(repo));
walk.setRecursive(true);
@ -362,8 +361,7 @@ public class StashApplyCommand extends GitCommand<ObjectId> {
checkoutPath(entry, reader);
}
} finally {
if (walk != null)
walk.release();
walk.release();
}
}

Loading…
Cancel
Save