LogCommand.all(): filter out refs that do not refer to commit objects
1. I have authored 100% of the content I'm contributing, 2. I have the rights to donate the content to Eclipse, 3. I contribute the content under the EDL Change-Id: I48b1828e0b1304f76276ec07ebac7ee9f521b194
This commit is contained in:
parent
2b9c440fd1
commit
35be98fb8f
|
@ -100,11 +100,17 @@ public void logAllCommitsWithTag() throws Exception {
|
||||||
commits.add(git.commit().setMessage("initial commit").call());
|
commits.add(git.commit().setMessage("initial commit").call());
|
||||||
|
|
||||||
TagCommand tagCmd = git.tag();
|
TagCommand tagCmd = git.tag();
|
||||||
tagCmd.setName("tagname");
|
tagCmd.setName("tagcommit");
|
||||||
tagCmd.setObjectId(commits.get(0));
|
tagCmd.setObjectId(commits.get(0));
|
||||||
tagCmd.setTagger(new PersonIdent(db));
|
tagCmd.setTagger(new PersonIdent(db));
|
||||||
Ref tag = tagCmd.call();
|
Ref tag = tagCmd.call();
|
||||||
|
|
||||||
|
tagCmd = git.tag();
|
||||||
|
tagCmd.setName("tagtree");
|
||||||
|
tagCmd.setObjectId(commits.get(0).getTree());
|
||||||
|
tagCmd.setTagger(new PersonIdent(db));
|
||||||
|
tagCmd.call();
|
||||||
|
|
||||||
Iterator<RevCommit> log = git.log().all().call().iterator();
|
Iterator<RevCommit> log = git.log().all().call().iterator();
|
||||||
assertTrue(log.hasNext());
|
assertTrue(log.hasNext());
|
||||||
RevCommit commit = log.next();
|
RevCommit commit = log.next();
|
||||||
|
|
|
@ -241,10 +241,23 @@ public LogCommand all() throws IOException {
|
||||||
for (Ref ref : getRepository().getAllRefs().values()) {
|
for (Ref ref : getRepository().getAllRefs().values()) {
|
||||||
if(!ref.isPeeled())
|
if(!ref.isPeeled())
|
||||||
ref = getRepository().peel(ref);
|
ref = getRepository().peel(ref);
|
||||||
|
|
||||||
ObjectId objectId = ref.getPeeledObjectId();
|
ObjectId objectId = ref.getPeeledObjectId();
|
||||||
if (objectId == null)
|
if (objectId == null)
|
||||||
objectId = ref.getObjectId();
|
objectId = ref.getObjectId();
|
||||||
add(objectId);
|
RevCommit commit = null;
|
||||||
|
try {
|
||||||
|
commit = walk.parseCommit(objectId);
|
||||||
|
} catch (MissingObjectException e) {
|
||||||
|
// ignore: the ref points to an object that does not exist;
|
||||||
|
// it should be ignored as traversal starting point.
|
||||||
|
} catch (IncorrectObjectTypeException e) {
|
||||||
|
// ignore: the ref points to an object that is not a commit
|
||||||
|
// (e.g. a tree or a blob);
|
||||||
|
// it should be ignored as traversal starting point.
|
||||||
|
}
|
||||||
|
if (commit != null)
|
||||||
|
add(commit);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue