You need to do something like this:
private static final class RepositoryResolverImplementation implements
RepositoryResolver<DaemonClient> {
@Override
public Repository open(DaemonClient client, String name)
throws RepositoryNotFoundException,
ServiceNotAuthorizedException, ServiceNotEnabledException,
ServiceMayNotContinueException {
InMemoryRepository repo = repositories.get(name);
if (repo == null) {
repo = new InMemoryRepository(
new DfsRepositoryDescription(name));
repositories.put(name, repo);
}
return repo;
}
}
private static Map<String, InMemoryRepository> repositories = new HashMap<String, InMemoryRepository>();
public static void main(String[] args) throws IOException {
Daemon server = new Daemon(new InetSocketAddress(9418));
boolean uploadsEnabled = true;
server.getService("git-receive-pack").setEnabled(uploadsEnabled);
server.setRepositoryResolver(new RepositoryResolverImplementation());
server.start();
}
You should then be able to run git clone git://localhost/repo.git
and a new in-memory 'repo.git' repository will be created. If you want to upload, make sure that the uploadsEnabled is set to 'true' - by default, it is set to 'false'.