I need the last commit with affected the path something similar to git log -1 -- path
.
Currently, I am doing this
TreeWalk.forPath(repo, filepath, rootCommit.getTree()).getObjectId(0)
Is there any faster way to achieve this?
I need the last commit with affected the path something similar to git log -1 -- path
.
Currently, I am doing this
TreeWalk.forPath(repo, filepath, rootCommit.getTree()).getObjectId(0)
Is there any faster way to achieve this?
Another option would be to use the Porcelain command for "log", it uses a RevWalk internally, so it might run with different timings, however I am not sure which one will be faster, it may also depend on the repository size and structure to some degree...
Iterable<RevCommit> logs = new Git(repository).log()
.addPath("README.md")
.setMaxCount(1)
.call();
for(RevCommit rev : logs) {
System.out.println("Commit: " + rev);
}