diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-02-10 00:50:41 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-02-10 00:51:01 +0100 |
commit | 28e2fed761f0ddf01029c999b299ed0bccdf630e (patch) | |
tree | f7878683e3aef308a939015091c978bff2488431 /org.eclipse.jgit.junit | |
parent | c901cd89d35fe2cc014c7e0f5849e32a14fe679a (diff) | |
parent | 26012958a35d85639fe44fdbd4690cb58ec3b836 (diff) | |
download | jgit-28e2fed761f0ddf01029c999b299ed0bccdf630e.tar.gz jgit-28e2fed761f0ddf01029c999b299ed0bccdf630e.zip |
Merge branch 'stable-4.2'
* stable-4.2:
RepoProject: Fix warnings about variable hiding
RepoTest: Open Git in try-with-resources
RepositoryResolveTest: Open Git in try-with-resource
RepositoryTestCase: Open autocloseable types in try-with-resource
ResetCommandTest: Use Git member in testHardResetAfterSquashMerge
ResolveMergerTest: Open Git in try-with-resource
RevCommitListTest: Open Git and RevWalk in try-with-resource
RevCommitParseTest: Open ObjectInserter.Formatter in try-with-resource
RevObjectTest: Open RevWalk in try-with-resource
RevTagParseTest: Open ObjectInserter.Formatter in try-with-resource
RevertCommandTest: Open Git in try-with-resource
SquashMessageFormatterTest: Open git in try-with-resource
StatusCommandTest: Open Git in try-with-resource
SubmoduleAddTest: Open Git in try-with-resource
SymlinksTest: Open git and TreeWalk in try-with-resource
T0003_BasicTest: Open autocloseable types in try-with-resource
TextHashFunctions: Fix warnings about variable hiding
TreeFilterTest: Open TreeWalk in try-with-resource
TreeWalkJava7Test: Open TreeWalk in try-with-resource
Fix diff for added and removed submodule
Change-Id: If3ecc63f6dfac55474d3c1dd2f4105371f3d24fb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java index c649eb9086..0db71f7cbc 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java @@ -401,8 +401,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { * @return the created commit */ protected RevCommit commitFile(String filename, String contents, String branch) { - try { - Git git = new Git(db); + try (Git git = new Git(db)) { Repository repo = git.getRepository(); String originalBranch = repo.getFullBranch(); boolean empty = repo.resolve(Constants.HEAD) == null; @@ -443,8 +442,10 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { final int stage, final String content) { final DirCacheEntry entry = new DirCacheEntry(path, stage); entry.setFileMode(mode); - entry.setObjectId(new ObjectInserter.Formatter().idFor( - Constants.OBJ_BLOB, Constants.encode(content))); + try (ObjectInserter.Formatter formatter = new ObjectInserter.Formatter()) { + entry.setObjectId(formatter.idFor( + Constants.OBJ_BLOB, Constants.encode(content))); + } return entry; } |