* @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();
}
}
* @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();
}
}