本文整理匯總了Java中org.eclipse.jgit.lib.Repository.lockDirCache方法的典型用法代碼示例。如果您正苦於以下問題:Java Repository.lockDirCache方法的具體用法?Java Repository.lockDirCache怎麽用?Java Repository.lockDirCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.lib.Repository
的用法示例。
在下文中一共展示了Repository.lockDirCache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
@Override
protected void run() throws GitException {
Repository repository = getRepository();
DirCache cache = null;
try {
// cache must be locked because checkout index may modify its entries
cache = repository.lockDirCache();
DirCacheBuilder builder = cache.builder();
if (cache.getEntryCount() > 0) {
builder.keep(0, cache.getEntryCount());
}
builder.finish();
new CheckoutIndex(repository, cache, roots, recursively, listener, monitor, true).checkout();
// cache must be saved to disk because checkout index may modify its entries
builder.commit();
} catch (IOException ex) {
throw new GitException(ex);
} finally {
if (cache != null) {
cache.unlock();
}
}
}
示例2: assertDirCacheEntry
import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
protected static void assertDirCacheEntry (Repository repository, File workDir, Collection<File> files) throws IOException {
DirCache cache = repository.lockDirCache();
for (File f : files) {
String relativePath = Utils.getRelativePath(workDir, f);
DirCacheEntry e = cache.getEntry(relativePath);
assertNotNull(e);
assertEquals(relativePath, e.getPathString());
if (f.lastModified() != e.getLastModified()) {
assertEquals((f.lastModified() / 1000) * 1000, (e.getLastModified() / 1000) * 1000);
}
try (InputStream in = new FileInputStream(f)) {
assertEquals(e.getObjectId(), repository.newObjectInserter().idFor(Constants.OBJ_BLOB, f.length(), in));
}
if (e.getLength() == 0 && f.length() != 0) {
assertTrue(e.isSmudged());
} else {
assertEquals(f.length(), e.getLength());
}
}
cache.unlock();
}