Community
Participate
Working Groups
Using JGit on a shallow clone throws a org.eclipse.jgit.errors.TransportException: Missing commit ..... exception. The issue seems to be that the RevCommit.parents when set to RevCommit.NO_PARENTS by initializeShallowCommits in RevWalk is overwritten before StartGenerator.next is called. This problem can be worked around by calling initializeShallowCommits in StartGenerator.next and commenting out the exception in initializeShallowCommits if it has already been initialized. This is obviously hacking around the problem, fixing this properly will need someone better versed with the JGit source to investigate.
Furhter investigation shows that initializeShallowCommits is never called on the RevWalk instance that is used in StartGenerator. The following patch fixes this, but I am unsure if this patch will cause any unexpected behaviour. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java index 79cc42d..3047ad7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java @@ -201,8 +201,9 @@ * the repository the walker will obtain data from. An * ObjectReader will be created by the walker, and must be * released by the caller. + * @throws RevWalkException */ - public RevWalk(final Repository repo) { + public RevWalk(final Repository repo) throws RevWalkException { this(repo.newObjectReader()); } @@ -213,8 +214,9 @@ * the reader the walker will obtain data from. The reader should * be released by the caller when the walker is no longer * required. + * @throws RevWalkException */ - public RevWalk(ObjectReader or) { + public RevWalk(ObjectReader or) throws RevWalkException { reader = or; idBuffer = new MutableObjectId(); objects = new ObjectIdOwnerMap<RevObject>(); @@ -225,6 +227,12 @@ filter = RevFilter.ALL; treeFilter = TreeFilter.ALL; retainBody = true; + + try { + initializeShallowCommits(); + } catch (IOException e) { + throw new RevWalkException(e); + } } /** @return the reader this walker is using to load objects. */
Any progress on this? It seems blocks pushing from shallow clones to a new Gerrit repos