This post explains how to apply a reference filter to your Git server using
JGit. This might be useful if you want to filter refs, e.g. hide internal refs.
This can be achieved by implementing the interface RefFilter. Once
implemented, you just need to apply it to your upload-pack factory so that it
can change the upload-pack creation.
If you’re not familiar with Git references, this post will be too difficult
for you. I suggest you to first take a look at
§10.3 Git Internals - Git References of book “Pro Git”, you’ll
get a much better understanding of this subject.
Let’s code. First of all, implement the RefFilter:
Then, include it in your upload-pack factory to change the upload-pack creation.
For example, only takes the public refs refs/heads/public/.* in the ref
database, and provide them to the client:
At the end, use this upload-pack factory in your GitServlet:
That’s it. Now it should work :)
"Pro Git (2nd Edition)" contains everything you need to know about Git,
written by Scott Chacon and Ben Straub.
The print version is available on Amazon: