]> source.dussan.org Git - jgit.git/commitdiff
Remove unneeded catch block and null checks 32/5832/1
authorKevin Sawicki <kevin@github.com>
Fri, 4 May 2012 21:37:40 +0000 (14:37 -0700)
committerKevin Sawicki <kevin@github.com>
Fri, 4 May 2012 21:37:40 +0000 (14:37 -0700)
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

org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java

index db2dd8da9b9807cb141096437ab7a38bcf4e8543..60776f903cef8037ce17f12a12da1f602c0005d5 100644 (file)
@@ -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();
                }
        }