当前位置: 首页>>代码示例>>Java>>正文


Java DirCacheEntry.setFileMode方法代码示例

本文整理汇总了Java中org.eclipse.jgit.dircache.DirCacheEntry.setFileMode方法的典型用法代码示例。如果您正苦于以下问题:Java DirCacheEntry.setFileMode方法的具体用法?Java DirCacheEntry.setFileMode怎么用?Java DirCacheEntry.setFileMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.dircache.DirCacheEntry的用法示例。


在下文中一共展示了DirCacheEntry.setFileMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildDirCache

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
private void buildDirCache(TreeWalk walk, DirCacheBuilder builder)
		throws MissingObjectException, IncorrectObjectTypeException,
		CorruptObjectException, IOException {
	while (walk.next()) {
		AbstractTreeIterator cIter = walk.getTree(0,
				AbstractTreeIterator.class);
		if (cIter == null) {
			// Not in commit, don't add to new index
			continue;
		}

		final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
		entry.setFileMode(cIter.getEntryFileMode());
		entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());

		DirCacheIterator dcIter = walk.getTree(1, DirCacheIterator.class);
		if (dcIter != null && dcIter.idEqual(cIter)) {
			DirCacheEntry indexEntry = dcIter.getDirCacheEntry();
			entry.setLastModified(indexEntry.getLastModified());
			entry.setLength(indexEntry.getLength());
		}

		builder.add(entry);
	}
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:26,代码来源:IndexUpdate.java

示例2: createTreeDirCache

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
private DirCache createTreeDirCache(Map<SubtreeConfig, RevCommit> parentCommits,
		String commitMessage) throws IOException {

	try (TreeWalk treeWalk = new TreeWalk(repository)) {
		treeWalk.setRecursive(true);
		addTrees(parentCommits, treeWalk);

		DirCacheBuilder builder = DirCache.newInCore().builder();
		while (treeWalk.next()) {
			AbstractTreeIterator iterator = getSingleTreeIterator(treeWalk, commitMessage);
			if (iterator == null) {
				throw new IllegalStateException(
						"Tree walker did not return a single tree (should not happen): "
								+ treeWalk.getPathString());
			}
			byte[] path = Arrays.copyOf(iterator.getEntryPathBuffer(),
					iterator.getEntryPathLength());
			DirCacheEntry entry = new DirCacheEntry(path);
			entry.setFileMode(iterator.getEntryFileMode());
			entry.setObjectId(iterator.getEntryObjectId());
			builder.add(entry);
		}
		builder.finish();
		return builder.getDirCache();
	}
}
 
开发者ID:robinst,项目名称:git-merge-repos,代码行数:27,代码来源:SubtreeMerger.java

示例3: testResetConflict

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ResetTest.java

示例4: someEntry

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
@Nonnull
private DirCacheEntry someEntry(String path, int stage) {
  DirCacheEntry ret = new DirCacheEntry(normalizeNodePath(path), stage);
  ret.setFileMode(REGULAR_FILE);
  ret.setObjectId(someObjectId());
  return ret;
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:8,代码来源:GfsDefaultCheckoutCacheTest.java

示例5: apply

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
@Override
public void apply(DirCacheEntry ent) {
  if(newBlob != null)
    ent.setObjectId(newBlob);
  if(newFileMode != null)
    ent.setFileMode(newFileMode);
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:8,代码来源:CacheEntryUpdate.java

示例6: file

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
private DirCacheEntry file(String name) throws IOException {
  try (ObjectInserter oi = repository.newObjectInserter()) {
    final DirCacheEntry e = new DirCacheEntry(name);
    e.setFileMode(FileMode.REGULAR_FILE);
    e.setObjectId(oi.insert(Constants.OBJ_BLOB, Constants.encode(name)));
    oi.flush();
    return e;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:CommitMsgHookTest.java

示例7: getTreeEntries

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
/**
 * Returns all tree entries that do not match the ignore paths.
 * 
 * @param db
 * @param ignorePaths
 * @param dcBuilder
 * @throws IOException
 */
private List<DirCacheEntry> getTreeEntries(Repository db, Collection<String> ignorePaths) throws IOException {
	List<DirCacheEntry> list = new ArrayList<DirCacheEntry>();
	ObjectId treeId = db.resolve(BRANCH + "^{tree}");
	if (treeId == null) {
		// branch does not exist yet, could be migrating tickets
		return list;
	}
	try (TreeWalk tw = new TreeWalk(db)) {
		int hIdx = tw.addTree(treeId);
		tw.setRecursive(true);

		while (tw.next()) {
			String path = tw.getPathString();
			CanonicalTreeParser hTree = null;
			if (hIdx != -1) {
				hTree = tw.getTree(hIdx, CanonicalTreeParser.class);
			}
			if (!ignorePaths.contains(path)) {
				// add all other tree entries
				if (hTree != null) {
					final DirCacheEntry entry = new DirCacheEntry(path);
					entry.setObjectId(hTree.getEntryObjectId());
					entry.setFileMode(hTree.getEntryFileMode());
					list.add(entry);
				}
			}
		}
	}
	return list;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:39,代码来源:BranchTicketService.java

示例8: apply

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
@Override
public void apply(DirCacheEntry dirCacheEntry) {
  dirCacheEntry.setFileMode(fileMode);
  dirCacheEntry.setObjectId(objectId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:AddPath.java

示例9: deleteTicketImpl

import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
/**
 * Deletes a ticket from the repository.
 * 
 * @param ticket
 * @return true if successful
 */
@Override
protected synchronized boolean deleteTicketImpl(RepositoryModel repository, TicketModel ticket, String deletedBy) {
	if (ticket == null) {
		throw new RuntimeException("must specify a ticket!");
	}

	boolean success = false;
	Repository db = repositoryManager.getRepository(ticket.repository);
	try {
		RefModel ticketsBranch = getTicketsBranch(db);

		if (ticketsBranch == null) {
			throw new RuntimeException(BRANCH + " does not exist!");
		}
		String ticketPath = toTicketPath(ticket.number);

		try {
			ObjectId treeId = db.resolve(BRANCH + "^{tree}");

			// Create the in-memory index of the new/updated ticket
			DirCache index = DirCache.newInCore();
			DirCacheBuilder builder = index.builder();

			// Traverse HEAD to add all other paths
			try (TreeWalk treeWalk = new TreeWalk(db)) {
				int hIdx = -1;
				if (treeId != null) {
					hIdx = treeWalk.addTree(treeId);
				}
				treeWalk.setRecursive(true);
				while (treeWalk.next()) {
					String path = treeWalk.getPathString();
					CanonicalTreeParser hTree = null;
					if (hIdx != -1) {
						hTree = treeWalk.getTree(hIdx, CanonicalTreeParser.class);
					}
					if (!path.startsWith(ticketPath)) {
						// add entries from HEAD for all other paths
						if (hTree != null) {
							final DirCacheEntry entry = new DirCacheEntry(path);
							entry.setObjectId(hTree.getEntryObjectId());
							entry.setFileMode(hTree.getEntryFileMode());

							// add to temporary in-core index
							builder.add(entry);
						}
					}
				}
			}

			// finish temporary in-core index used for this commit
			builder.finish();

			success = commitIndex(db, index, deletedBy, "- " + ticket.number);

		} catch (Throwable t) {
			log.error(MessageFormat.format("Failed to delete ticket {0,number,0} from {1}", ticket.number, db.getDirectory()), t);
		}
	} finally {
		db.close();
	}
	return success;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:70,代码来源:BranchTicketService.java


注:本文中的org.eclipse.jgit.dircache.DirCacheEntry.setFileMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。