List of usage examples for org.eclipse.jgit.treewalk CanonicalTreeParser getEntryPathBuffer
public byte[] getEntryPathBuffer()
From source file:playRepository.BareCommit.java
License:Apache License
private TreeFormatter rebuildExistingTreeWith(String fileName, ObjectId fileObjectId) throws IOException { TreeFormatter formatter = new TreeFormatter(); CanonicalTreeParser treeParser = getCanonicalTreeParser(this.repository); boolean isInsertedInTree = false; while (!treeParser.eof()) { String entryName = new String(treeParser.getEntryPathBuffer(), 0, treeParser.getEntryPathLength(), Config.getCharset());/* w ww . j a v a 2s . c o m*/ String nameForComparison = entryName; if (treeParser.getEntryFileMode() == FileMode.TREE) { nameForComparison = entryName.concat("/"); //for tree ordering comparison } if (nameForComparison.compareTo(fileName) == 0 && isInsertedInTree == false) { formatter.append(fileName, FileMode.REGULAR_FILE, fileObjectId); isInsertedInTree = true; } else if (nameForComparison.compareTo(fileName) > 0 && isInsertedInTree == false) { formatter.append(fileName, FileMode.REGULAR_FILE, fileObjectId); formatter.append(entryName.getBytes(Config.getCharset()), treeParser.getEntryFileMode(), treeParser.getEntryObjectId()); isInsertedInTree = true; } else { formatter.append(entryName.getBytes(Config.getCharset()), treeParser.getEntryFileMode(), treeParser.getEntryObjectId()); } treeParser = treeParser.next(); } if (!isInsertedInTree) { formatter.append(fileName, FileMode.REGULAR_FILE, fileObjectId); } return formatter; }