Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] InMemoryRepository and HEAD reference

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.setRepositoryResolver(…return new InMemoryRepository());

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?


Back to the top