Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] RevWalk problems with shallow clones

> The way to do handle the shallow stuff is to actually insert
> pre-parsed RevCommit objects into the RevWalk object pool that have
> the parents truncated away, similar to a graft (which we also don't
> support). This will keep JGit from walking backwards into the commits
> it doesn't have, and thus avoid the MissingObjectException you noted.

That means to parse probably a lot of shallow commits which are actually
never encountered for a specific RevWalk. Couldn't we detect shallow
commits lazily -- would following approach work?

RevCommit.parseCanonical() uses RevWalk.lookupCommit() to resolve
parents. We could introduce a new package-protected method:

lookupCommit(final AnyObjectId id, final AnyObjectId child)

On the otherside we would have new

public RevWalk.markShallow(final AnyObjectId id)

Now, when new lookupCommit() receives a child being part of commits
marked as shallow, it will return null and RevCommit.parseCanonical()
then will simply ignore that parent.

--
Best regards,
Marc Strapetz
=============
syntevo GmbH
http://www.syntevo.com
http://blog.syntevo.com



On 11.08.2011 19:05, Shawn Pearce wrote:
> On Thu, Aug 4, 2011 at 03:36, Marc Strapetz <marc.strapetz@xxxxxxxxxxx> wrote:
>> A RevWalk on a repository which had been cloned with --depth flag
>> results in following stack trace. I'm wondering if PendingGenerator
>> could be more tolerant if told so by some kind of flag? The flag would
>> probably be set when .git/shallow exists.
> 
> Right, we have not yet implemented shallow client support in JGit.
> 
> The way to do handle the shallow stuff is to actually insert
> pre-parsed RevCommit objects into the RevWalk object pool that have
> the parents truncated away, similar to a graft (which we also don't
> support). This will keep JGit from walking backwards into the commits
> it doesn't have, and thus avoid the MissingObjectException you noted.
> 
> That isn't a complete solution, the transport code also needs to know
> how to fetch into a shallow repository. But it would certainly help to
> fix RevWalk so its not crashing.
> 


Back to the top