Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Commits and tags

Hi, All !

I'm using jgit from org.eclipse.jgit_2.0.0.201206121211.jar. Could
anybody please to help me to solve issue ?

I need to find last tagged commit in my branch.
http://stackoverflow.com/questions/7501646/jgit-retrieve-tag-associated-with-a-git-commit?rq=1
doesn't help me because git.tagList().call() returns List<Ref> instead
List<RevTag>.

As far as I understand, I can get reference to tagged RevCommit by
tagRef.getPeeledObjectId(). Am I right ?

So, I created RevWalk by code:

Ref ref = gitRepository.getRef(Constants.HEAD);
RevWalk walk = new RevWalk(gitRepository);
walk.markStart(walk.parseCommit(ref.getObjectId()));
for (RevCommit commit : walk) {
  ...
}

I have correct list of commits from latest to earlier, and I want to
compare each commit with tags. I retrieved tags by
gitRepository.getTags(). Refs in this map pointed to tag, not to
commit. Just like in .git/refs/tags/* files. But for all tags in this
map, tagRef.getPeeledObjectID() is always null.

After that, I runned "git gc" from command line, then it moved tags to
.git/packed-refs file. After that, tagRef.getPeeledObjectId() contains
correct ID for commit.

So, am I using correct algorithm for find last tagged commit ? Why
tagRef.getPeeledObjectId() works only after "git gc" ? Is it jgit bug
?

BTW, I created tags by JGit.

WBR, Alex.


Back to the top