|Re: [jgit-dev] InMemoryRepository and HEAD reference|
On Mon, Mar 18, 2013 at 1:10 PM, Alex Blewitt <alex.blewitt@xxxxxxxxx> wrote: > If I use the InMemoryRepository to set up a simple DFS based Git repository, I can push and clone over the Git protocol fairly easily with: > > Daemon daemon = new Daemon(new InetSocketAddress(9148)); > daemon.getService("git-receive-pack").setEnabled(true); > daemon.setRepositoryResolver(…return new InMemoryRepository()); > daemon.start(); > > However, when I clone from this repository I get a message: > > warning: remote HEAD refers to nonexistent ref, unable to checkout > > If I try to add HEAD as a symbolic reference to refs/master/head in the 'scanAllRefs' of the InMemoryRefDatabase, when I check out I get an error on the server side where the RefMap class is trying to compare a loose refs/heads/master with a symbolic reference HEAD -> refs/heads/master, and then falling into the WTF comment of RefMap's 'resolveloose' method. > > On the other hand, if I had HEAD as a non-symbolic reference (using new ObjectIdRef.PeeledNonTag with a name of HEAD) then it seems to work as expected. > > Is managing a virtual HEAD ref on the server the right way to go about this, and do I need to hook up a listener such that when the default branch is changed I also update the HEAD, or is there a better way of solving the 'default branch' problem in JGit with DFS? I think this is a bug in MemRefDatabase, the inner class of InMemoryRepository. HEAD works correctly as a symbolic reference in our storage system at Google. So it works correctly in a DFS type repository. Our implementation of DfsRefDatabase is ~1200 lines of non-trivial code, but I can't see anything really wrong with MemRefDatabase just by glancing at it. How did you add the HEAD to the InMemoryRepository?
Back to the top