diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2015-08-04 07:34:20 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2015-08-04 07:34:22 -0400 |
commit | 5c2f52f72b1ab84328bc161fb9884224a6296bba (patch) | |
tree | 6a1304c69255ffcfea14d0b2f772ad25ab4a168e /org.eclipse.jgit | |
parent | a28ae3995fc4655be1400cf694e4b0d97db5df45 (diff) | |
parent | 130952656432ec9c5d7f56fc84049ff95bfaed56 (diff) | |
download | jgit-5c2f52f72b1ab84328bc161fb9884224a6296bba.tar.gz jgit-5c2f52f72b1ab84328bc161fb9884224a6296bba.zip |
Merge "Clone should close repository after errors in fetch or checkout"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java index 9de2803c0b..4aaee8d96d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java @@ -127,16 +127,23 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> { */ 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)); } |