]> source.dussan.org Git - jgit.git/commitdiff
SubmoduleStatusCommand: Open Repository in try-with-resource 87/119387/4
authorDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 04:39:23 +0000 (13:39 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 15 Mar 2018 01:28:14 +0000 (10:28 +0900)
Change-Id: Id65c8a94d43bc01e76733eb2ff87635d0f8a8dc2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java

index 97ae668078fd4035f0db248ef019e41bd28e1870..5c21864202dec63e879d95feec568148cfca32d8 100644 (file)
@@ -130,16 +130,14 @@ public class SubmoduleStatusCommand extends
                                        id);
 
                // Report uninitialized if no submodule repository
-               Repository subRepo = generator.getRepository();
-               if (subRepo == null)
-                       return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED, path,
-                                       id);
+               ObjectId headId = null;
+               try (Repository subRepo = generator.getRepository()) {
+                       if (subRepo == null) {
+                               return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED,
+                                               path, id);
+                       }
 
-               ObjectId headId;
-               try {
                        headId = subRepo.resolve(Constants.HEAD);
-               } finally {
-                       subRepo.close();
                }
 
                // Report uninitialized if no HEAD commit in submodule repository