List of usage examples for org.eclipse.jgit.lib Constants OBJ_TREE
int OBJ_TREE
To view the source code for org.eclipse.jgit.lib Constants OBJ_TREE.
Click Source Link
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
License:Apache License
public static String asObjectType(int objectType) { switch (objectType) { case Constants.OBJ_BAD: return "BAD"; case Constants.OBJ_BLOB: return "BLOB"; case Constants.OBJ_COMMIT: return "COMMIT"; case Constants.OBJ_EXT: return "EXT(future)"; case Constants.OBJ_OFS_DELTA: return "OFS_DELTA(offset_delta)"; case Constants.OBJ_REF_DELTA: return "REF_DELTA(reference_delta)"; case Constants.OBJ_TAG: return "TAG"; case Constants.OBJ_TREE: return "TREE"; case Constants.OBJ_TYPE_5: return "TYPE_S(future)"; default:// w w w .ja v a 2 s. c o m return "[" + objectType + "]"; } }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
License:Apache License
public static String getObjectName(Repository repo, ObjectId objectId) { try {/*from ww w .j a v a 2s. c o m*/ ObjectLoader loader = repo.open(objectId); StringBuilder ret = new StringBuilder(); if (loader.isLarge()) { ret.append("LARGE! "); } switch (loader.getType()) { case Constants.OBJ_BAD: ret.append("BAD "); break; case Constants.OBJ_BLOB: ret.append("BLOB "); break; case Constants.OBJ_COMMIT: ret.append("COMMIT "); break; case Constants.OBJ_EXT: ret.append("EXT "); break; case Constants.OBJ_OFS_DELTA: ret.append("OFS_DELTA "); break; case Constants.OBJ_REF_DELTA: ret.append("REF_DELTA "); break; case Constants.OBJ_TAG: ret.append("TAG "); break; case Constants.OBJ_TREE: ret.append("TREE "); break; case Constants.OBJ_TYPE_5: ret.append("TYPE_5 "); break; default: ret.append("UNKNOWN[").append(loader.getType()).append("] "); break; } ret.append(String.format("Size=%,d", loader.getSize())); return ret.toString(); } catch (MissingObjectException e) { LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e); return "<missing object>"; } catch (IOException e) { LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e); return "<unable to open object>"; } }
From source file:org.craftercms.studio.impl.v1.repository.git.GitContentRepository.java
License:Open Source License
@Override public RepositoryItem[] getContentChildren(String site, String path) { // TODO: SJ: Rethink this API call for 3.1+ final List<RepositoryItem> retItems = new ArrayList<RepositoryItem>(); Repository repo = helper.getRepository(site, StringUtils.isEmpty(site) ? GitRepositories.GLOBAL : GitRepositories.SANDBOX); try {//from ww w .j a va 2s. com RevTree tree = helper.getTreeForLastCommit(repo); try (TreeWalk tw = TreeWalk.forPath(repo, helper.getGitPath(path), tree)) { if (tw != null) { // Loop for all children and gather path of item excluding the item, file/folder name, and // whether or not it's a folder ObjectLoader loader = repo.open(tw.getObjectId(0)); if (loader.getType() == Constants.OBJ_TREE) { int depth = tw.getDepth(); tw.enterSubtree(); while (tw.next()) { if (tw.getDepth() == depth + 1) { RepositoryItem item = new RepositoryItem(); item.name = tw.getNameString(); String visitFolderPath = File.separator + tw.getPathString(); loader = repo.open(tw.getObjectId(0)); item.isFolder = loader.getType() == Constants.OBJ_TREE; int lastIdx = visitFolderPath.lastIndexOf(File.separator + item.name); if (lastIdx > 0) { item.path = visitFolderPath.substring(0, lastIdx); } if (!ArrayUtils.contains(IGNORE_FILES, item.name)) { retItems.add(item); } } } tw.close(); } else { logger.error("Error getChildren invoked for a file for site: " + site + " path: " + path); } } } catch (IOException e) { logger.error("Error while getting children for site: " + site + " path: " + path, e); } } catch (IOException e) { logger.error("Failed to create RevTree for site: " + site + " path: " + path, e); } RepositoryItem[] items = new RepositoryItem[retItems.size()]; items = retItems.toArray(items); return items; }
From source file:org.eclipse.egit.core.op.CommitOperation.java
License:Open Source License
private void writeTreeWithSubTrees(Tree tree) throws TeamException { if (tree.getId() == null) { // TODO is this the right Location? if (GitTraceLocation.CORE.isActive()) GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), "writing tree for: " + tree.getFullName()); //$NON-NLS-1$ try {// ww w . j a v a2 s.c o m for (TreeEntry entry : tree.members()) { if (entry.isModified()) { if (entry instanceof Tree) { writeTreeWithSubTrees((Tree) entry); } else { // this shouldn't happen.... not quite sure what to // do here :) // TODO is this the right Location? if (GitTraceLocation.CORE.isActive()) GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), "BAD JUJU: " //$NON-NLS-1$ + entry.getFullName()); } } } ObjectInserter inserter = tree.getRepository().newObjectInserter(); try { tree.setId(inserter.insert(Constants.OBJ_TREE, tree.format())); inserter.flush(); } finally { inserter.release(); } } catch (IOException e) { throw new TeamException(CoreText.CommitOperation_errorWritingTrees, e); } } }
From source file:org.eclipse.egit.ui.internal.components.RefContentProposal.java
License:Open Source License
public String getDescription() { if (objectId == null) return null; ObjectReader reader = db.newObjectReader(); try {/* w w w . ja va 2 s . c o m*/ final ObjectLoader loader = reader.open(objectId); final StringBuilder sb = new StringBuilder(); sb.append(refName); sb.append('\n'); sb.append(reader.abbreviate(objectId).name()); sb.append(" - "); //$NON-NLS-1$ switch (loader.getType()) { case Constants.OBJ_COMMIT: RevCommit c = new RevWalk(db).parseCommit(objectId); appendObjectSummary(sb, UIText.RefContentProposal_commit, c.getAuthorIdent(), c.getFullMessage()); break; case Constants.OBJ_TAG: RevWalk walk = new RevWalk(db); RevTag t = walk.parseTag(objectId); appendObjectSummary(sb, UIText.RefContentProposal_tag, t.getTaggerIdent(), t.getFullMessage()); break; case Constants.OBJ_TREE: sb.append(UIText.RefContentProposal_tree); break; case Constants.OBJ_BLOB: sb.append(UIText.RefContentProposal_blob); break; default: sb.append(UIText.RefContentProposal_unknownObject); } return sb.toString(); } catch (IOException e) { Activator.logError(NLS.bind(UIText.RefContentProposal_errorReadingObject, objectId), e); return null; } finally { reader.release(); } }
From source file:org.eclipse.egit.ui.internal.synchronize.mapping.GitTreeTraversal.java
License:Open Source License
private static IResource[] getResourcesImpl(Repository repo, AnyObjectId baseId, AnyObjectId remoteId, IPath path) {/*from w ww. j a va 2 s. com*/ if (remoteId.equals(zeroId())) return new IResource[0]; TreeWalk tw = new TreeWalk(repo); List<IResource> result = new ArrayList<IResource>(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); tw.reset(); tw.setRecursive(false); tw.setFilter(TreeFilter.ANY_DIFF); try { tw.addTree(new FileTreeIterator(repo)); if (!baseId.equals(zeroId())) tw.addTree(baseId); int actualNth = tw.addTree(remoteId); while (tw.next()) { int objectType = tw.getFileMode(actualNth).getObjectType(); IPath childPath = path.append(tw.getNameString()); IResource resource = null; if (objectType == Constants.OBJ_BLOB) resource = root.getFileForLocation(childPath); else if (objectType == Constants.OBJ_TREE) resource = root.getContainerForLocation(childPath); if (resource != null) result.add(resource); } } catch (IOException e) { Activator.logError(e.getMessage(), e); } return result.toArray(new IResource[result.size()]); }
From source file:org.eclipse.egit.ui.internal.synchronize.model.GitModelObjectContainer.java
License:Open Source License
/** * * @param tw instance of {@link TreeWalk} that should be used * @param ancestorNth// w ww. j a v a2 s .com * @param baseNth * @param actualNth * @return {@link GitModelObject} instance of given parameters * @throws IOException */ protected GitModelObject getModelObject(TreeWalk tw, int ancestorNth, int baseNth, int actualNth) throws IOException { String objName = tw.getNameString(); ObjectId objBaseId; if (baseNth > -1) objBaseId = tw.getObjectId(baseNth); else objBaseId = ObjectId.zeroId(); ObjectId objRemoteId = tw.getObjectId(actualNth); ObjectId objAncestorId = tw.getObjectId(ancestorNth); int objectType = tw.getFileMode(actualNth).getObjectType(); if (objectType == Constants.OBJ_BLOB) return new GitModelBlob(this, getBaseCommit(), objAncestorId, objBaseId, objRemoteId, objName); else if (objectType == Constants.OBJ_TREE) return new GitModelTree(this, getBaseCommit(), objAncestorId, objBaseId, objRemoteId, objName); return null; }
From source file:org.webcat.core.git.GitRepository.java
License:Open Source License
/** * Copies an item from the repository into a container. If the item is a * blob, it will be copied into the destination with the specified name; if * the item is a tree or commit, its children will be recursively copied. * * @param objectId the id of the object to copy * @param name the destination name to use (only when the item is a blob) * @param container the container where the items should be copied * @throws IOException if an I/O error occurred *///from w w w . j av a 2 s .c o m public void copyItemToContainer(ObjectId objectId, String name, IWritableContainer container) throws IOException { int type = typeOfObject(objectId); if (type == Constants.OBJ_BLOB) { OutputStream fileStream = container.createFile(name, -1); writeBlobToStream(objectId, fileStream); fileStream.close(); } else if (type == Constants.OBJ_TREE || type == Constants.OBJ_COMMIT) { GitTreeIterator iterator = new GitTreeIterator(this, objectId); try { for (GitTreeEntry entry : iterator) { if (entry.isTree()) { IWritableContainer childContainer = container.createContainer(entry.name()); copyItemToContainer(entry.objectId(), entry.name(), childContainer); childContainer.finish(); } else { copyItemToContainer(entry.objectId(), entry.name(), container); } } } finally { iterator.release(); } } }
From source file:org.webcat.core.git.GitTreeIterator.java
License:Open Source License
/** * Creates a new {@code GitTreeIterator} for the specified tree or commit * object.//from ww w . j ava 2s. c o m * * @param repository the repository * @param treeOrCommitId the id of the tree or commit object * @param recursive true if the iterator should be recursive, otherwise * false */ public GitTreeIterator(GitRepository repository, ObjectId treeOrCommitId, boolean recursive) { this.repository = repository; this.recursive = recursive; int type = repository.typeOfObject(treeOrCommitId); if (type == Constants.OBJ_TREE) { initializeFromTree(treeOrCommitId); } else if (type == Constants.OBJ_COMMIT || type == Constants.OBJ_TAG) { initializeFromCommit(treeOrCommitId); } else { treeWalk = null; } }
From source file:svnserver.repository.git.GitFile.java
License:GNU General Public License
@NotNull @Override// ww w . ja va 2 s. co m default SVNNodeKind getKind() { final int objType = getFileMode().getObjectType(); switch (objType) { case Constants.OBJ_TREE: case Constants.OBJ_COMMIT: return SVNNodeKind.DIR; case Constants.OBJ_BLOB: return SVNNodeKind.FILE; default: throw new IllegalStateException("Unknown obj type: " + objType); } }