Browse Source

SubmoduleWalk: Open Repository in try-with-resource

Change-Id: Ib29aaf26b49aa94a5a7cc0b0264a0a93ecff0c16
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
tags/v5.0.0.201805151920-m7
David Pursehouse 6 years ago
parent
commit
4775a394c0
1 changed files with 8 additions and 12 deletions
  1. 8
    12
      org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java

+ 8
- 12
org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java View File

@@ -754,13 +754,11 @@ public class SubmoduleWalk implements AutoCloseable {
* @throws java.io.IOException
*/
public ObjectId getHead() throws IOException {
Repository subRepo = getRepository();
if (subRepo == null)
return null;
try {
try (Repository subRepo = getRepository()) {
if (subRepo == null) {
return null;
}
return subRepo.resolve(Constants.HEAD);
} finally {
subRepo.close();
}
}

@@ -771,14 +769,12 @@ public class SubmoduleWalk implements AutoCloseable {
* @throws java.io.IOException
*/
public String getHeadRef() throws IOException {
Repository subRepo = getRepository();
if (subRepo == null)
return null;
try {
try (Repository subRepo = getRepository()) {
if (subRepo == null) {
return null;
}
Ref head = subRepo.exactRef(Constants.HEAD);
return head != null ? head.getLeaf().getName() : null;
} finally {
subRepo.close();
}
}


Loading…
Cancel
Save