aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/api
diff options
context:
space:
mode:
authorKevin Sawicki <kevin@github.com>2012-05-04 14:37:40 -0700
committerKevin Sawicki <kevin@github.com>2012-05-04 14:37:40 -0700
commit6f432673c105febf1f8cd617fc7c111d9525274f (patch)
tree72062993121c3e1ec37a7f77fb129dc64a69c8cd /org.eclipse.jgit/src/org/eclipse/jgit/api
parente5633ba2d3086f4c2e0385083cb13edb39996fe9 (diff)
downloadjgit-6f432673c105febf1f8cd617fc7c111d9525274f.tar.gz
jgit-6f432673c105febf1f8cd617fc7c111d9525274f.zip
Remove unneeded catch block and null checks
The catched exception was just rethrown and the null check of the locked dir cache was unneeded if the assignment was done outside the try block. Change-Id: If2ee1f3eff3849f8da51eab825057fc56e166a94
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java16
1 files changed, 4 insertions, 12 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 db2dd8da9b..60776f903c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
@@ -312,35 +312,27 @@ public class ResetCommand extends GitCommand<Ref> {
}
private void resetIndex(RevCommit commit) throws IOException {
- DirCache dc = null;
+ DirCache dc = repo.lockDirCache();
try {
- dc = repo.lockDirCache();
dc.clear();
DirCacheBuilder dcb = dc.builder();
dcb.addTree(new byte[0], 0, repo.newObjectReader(),
commit.getTree());
dcb.commit();
- } catch (IOException e) {
- throw e;
} finally {
- if (dc != null)
- dc.unlock();
+ dc.unlock();
}
}
private void checkoutIndex(RevCommit commit) throws IOException {
- DirCache dc = null;
+ DirCache dc = repo.lockDirCache();
try {
- dc = repo.lockDirCache();
DirCacheCheckout checkout = new DirCacheCheckout(repo, dc,
commit.getTree());
checkout.setFailOnConflict(false);
checkout.checkout();
- } catch (IOException e) {
- throw e;
} finally {
- if (dc != null)
- dc.unlock();
+ dc.unlock();
}
}