I am trying to use JGit to go through a repository, and for each pair of parent/child commits I want to somehow get the difference between them, or the revision made from one to the other. I don't know much about Git or JGit, so this is probably an easy task but I am still stumped.
Would using a RevWalk be a valid way of getting parent/child commits? I saw that in a lot of code snippets from the JGit documentation. I have no clue where to begin about taking the difference between them once I have them, though.
It think this snippet from the jgit-cookbook may be a good starting point. It shows how you can walk across all commits of a local repository.
try (Git git = new Git(repository)) {
Iterable<RevCommit> commits = git.log().all().call();
int count = 0;
for (RevCommit commit : commits) {
System.out.println("LogCommit: " + commit);
count++;
}
System.out.println(count);
}
If you rather look for information from a remote repository, there is a way to at least iterate commits on a remote repository, see this snippet
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.