I\'m trying to get my hands on the HEAD commit with JGit:
val builder = new FileRepositoryBuilder()
val repo = builder.setGitDir(new File(\"/www/test-repo\")
For the completeness sake, here is a fully working example how to get the hash for the HEAD commit:
public String getHeadName(Repository repo) {
String result = null;
try {
ObjectId id = repo.resolve(Constants.HEAD);
result = id.getName();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}