Merge "Clone should close repository after errors in fetch or checkout"

This commit is contained in:
Christian Halstrick 2015-08-04 07:34:20 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 5c2f52f72b
1 changed files with 8 additions and 1 deletions

View File

@ -127,16 +127,23 @@ public CloneCommand() {
*/
public Git call() throws GitAPIException, InvalidRemoteException,
org.eclipse.jgit.api.errors.TransportException {
Repository repository = null;
try {
URIish u = new URIish(uri);
Repository repository = init(u);
repository = init(u);
FetchResult result = fetch(repository, u);
if (!noCheckout)
checkout(repository, result);
return new Git(repository);
} catch (IOException ioe) {
if (repository != null) {
repository.close();
}
throw new JGitInternalException(ioe.getMessage(), ioe);
} catch (URISyntaxException e) {
if (repository != null) {
repository.close();
}
throw new InvalidRemoteException(MessageFormat.format(
JGitText.get().invalidRemote, remote));
}