/** * Advance to next submodule in the index tree. * * The object id and path of the next entry can be obtained by calling * {@link #getObjectId()} and {@link #getPath()}. * * @return true if entry found, false otherwise * @throws java.io.IOException */ public boolean next() throws IOException { while (walk.next()) { if (FileMode.GITLINK != walk.getFileMode(0)) continue; path = walk.getPathString(); return true; } path = null; return false; }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { ObjectId revId = repository.resolve(Constants.HEAD); try (TreeWalk treeWalk = new TreeWalk(repository)) { try (RevWalk revWalk = new RevWalk(repository)) { treeWalk.addTree(revWalk.parseTree(revId)); while (treeWalk.next()) { System.out.println("---------------------------"); System.out.append("name: ").println(treeWalk.getNameString()); System.out.append("path: ").println(treeWalk.getPathString()); ObjectLoader loader = repository.open(treeWalk.getObjectId(0)); System.out.append("directory: ").println(loader.getType() == Constants.OBJ_TREE); System.out.append("size: ").println(loader.getSize()); } } } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { ObjectId revId = repository.resolve(Constants.HEAD); try (TreeWalk treeWalk = new TreeWalk(repository)) { try (RevWalk revWalk = new RevWalk(repository)) { treeWalk.addTree(revWalk.parseTree(revId)); while (treeWalk.next()) { System.out.println("---------------------------"); System.out.append("name: ").println(treeWalk.getNameString()); System.out.append("path: ").println(treeWalk.getPathString()); ObjectLoader loader = repository.open(treeWalk.getObjectId(0)); System.out.append("directory: ").println(loader.getType() == Constants.OBJ_TREE); System.out.append("size: ").println(loader.getSize()); } } } } } }
QuotedString.BOURNE.quote((getPathString()))));
items.add(treeWalk.getPathString()); dirWalk.setRecursive(false); while(dirWalk.next()) { items.add(dirWalk.getPathString());
items.add(treeWalk.getPathString()); dirWalk.setRecursive(false); while(dirWalk.next()) { items.add(dirWalk.getPathString());
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { Ref head = repository.findRef("HEAD"); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); RevTree tree = commit.getTree(); System.out.println("Having tree: " + tree); // now use a TreeWalk to iterate over all files in the Tree // you can set Filters to narrow down the results if needed try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); // not walk the tree recursively so we only get the elements in the top-level directory treeWalk.setRecursive(false); while (treeWalk.next()) { System.out.println("found: " + treeWalk.getPathString()); } } } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { Ref head = repository.findRef("HEAD"); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); RevTree tree = commit.getTree(); System.out.println("Having tree: " + tree); // now use a TreeWalk to iterate over all files in the Tree recursively // you can set Filters to narrow down the results if needed try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); treeWalk.setRecursive(true); while (treeWalk.next()) { System.out.println("found: " + treeWalk.getPathString()); } } } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { Ref head = repository.findRef("HEAD"); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); RevTree tree = commit.getTree(); System.out.println("Having tree: " + tree); // now use a TreeWalk to iterate over all files in the Tree // you can set Filters to narrow down the results if needed try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); // not walk the tree recursively so we only get the elements in the top-level directory treeWalk.setRecursive(false); while (treeWalk.next()) { System.out.println("found: " + treeWalk.getPathString()); } } } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { Ref head = repository.findRef("HEAD"); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); RevTree tree = commit.getTree(); System.out.println("Having tree: " + tree); // now use a TreeWalk to iterate over all files in the Tree recursively // you can set Filters to narrow down the results if needed try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.addTree(tree); treeWalk.setRecursive(true); while (treeWalk.next()) { System.out.println("found: " + treeWalk.getPathString()); } } } } } }
Integer.valueOf(treeWalk.getRawMode(0))), (objectId == null) ? "null" : objectId.name(), //$NON-NLS-1$ treeWalk.getPathString(), // repo.getIndexFile()));
String name = RefTree.refName(tw.getPathString()); Ref oldRef = remote.remove(name); ObjectId oldId = getId(oldRef);
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); }
DirCacheEditor editor = dc.editor(); while (treeWalk.next()) { String path = treeWalk.getPathString();
entry.newPath = entry.oldPath = walk.getPathString();
String entryPath = treeWalk.getPathString(); boolean isDirectory = (treeWalk.getFileMode() == FileMode.TREE); Attributes attributes = new Attributes();
String name = pfx + walk.getPathString(); FileMode mode = walk.getFileMode(0);
final FileMode mode = tw.getFileMode(0); if (mode.getObjectType() == Constants.OBJ_BLOB) { String relativePath = tw.getPathString(); final File path = new File(repo.getWorkTree(), relativePath);
treeWalk.getObjectId(idBuffer, 0); throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3 , mode, idBuffer.name(), treeWalk.getPathString(), tree.name()));
private void checkoutPathsFromCommit(TreeWalk treeWalk, DirCache dc, RevCommit commit) throws IOException { treeWalk.addTree(commit.getTree()); final ObjectReader r = treeWalk.getObjectReader(); DirCacheEditor editor = dc.editor(); while (treeWalk.next()) { final ObjectId blobId = treeWalk.getObjectId(0); final FileMode mode = treeWalk.getFileMode(0); final EolStreamType eolStreamType = treeWalk .getEolStreamType(CHECKOUT_OP); final String filterCommand = treeWalk .getFilterCommand(Constants.ATTR_FILTER_TYPE_SMUDGE); final String path = treeWalk.getPathString(); editor.add(new PathEdit(path) { @Override public void apply(DirCacheEntry ent) { ent.setObjectId(blobId); ent.setFileMode(mode); checkoutPath(ent, r, new CheckoutMetadata(eolStreamType, filterCommand)); actuallyModifiedPaths.add(path); } }); } editor.commit(); }