@Override public int getType() { return ptr.getEntryFileMode().getObjectType(); }
r.append(mode); r.append(' '); r.append(Constants.typeString(mode.getObjectType())); r.append(' '); r.append(p.getEntryObjectId().name());
private static void printDirectory(Repository repository, RevTree tree) throws IOException { // look at directory, this has FileMode.TREE try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); treeWalk.setRecursive(false); treeWalk.setFilter(PathFilter.create("src")); if (!treeWalk.next()) { throw new IllegalStateException("Did not find expected folder 'src'"); } // FileMode now indicates that this is a directory, i.e. FileMode.TREE.equals(fileMode) holds true FileMode fileMode = treeWalk.getFileMode(0); System.out.println("src: " + getFileMode(fileMode) + ", type: " + fileMode.getObjectType() + ", mode: " + fileMode); } }
private static void printDirectory(Repository repository, RevTree tree) throws IOException { // look at directory, this has FileMode.TREE try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); treeWalk.setRecursive(false); treeWalk.setFilter(PathFilter.create("src")); if (!treeWalk.next()) { throw new IllegalStateException("Did not find expected folder 'src'"); } // FileMode now indicates that this is a directory, i.e. FileMode.TREE.equals(fileMode) holds true FileMode fileMode = treeWalk.getFileMode(0); System.out.println("src: " + getFileMode(fileMode) + ", type: " + fileMode.getObjectType() + ", mode: " + fileMode); } }
private static void printFile(Repository repository, RevTree tree) throws IOException { // now try to find a specific file try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); treeWalk.setRecursive(false); treeWalk.setFilter(PathFilter.create("README.md")); if (!treeWalk.next()) { throw new IllegalStateException("Did not find expected file 'README.md'"); } // FileMode specifies the type of file, FileMode.REGULAR_FILE for normal file, FileMode.EXECUTABLE_FILE for executable bit // set FileMode fileMode = treeWalk.getFileMode(0); ObjectLoader loader = repository.open(treeWalk.getObjectId(0)); System.out.println("README.md: " + getFileMode(fileMode) + ", type: " + fileMode.getObjectType() + ", mode: " + fileMode + " size: " + loader.getSize()); } }
private static void printFile(Repository repository, RevTree tree) throws IOException { // now try to find a specific file try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); treeWalk.setRecursive(false); treeWalk.setFilter(PathFilter.create("README.md")); if (!treeWalk.next()) { throw new IllegalStateException("Did not find expected file 'README.md'"); } // FileMode specifies the type of file, FileMode.REGULAR_FILE for normal file, FileMode.EXECUTABLE_FILE for executable bit // set FileMode fileMode = treeWalk.getFileMode(0); ObjectLoader loader = repository.open(treeWalk.getObjectId(0)); System.out.println("README.md: " + getFileMode(fileMode) + ", type: " + fileMode.getObjectType() + ", mode: " + fileMode + " size: " + loader.getSize()); } }
private RawText open(DiffEntry.Side side, DiffEntry entry) throws IOException, BinaryBlobException { if (entry.getMode(side) == FileMode.MISSING) return RawText.EMPTY_TEXT; if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB) return RawText.EMPTY_TEXT; AbbreviatedObjectId id = entry.getId(side); if (!id.isComplete()) { Collection<ObjectId> ids = reader.resolve(id); if (ids.size() == 1) { id = AbbreviatedObjectId.fromObjectId(ids.iterator().next()); switch (side) { case OLD: entry.oldId = id; break; case NEW: entry.newId = id; break; } } else if (ids.size() == 0) throw new MissingObjectException(id, Constants.OBJ_BLOB); else throw new AmbiguousObjectException(id, ids); } ObjectLoader ldr = LfsFactory.getInstance().applySmudgeFilter(repository, source.open(side, entry), entry.getDiffAttribute()); return RawText.load(ldr, binaryFileThreshold); }
private void processTree(RevObject obj) throws TransportException { try { treeWalk.reset(obj); while (treeWalk.next()) { final FileMode mode = treeWalk.getFileMode(0); final int sType = mode.getObjectType(); switch (sType) { case Constants.OBJ_BLOB: case Constants.OBJ_TREE: treeWalk.getObjectId(idBuffer, 0); needs(revWalk.lookupAny(idBuffer, sType)); continue; default: if (FileMode.GITLINK.equals(mode)) continue; treeWalk.getObjectId(idBuffer, 0); throw new CorruptObjectException(MessageFormat.format(JGitText.get().invalidModeFor , mode, idBuffer.name(), treeWalk.getPathString(), obj.getId().name())); } } } catch (IOException ioe) { throw new TransportException(MessageFormat.format(JGitText.get().cannotReadTree, obj.name()), ioe); } obj.add(COMPLETE); }
if (!cached) { final FileMode mode = tw.getFileMode(0); if (mode.getObjectType() == Constants.OBJ_BLOB) { String relativePath = tw.getPathString(); final File path = new File(repo.getWorkTree(),
while (treeWalk.next()) { final FileMode mode = treeWalk.getFileMode(0); final int sType = mode.getObjectType();
if (FileMode.fromBits(thisMode).getObjectType() == OBJ_BAD) { throw new CorruptObjectException(MessageFormat.format( JGitText.get().corruptObjectInvalidMode2,
@Override public int getType() { return ptr.getEntryFileMode().getObjectType(); }
public static boolean isTree(@Nonnull TreeWalk treeWalk) { return treeWalk.getFileMode(0).getObjectType() == Constants.OBJ_TREE; }
@Override public int getType() { return ptr.getEntryFileMode().getObjectType(); }
@NotNull @Override 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); } }
public static boolean isBlob(@Nonnull TreeWalk treeWalk) { return treeWalk.getFileMode(0).getObjectType() == Constants.OBJ_BLOB; }
private boolean isFile(@NotNull FileMode fileMode) { return (fileMode.getObjectType() == Constants.OBJ_BLOB) && ((fileMode.getBits() & FileMode.TYPE_MASK) == FileMode.TYPE_FILE); }
@Nullable @Override public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) { final boolean isDir = fileMode.getObjectType() != Constants.OBJ_BLOB; final PathMatcher matcherChild = matcher.createChild(name, isDir); if ((matcherChild != null) && (isDir || matcherChild.isMatch())) { return new GitFilterProperty(matcherChild, filterName); } return null; }
@Nullable @Override public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) { if (fileMode.getObjectType() == Constants.OBJ_BLOB) { return null; } if (matcher.getSvnMaskGlobal() != null) { return null; } final PathMatcher matcherChild = matcher.createChild(name, true); if (matcherChild == null) { return null; } return new GitAutoProperty(matcherChild, property, value); }
if (parser.getEntryFileMode().getObjectType() == objectType) { idBuf.fromRaw(parser.idBuffer(), parser.idOffset()); add(idBuf, objectType, pathHash);