diff options
-rw-r--r-- | org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java index c76ae2af8c..b9a868826e 100644 --- a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java +++ b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java @@ -117,10 +117,10 @@ public class GitAddTask extends Task { } AddCommand gitAdd; - try { - Repository repo = new FileRepositoryBuilder().readEnvironment() - .findGitDir(src).build(); - gitAdd = new Git(repo).add(); + try (Repository repo = new FileRepositoryBuilder().readEnvironment() + .findGitDir(src).build(); + Git git = new Git(repo);) { + gitAdd = git.add(); } catch (IOException e) { throw new BuildException("Could not access repository " + src, e); } diff --git a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java index 14c4bc5700..9962472c9e 100644 --- a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java +++ b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java @@ -105,10 +105,10 @@ public class GitCheckoutTask extends Task { @Override public void execute() throws BuildException { CheckoutCommand checkout; - try { - Repository repo = new FileRepositoryBuilder().readEnvironment() - .findGitDir(src).build(); - checkout = new Git(repo).checkout(); + try (Repository repo = new FileRepositoryBuilder().readEnvironment() + .findGitDir(src).build(); + Git git = new Git(repo)) { + checkout = git.checkout(); } catch (IOException e) { throw new BuildException("Could not access repository " + src, e); } |