浏览代码

Merge "Use try-with-resources to fix warnings in AddCommand"

tags/v4.0.0.201505050340-m2
Shawn Pearce 9 年前
父节点
当前提交
e0d95ab577
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2
    4
      org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java

+ 2
- 4
org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java 查看文件

@@ -137,13 +137,12 @@ public class AddCommand extends GitCommand<DirCache> {
if (filepatterns.contains(".")) //$NON-NLS-1$
addAll = true;

ObjectInserter inserter = repo.newObjectInserter();
try {
try (ObjectInserter inserter = repo.newObjectInserter();
final TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheIterator c;

DirCacheBuilder builder = dc.builder();
final TreeWalk tw = new TreeWalk(repo);
tw.addTree(new DirCacheBuildIterator(builder));
if (workingTreeIterator == null)
workingTreeIterator = new FileTreeIterator(repo);
@@ -212,7 +211,6 @@ public class AddCommand extends GitCommand<DirCache> {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfAddCommand, e);
} finally {
inserter.release();
if (dc != null)
dc.unlock();
}

正在加载...
取消
保存