本文整理了Java中org.eclipse.jgit.lib.Repository.readDirCache
方法的一些代码示例,展示了Repository.readDirCache
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.readDirCache
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:readDirCache
[英]Create a new in-core index representation and read an index from disk.
The new index will be read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
[中]创建一个新的核心索引表示,并从磁盘读取索引。
新索引将在返回给调用方之前被读取。读取失败被报告为异常,因此阻止该方法返回部分填充的索引。
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Reverts the worktree after an unsuccessful merge. We know that for all
* modified files the old content was in the old index and the index
* contained only stage 0. In case if inCore operation just clear the
* history of modified files.
*
* @throws java.io.IOException
* @throws org.eclipse.jgit.errors.CorruptObjectException
* @throws org.eclipse.jgit.errors.NoWorkTreeException
* @since 3.4
*/
protected void cleanUp() throws NoWorkTreeException,
CorruptObjectException,
IOException {
if (inCore) {
modifiedFiles.clear();
return;
}
DirCache dc = nonNullRepo().readDirCache();
Iterator<String> mpathsIt=modifiedFiles.iterator();
while(mpathsIt.hasNext()) {
String mpath = mpathsIt.next();
DirCacheEntry entry = dc.getEntry(mpath);
if (entry != null) {
DirCacheCheckout.checkoutEntry(db, entry, reader, false,
checkoutMetadata.get(mpath));
}
mpathsIt.remove();
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
if (!readDirCache().hasUnmergedPaths()) {
if (!readDirCache().hasUnmergedPaths()) {
if (!readDirCache().hasUnmergedPaths()) {
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Create a generator to walk over the submodule entries currently in the
* index
*
* The {@code .gitmodules} file is read from the index.
*
* @param repository
* a {@link org.eclipse.jgit.lib.Repository} object.
* @return generator over submodule index entries. The caller is responsible
* for calling {@link #close()}.
* @throws java.io.IOException
*/
public static SubmoduleWalk forIndex(Repository repository)
throws IOException {
@SuppressWarnings("resource") // The caller closes it
SubmoduleWalk generator = new SubmoduleWalk(repository);
try {
DirCache index = repository.readDirCache();
generator.setTree(new DirCacheIterator(index));
} catch (IOException e) {
generator.close();
throw e;
}
return generator;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
int estIndexSize, final String title)
throws IOException {
dirCache = repository.readDirCache();
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
gen.push(null, repo.resolve(Constants.HEAD));
if (!repo.isBare()) {
DirCache dc = repo.readDirCache();
int entry = dc.findEntry(path);
if (0 <= entry)
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
newTree = new DirCacheIterator(repo.readDirCache());
} else {
if (oldTree == null)
oldTree = new DirCacheIterator(repo.readDirCache());
if (newTree == null)
newTree = new FileTreeIterator(repo);
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
@Override
protected void run() throws Exception {
final int cnt = 100;
final long start = System.currentTimeMillis();
for (int i = 0; i < cnt; i++)
db.readDirCache();
final long end = System.currentTimeMillis();
outw.print(" "); //$NON-NLS-1$
outw.println(MessageFormat.format(CLIText.get().averageMSPerRead,
valueOf((end - start) / cnt)));
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
DirCache dc = repo.readDirCache();
boolean hasUnmergedPaths = dc.hasUnmergedPaths();
if (hasUnmergedPaths)
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
@Override
protected void run() throws Exception {
final DirCache cache = db.readDirCache();
final DirCacheTree tree = cache.getCacheTree(true);
show(tree);
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
/**
* Reverts the worktree after an unsuccessful merge. We know that for all
* modified files the old content was in the old index and the index
* contained only stage 0. In case if inCore operation just clear the
* history of modified files.
*
* @throws IOException
* @throws CorruptObjectException
* @throws NoWorkTreeException
* @since 3.4
*/
protected void cleanUp() throws NoWorkTreeException,
CorruptObjectException,
IOException {
if (inCore) {
modifiedFiles.clear();
return;
}
DirCache dc = db.readDirCache();
Iterator<String> mpathsIt=modifiedFiles.iterator();
while(mpathsIt.hasNext()) {
String mpath=mpathsIt.next();
DirCacheEntry entry = dc.getEntry(mpath);
if (entry != null)
DirCacheCheckout.checkoutEntry(db, entry, reader);
mpathsIt.remove();
}
}
代码示例来源:origin: berlam/github-bucket
/**
* Reverts the worktree after an unsuccessful merge. We know that for all
* modified files the old content was in the old index and the index
* contained only stage 0. In case if inCore operation just clear the
* history of modified files.
*
* @throws java.io.IOException
* @throws org.eclipse.jgit.errors.CorruptObjectException
* @throws org.eclipse.jgit.errors.NoWorkTreeException
* @since 3.4
*/
protected void cleanUp() throws NoWorkTreeException,
CorruptObjectException,
IOException {
if (inCore) {
modifiedFiles.clear();
return;
}
DirCache dc = nonNullRepo().readDirCache();
Iterator<String> mpathsIt=modifiedFiles.iterator();
while(mpathsIt.hasNext()) {
String mpath = mpathsIt.next();
DirCacheEntry entry = dc.getEntry(mpath);
if (entry != null) {
DirCacheCheckout.checkoutEntry(db, entry, reader, false,
checkoutMetadata.get(mpath));
}
mpathsIt.remove();
}
}
代码示例来源:origin: sheimi/SGit
private AbstractTreeIterator getTreeIterator(Repository repo, String commit) throws IOException {
if (commit.equals("dircache")) {
return new DirCacheIterator(repo.readDirCache());
}
if (commit.equals("filetree")) {
return new FileTreeIterator(repo);
}
ObjectId treeId = repo.resolve(commit + "^{tree}");
if (treeId == null) {
throw new NullPointerException();
}
CanonicalTreeParser treeIter = new CanonicalTreeParser();
ObjectReader reader = repo.newObjectReader();
treeIter.reset(reader, treeId);
return treeIter;
}
代码示例来源:origin: maks/MGit
private AbstractTreeIterator getTreeIterator(Repository repo, String commit) throws IOException {
if (commit.equals("dircache")) {
return new DirCacheIterator(repo.readDirCache());
}
if (commit.equals("filetree")) {
return new FileTreeIterator(repo);
}
ObjectId treeId = repo.resolve(commit + "^{tree}");
if (treeId == null) {
throw new NullPointerException();
}
CanonicalTreeParser treeIter = new CanonicalTreeParser();
ObjectReader reader = repo.newObjectReader();
treeIter.reset(reader, treeId);
return treeIter;
}
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
@Override
protected void run() throws Exception {
final DirCache cache = db.readDirCache();
final DirCacheTree tree = cache.getCacheTree(false);
if (tree == null)
throw die(CLIText.get().noTREESectionInIndex);
show(tree);
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
/**
* Create a generator to walk over the submodule entries currently in the
* index
*
* The {@code .gitmodules} file is read from the index.
*
* @param repository
* @return generator over submodule index entries
* @throws IOException
*/
public static SubmoduleWalk forIndex(Repository repository)
throws IOException {
SubmoduleWalk generator = new SubmoduleWalk(repository);
try {
DirCache index = repository.readDirCache();
generator.setTree(new DirCacheIterator(index));
} catch (IOException e) {
generator.close();
throw e;
}
return generator;
}
代码示例来源:origin: berlam/github-bucket
/**
* Create a generator to walk over the submodule entries currently in the
* index
*
* The {@code .gitmodules} file is read from the index.
*
* @param repository
* a {@link org.eclipse.jgit.lib.Repository} object.
* @return generator over submodule index entries. The caller is responsible
* for calling {@link #close()}.
* @throws java.io.IOException
*/
public static SubmoduleWalk forIndex(Repository repository)
throws IOException {
@SuppressWarnings("resource") // The caller closes it
SubmoduleWalk generator = new SubmoduleWalk(repository);
try {
DirCache index = repository.readDirCache();
generator.setTree(new DirCacheIterator(index));
} catch (IOException e) {
generator.close();
throw e;
}
return generator;
}
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
@Override
protected void run() throws Exception {
final DirCache cache = db.readDirCache();
if (!cache.lock())
throw die(CLIText.get().failedToLockIndex);
cache.read();
cache.write();
if (!cache.commit())
throw die(CLIText.get().failedToCommitIndex);
}
}
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
fmt = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.SSS"); //$NON-NLS-1$
final DirCache cache = db.readDirCache();
for (int i = 0; i < cache.getEntryCount(); i++) {
final DirCacheEntry ent = cache.getEntry(i);
代码示例来源:origin: org.eclipse.egit/ui
private boolean isTracked(File file, Repository repo) throws IOException {
ObjectId objectId = repo.resolve(Constants.HEAD);
RevTree tree;
if (objectId != null)
tree = new RevWalk(repo).parseTree(objectId);
else
tree = null;
TreeWalk treeWalk = new TreeWalk(repo);
treeWalk.setRecursive(true);
if (tree != null)
treeWalk.addTree(tree);
else
treeWalk.addTree(new EmptyTreeIterator());
treeWalk.addTree(new DirCacheIterator(repo.readDirCache()));
treeWalk.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(
Repository.stripWorkDir(repo.getWorkTree(), file))));
return treeWalk.next();
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
public boolean isTracked(String path) throws IOException {
ObjectId objectId = localRepo.resolve(Constants.HEAD);
RevTree tree;
RevWalk walk = null;
if (objectId != null) {
walk = new RevWalk(localRepo);
tree = walk.parseTree(objectId);
}
else {
tree = null;
}
try (TreeWalk treeWalk = new TreeWalk(localRepo)) {
treeWalk.setRecursive(true);
if (tree != null)
treeWalk.addTree(tree);
else
treeWalk.addTree(new EmptyTreeIterator());
treeWalk.addTree(new DirCacheIterator(localRepo.readDirCache()));
treeWalk.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
return treeWalk.next();
}
finally {
if (walk != null)
walk.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!