Get мерзавец файл состояния с помощью JGit
// find the HEAD
ObjectId lastCommitId = existingRepo.resolve(Constants.HEAD);
// a RevWalk allows to walk over commits based on some filtering that is defined
try (RevWalk revWalk = new RevWalk(existingRepo)) {
RevCommit commit = revWalk.parseCommit(lastCommitId);
// and using commit's tree find the path
RevTree tree = commit.getTree();
// now try to find a specific file
try (TreeWalk treeWalk = new TreeWalk(existingRepo)) {
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
treeWalk.setFilter(PathFilter.create("TestProject/test1"));
if (!treeWalk.next()) {
throw new IllegalStateException("Did not find expected file");
}
ObjectId objectId = treeWalk.getObjectId(0);
ObjectLoader loader = existingRepo.open(objectId);
// and then one can the loader to read the file
loader.copyTo(System.out);
// Get status
Git git = new Git(existingRepo);
StatusCommand status = git.status().addPath(treeWalk.getPathString());
System.out.println("Not Modified : " + status.call().getModified().isEmpty());
}
могли бы вы объяснить подробнее? – Alice
Как они отображаются в столбце состояния прикрепленного изображения, я хочу получить API в JGIT –
Вы проверили http://stackoverflow.com/questions/23508315/git-status-does-not-show-changes-when-creating -repo-in-jgit – Alice