Browse Source

Clone should close repository after errors in fetch or checkout

Bug: 474093
Change-Id: Ia0a1478260b94a71a947aa8c04ee0c836d390aec
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
tags/v4.1.0.201509280440-r
Andrey Loskutov 8 years ago
parent
commit
1309526564
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

+ 8
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java View File

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

Loading…
Cancel
Save