本文整理汇总了Java中org.eclipse.jgit.dircache.DirCache.getEntry方法的典型用法代码示例。如果您正苦于以下问题:Java DirCache.getEntry方法的具体用法?Java DirCache.getEntry怎么用?Java DirCache.getEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.dircache.DirCache
的用法示例。
在下文中一共展示了DirCache.getEntry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteIfUnversioned
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private void deleteIfUnversioned(DirCache cache, String path, WorkingTreeIterator f, Repository repository, TreeWalk treeWalk) throws IOException, NoWorkTreeException {
if (cache.getEntry(path) == null && // not in index
!f.isEntryIgnored() && // not ignored
!Utils.isFromNested(f.getEntryFileMode().getBits()))
{
File file = new File(repository.getWorkTree().getAbsolutePath() + File.separator + path);
if(file.isDirectory()) {
String[] s = file.list();
if(s != null && s.length > 0) { // XXX is there no better way to find out if empty?
// not empty
return;
}
}
file.delete();
listener.notifyFile(file, treeWalk.getPathString());
}
}
示例2: assertDirCacheEntryModified
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private void assertDirCacheEntryModified (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());
InputStream in = new FileInputStream(f);
try {
assertNotSame(e.getObjectId(), repository.newObjectInserter().idFor(Constants.OBJ_BLOB, f.length(), in));
} finally {
in.close();
}
}
cache.unlock();
}
示例3: assertDirCacheEntry
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的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();
}
示例4: findEntrys
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private DirCacheEntry[] findEntrys(Repository repository, String path) throws IOException {
DirCache dirCache = repository.readDirCache();
int eIdx = dirCache.findEntry(path);
if (eIdx < 0) {
throw new GitInvalidPathException(format("%s is not found in git index", path));
}
int lastIdx = dirCache.nextEntry(eIdx);
final DirCacheEntry[] entries = new DirCacheEntry[lastIdx - eIdx];
for (int i=0; i<entries.length; i++) {
entries[i] = dirCache.getEntry(eIdx + i);
}
return entries;
}
示例5: main
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
// DirCache contains all files of the repository
DirCache index = DirCache.read(repository);
System.out.println("DirCache has " + index.getEntryCount() + " items");
for (int i = 0; i < index.getEntryCount(); i++) {
// the number after the AnyObjectId is the "stage", see the constants in DirCacheEntry
System.out.println("Item " + i + ": " + index.getEntry(i));
}
//
System.out.println("Now printing staged items...");
for (int i = 0; i < index.getEntryCount(); i++) {
DirCacheEntry entry = index.getEntry(i);
if (entry.getStage() != DirCacheEntry.STAGE_0) {
System.out.println("Item " + i + ": " + entry);
}
}
}
}
示例6: call
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Override
public String call() throws GitAPIException {
try {
DirCache index = repo.lockDirCache();
DirCacheEntry entry = index.getEntry(fileName);
if (entry != null) {
entry.setAssumeValid(assumeUnchanged);
index.write();
index.commit();
return entry.getPathString();
}
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
}
return null;
}
示例7: assertNullDirCacheEntry
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private void assertNullDirCacheEntry (Collection<File> files) throws Exception {
DirCache cache = repository.lockDirCache();
for (File f : files) {
DirCacheEntry e = cache.getEntry(Utils.getRelativePath(workDir, f));
assertNull(e);
}
cache.unlock();
}
示例8: testLargeFile
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public void testLargeFile () throws Exception {
unpack("large.dat.zip");
File large = new File(workDir, "large.dat");
assertTrue(large.exists());
assertEquals(2158310, large.length());
add();
DirCache cache = repository.readDirCache();
DirCacheEntry e = cache.getEntry("large.dat");
WindowCacheConfig cfg = new WindowCacheConfig();
cfg.setStreamFileThreshold((int) large.length() - 1);
cfg.install();
DirCacheCheckout.checkoutEntry(repository, large, e);
}
示例9: testResetConflict
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public void testResetConflict () throws Exception {
File file = new File(workDir, "file");
write(file, "init");
File[] files = new File[] { file };
add(files);
commit(files);
DirCache index = repository.lockDirCache();
DirCacheBuilder builder = index.builder();
DirCacheEntry e = index.getEntry(file.getName());
DirCacheEntry e1 = new DirCacheEntry(file.getName(), 1);
e1.setCreationTime(e.getCreationTime());
e1.setFileMode(e.getFileMode());
e1.setLastModified(e.getLastModified());
e1.setLength(e.getLength());
e1.setObjectId(e.getObjectId());
builder.add(e1);
builder.finish();
builder.commit();
GitClient client = getClient(workDir);
Map<File, GitStatus> status = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertTrue(status.get(file).isConflict());
assertEquals(GitConflictDescriptor.Type.BOTH_DELETED, status.get(file).getConflictDescriptor().getType());
client.reset(files, "HEAD", true, NULL_PROGRESS_MONITOR);
status = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertFalse(status.get(file).isConflict());
}
示例10: locateObjectIdInIndex
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
/**
* Locates the file with the given path in the index.
*
* @param path File path.
*
* @return The ID or null if not found.
*
* @throws IOException Unable to read the index.
*/
public ObjectId locateObjectIdInIndex(String path) throws IOException {
DirCache dc = git.getRepository().readDirCache();
int firstIndex = dc.findEntry(path);
if (firstIndex < 0) {
return null;
}
org.eclipse.jgit.dircache.DirCacheEntry firstEntry = dc.getEntry(firstIndex);
return firstEntry.getObjectId();
}
示例11: updateSubmodule
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private RevCommit updateSubmodule(
DirCache dc, DirCacheEditor ed, StringBuilder msgbuf, SubmoduleSubscription s)
throws SubmoduleException, IOException {
OpenRepo subOr;
try {
subOr = orm.getRepo(s.getSubmodule().getParentKey());
} catch (NoSuchProjectException | IOException e) {
throw new SubmoduleException("Cannot access submodule", e);
}
DirCacheEntry dce = dc.getEntry(s.getPath());
RevCommit oldCommit = null;
if (dce != null) {
if (!dce.getFileMode().equals(FileMode.GITLINK)) {
String errMsg =
"Requested to update gitlink "
+ s.getPath()
+ " in "
+ s.getSubmodule().getParentKey().get()
+ " but entry "
+ "doesn't have gitlink file mode.";
throw new SubmoduleException(errMsg);
}
oldCommit = subOr.rw.parseCommit(dce.getObjectId());
}
final CodeReviewCommit newCommit;
if (branchTips.containsKey(s.getSubmodule())) {
newCommit = branchTips.get(s.getSubmodule());
} else {
Ref ref = subOr.repo.getRefDatabase().exactRef(s.getSubmodule().get());
if (ref == null) {
ed.add(new DeletePath(s.getPath()));
return null;
}
newCommit = subOr.rw.parseCommit(ref.getObjectId());
addBranchTip(s.getSubmodule(), newCommit);
}
if (Objects.equals(newCommit, oldCommit)) {
// gitlink have already been updated for this submodule
return null;
}
ed.add(
new PathEdit(s.getPath()) {
@Override
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.GITLINK);
ent.setObjectId(newCommit.getId());
}
});
if (verboseSuperProject != VerboseSuperprojectUpdate.FALSE) {
createSubmoduleCommitMsg(msgbuf, s, subOr, newCommit, oldCommit);
}
subOr.rw.parseBody(newCommit);
return newCommit;
}