Supporting Namespaces in cgit

John Keeping john at
Mon May 9 23:31:37 CEST 2016

On Mon, May 09, 2016 at 09:34:24PM +0100, Daniel Silverstone wrote:
> One of the projects I am involved with is called Gitano[1] and is a Git server
> along the lines of Gitolite or Gitosis, but not along the lines of Gitlab or
> Gitorious.  Among various technologies developed by other projects, we
> recommend the use of CGit for visualising the Git repositories hosted in a
> Gitano instance; and we have been very pleased with CGit in the three or
> four years we've been using it.
> We have recently been looking at ways to support server-side repository forks
> in Gitano and how we might use namespaces to support that.  In addition that
> led to us thinking about how we could segregate Gitano's administration refs
> into a namespace to keep things cleaner.  However if we were to use server-side
> namespaces for that, then we would need to ensure our chosen web visualisation
> tool (CGit) was able to deal with it.
> An examination of the code (thorough, but admittedly a while ago) failed to
> find any support for Git namespaces in CGit, but I wondered firstly if
> namespaces had ever been considered for support in CGit?  If not yet
> considered, would support for namespaces be something that the CGit project
> might entertain?  We would be very prepared to do a first pass set of patches,
> or indeed a design document first if that were desirable; but given our
> relative inexperience in the CGit codebase we would very much appreciate
> pointers and assistance from the CGit community.
> Obviously, if namespace support is not something that the CGit community wants
> to see done then we will have to rethink some of our backend design decisions.
> Similarly, if it's interesting but there is no intention to make a CGit release
> within the timeframe we'd be working to (approx. November time at the latest)
> then we'll need to think again.
> I appreciate this is a fairly content-free mail that seems to be asking so much
> and offering very little, so in brief summary:
> 1. We'd like CGit to support namespaces on a per-repo basis
> 2. We're prepared to head up the design and/or implementation of this
> 3. But only if the CGit community thinks this is at least possible to get
>    merged into a release the near future (next 6 months or so).
> I look forward to your opinions, even if they're in the negative.

I'm curious what you expect the UI for this to look like.  Would
namespaces appear under the repository in the URL?  If so, what does the
base repository look like?  (Although after I finished thinking this
through and writing the rest of the email maybe this doesn't actually
matter - see the last paragraph.)

Implementation-wise, it looks like using a namespace should just be a
matter of setting GIT_NAMESPACE in the environment near the top of

Discovering namespaces is more interesting, since we can't know what
exactly is a namespace.  For example, if we have:


is the namespace "foo" or "foo/bar"?  Maybe checking for "heads" and
"tags" subdirectories is enough, but I'm not familiar enough with
namespaces to know if those will definitely exist, and obviously users
can create or delete any directories anywhere in the hierarchy.

Also, any attempt to discover namespaces during automated repository
discovery (i.e. cgitrc's "scan-tree") is likely to be quite expensive
with reading packed-refs and the whole loose refs tree.  However, it
sounds like Gitano probably generates an explicit repository list, in
which case a "repo.namespace" config key should be usable.

If we can indeed ignore any attempt to discover namespaces and just use
"repo.namespace", is it enough to add that config value to
"struct cgit_repo" and then pass it to setenv() in prepare_repo_cmd()?

More information about the CGit mailing list