Re: [PATCH] Support multiple virtual repositories with a single object store and refs
- From
Shawn Pearce <spearce@spearce.org>
- Date
- May 25, 2011, 16:56 UTC
- Message-ID
- <BANLkTi=WTbEbRoR7pEzja9e5hfoApFhw_w@mail.gmail.com>
- In-Reply-To
- <20110524224711.GA2527@leaf>
On Tue, May 24, 2011 at 15:47, Josh Triplett <josh@joshtriplett.org> wrote:
Show 5 quoted lines
> On Tue, May 24, 2011 at 03:59:37PM -0400, Jeff King wrote: >> You have a namespace clash if a repo is named "heads" or "tags" or >> "remotes". Should we give it its own namespace, like: >> >> refs/virtual/repo1/heads/*
Yes, I strongly agree with Peff here. We should "standardize" the prefix of "refs/virtual/" for these things, to keep them from inteferring with the other "standard" namespaces of refs/heads, refs/remotes, refs/tags, refs/notes, and if Gerrit Code Review is used, refs/changes.
>> Also, it seems conceptually simpler to me if it's a straight prefix. >> IOW, "refs/heads/foo" in repo1 becomes: >> >> refs/virtual/repo1/refs/heads/foo
I also think this is a great idea. It vastly simplifies the operations involved and allows each virtual namespace to have its own HEAD within the virtual namespace, as a sibling of "refs", just like in a normal repository. It may seem a little ugly to put two refs in there, but I think this is easily understood by repository owners/administrators and will keep the implementation much more simple.
Show 12 quoted lines
>> Then if we are operating in the virtual repo1 space, then: >> >> 1. It is an easy test to know whether we are allowed to see a ref: >> "does it start with refs/virtual/$repo/ ?" >> >> 2. Converting back and forth is simple. You just prepend or strip the >> refs/virtual/$repo prefix. > > Both of the namespaces you suggested work with our current patch: > --ref-prefix=virtual/repo1/, or --ref-prefix=virtual/repo1/refs/. We'd > like to leave the exact choice of paths up to the policies of the host, > but your suggestion does seem like a good general namespacing policy.
Ideally your implementation would only add/remove the prefix and wouldn't muck around with the "refs/" part. Then step 1 and step 2 are trivial.
Don't forget that a lot of Git usage comes from shell scripts. Being able to use git for-each-ref with a simple sed script to process these virtual namespaces is really important. If the sed script just needs to remove a prefix, this easy. If it needs to remove part of the prefix and replace with something else, its a bit more complicated for the script writer to work with.
-- Shawn.