summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ant
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2015-10-02 01:34:45 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2015-10-02 01:34:59 +0200
commitd652a6bfd763e1e2a0112bde56b307dfe7f6e59e (patch)
treedc7df6c4d5e35a333fc982467be0d5332bfa70fd /org.eclipse.jgit.ant
parent100179a101f1fd9ce281397574d7ad729f08953a (diff)
parentee66914e410a258d8d8acd877a97f9152e2c1a41 (diff)
downloadjgit-d652a6bfd763e1e2a0112bde56b307dfe7f6e59e.tar.gz
jgit-d652a6bfd763e1e2a0112bde56b307dfe7f6e59e.zip
Merge branch 'stable-4.1'
* stable-4.1: pgm: Open RevWalk and TreeWalk in try-with-resource ant: Open Repository and Git in try-with-resource pgm: Create instances of Git in try-with-resource FanoutBucket: Create ObjectInserter.Formatter in try-with-resource Fix compiler warnings in DiffFormatter.writeGitLinkText Change-Id: I448ecc9a1334977d9f304dd61ea20c7a8e692b10 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.ant')
-rw-r--r--org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java8
-rw-r--r--org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java8
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);
}