use of org.eclipse.jgit.revwalk.ObjectWalk in project egit by eclipse.
the class GitSynchronizeData method updateRevs.
/**
* Recalculates source, destination and ancestor Rev commits
*
* @throws IOException
*/
public void updateRevs() throws IOException {
try (ObjectWalk ow = new ObjectWalk(repo)) {
ow.setRetainBody(true);
srcRevCommit = getCommit(srcRev, ow);
dstRevCommit = getCommit(dstRev, ow);
}
if (this.dstRevCommit != null && this.srcRevCommit != null)
this.ancestorRevCommit = getCommonAncestor(repo, this.srcRevCommit, this.dstRevCommit);
else
this.ancestorRevCommit = null;
}
use of org.eclipse.jgit.revwalk.ObjectWalk in project gerrit by GerritCodeReview.
the class RefUtil method verifyConnected.
public static RevWalk verifyConnected(Repository repo, ObjectId revid) throws InvalidRevisionException {
try {
ObjectWalk rw = new ObjectWalk(repo);
try {
rw.markStart(rw.parseCommit(revid));
} catch (IncorrectObjectTypeException err) {
throw new InvalidRevisionException(revid.name(), err);
}
RefDatabase refDb = repo.getRefDatabase();
Iterable<Ref> refs = Iterables.concat(refDb.getRefsByPrefix(Constants.R_HEADS), refDb.getRefsByPrefix(Constants.R_TAGS));
Ref rc = refDb.exactRef(RefNames.REFS_CONFIG);
if (rc != null) {
refs = Iterables.concat(refs, Collections.singleton(rc));
}
for (Ref r : refs) {
try {
rw.markUninteresting(rw.parseAny(r.getObjectId()));
} catch (MissingObjectException err) {
continue;
}
}
rw.checkConnectivity();
return rw;
} catch (IncorrectObjectTypeException | MissingObjectException err) {
throw new InvalidRevisionException(revid.name(), err);
} catch (IOException err) {
logger.atSevere().withCause(err).log("Repository \"%s\" may be corrupt; suggest running git fsck", repo.getDirectory());
throw new InvalidRevisionException(revid.name());
}
}
Aggregations