This question is the opposite of this question: JGit, how do I get SHA1 from RevCommit? .
If I am assigned the SHA1 identifier of a particular commit as a string, how can I get the ObjectId or the associated RevCommit in JGit?
Here is a possible answer that RevCommit through all RevCommit s:
RevCommit findCommit(String SHAId) { Iterable<RevCommit> commits = git_.log().call(); for (RevCommit commit: commits) { if (commit.getName().equals(SHAId)) return commit; } return null; }
Is there anything better than this implementation above?
jgit sha1
modulitos
source share