I am trying to read Git Notes information from a custom ref refs/notes/abcd
of a particular commit in a repository using JGit
Here is what I tried:
Repository repository = repositoryManager.openRepository(repoName);
Git git = new Git(repository);
ObjectId oid = repository.resolve("5740b142a7b5f66768a2d904b267dccaef1a095f");
Note note = git.notesShow().setNotesRef("refs/notes/abcd").setObjectId(oid).call();
ObjectLoader loader = repository.open(note.getData());
byte[] data = loader.getBytes();
System.out.println(new String(data, "utf-8"));
I get the following compilation error:
error: incompatible types: org.eclipse.jgit.lib.ObjectId cannot be converted to org.eclipse.jgit.revwalk.RevObject
How do I pass a RevObject
variable to Git setObjectId()
given a commit-sha string?
With a
RevWalk
, the object id can be parsed and the resultingRevCommit
can be passed to theShowNoteCommand
.For example: