threads / rfc / 25437

[RFC] Hidden refs

Subject: [RFC] Hidden refs

## tl;dr

8 messages between Oct 13, 2010 and Oct 13, 2010.

replies: 7people: 5as markdown or json

Marc Branchaud· Oct 13, 2010, 15:22 UTC · lore
Hi all,

We want to have our build system record, in our repo, which commits correspond to which builds.

Nominally, this is a job for tags. But we don't want to have to look at these tags all the time. We particularly just want to tag the repo when we make an actual release -- tags are a Big Deal for us.

Notes are an option, though they feel a bit heavy for this application. And although we can store the build notes in their own refspace, it would (I believe) be a little clunky to make commands like checkout and log work with the commits that were noted by the build system.

It struck me that it would be neat to have hidden refs in the refs/ directory. I experimented a bit with a "refs/.builds" directory:

* "git update-ref refs/.builds/One" fails with "Cannot lock the
  ref 'refs/.builds/One'."  So I created a ref the regular way
  (refs/blah/One) and copied the "One" file into refs/.builds/.
* Commands like show, checkout, and log all worked fine with
  "refs/.builds/One"
* "git show-ref" ignores the entries in refs/.builds/.
* So the .builds/ refs don't show up in gitk -- yay!
* "git push origin +refs/.builds/One fails with "remote part of refspec is
not a valid name in +refs/.builds/One".
* Completion in bash doesn't work with entries in refs/.builds/.

So I'm wondering if it makes sense to properly support hidden directories in refs/, and what it would take to do so. (I image, for example, that things would behave quite differently on Windows...)

Thoughts?
		M.
Stephen Bash· Oct 13, 2010, 15:32 UTC · re: Marc Branchaud · lore

Re: [RFC] Hidden refs

Show 7 quoted lines
> So I'm wondering if it makes sense to properly support hidden
> directories in
> refs/, and what it would take to do so. (I image, for example, that
> things
> would behave quite differently on Windows...)
> 
> Thoughts?
We currently use refs/hidden/heads and refs/hidden/tags for hidden refs.  It does require calling 'gitk --branches --tags' rather than 'gitk --all', but otherwise I like the behavior (git branch only lists refs/heads, git tag only lists ref/tags).  And they never get cloned by default (they can still be fetched when needed).
Stephen
Marc Branchaud· Oct 13, 2010, 16:14 UTC · re: Stephen Bash · lore

Re: [RFC] Hidden refs

On 10-10-13 11:32 AM, Stephen Bash wrote:
Show 11 quoted lines
>> So I'm wondering if it makes sense to properly support hidden 
>> directories in refs/, and what it would take to do so. (I image, for
>> example, that things would behave quite differently on Windows...)
>> 
>> Thoughts?
> 
> We currently use refs/hidden/heads and refs/hidden/tags for hidden refs.
> It does require calling 'gitk --branches --tags' rather than 'gitk --all',
> but otherwise I like the behavior (git branch only lists refs/heads, git
> tag only lists ref/tags).  And they never get cloned by default (they can
> still be fetched when needed).
Hmm, maybe I'm just over-designing.

It's true that we could just use refs/builds (instead of .builds) and that those refs would need to be explicitly retrieved by anyone who wanted to see them (which is fine). And after the builds/ refs are fetched and done with, it's easy enough to get rid of them with a simple "rm -r .git/refs/builds"

It appears all I'm looking for is a way to avoid that rm command. Seems a bit silly in the end.

Thanks for the perspective!
		M.
Jeff King· Oct 13, 2010, 17:35 UTC · re: Marc Branchaud · lore

Re: [RFC] Hidden refs

On Wed, Oct 13, 2010 at 11:22:11AM -0400, Marc Branchaud wrote:
Show 11 quoted lines
> We want to have our build system record, in our repo, which commits
> correspond to which builds.
> 
> Nominally, this is a job for tags.  But we don't want to have to look at
> these tags all the time.  We particularly just want to tag the repo when we
> make an actual release -- tags are a Big Deal for us.
> 
> Notes are an option, though they feel a bit heavy for this application.  And
> although we can store the build notes in their own refspace, it would (I
> believe) be a little clunky to make commands like checkout and log work with
> the commits that were noted by the build system.

Keep in mind that notes and tags are basically inverses as far as efficient lookup goes. If you want to map a build name or number to a commit, you would use a ref which points to a commit. But if you want to map a commit sha1 to a build number, you would use notes.

Show 6 quoted lines
> It struck me that it would be neat to have hidden refs in the refs/
> directory.  I experimented a bit with a "refs/.builds" directory:
> 
> * "git update-ref refs/.builds/One" fails with "Cannot lock the
>   ref 'refs/.builds/One'."  So I created a ref the regular way
>   (refs/blah/One) and copied the "One" file into refs/.builds/.

Yeah, I believe "." at the front of a directory component is explicitly forbidden by check_ref_format. I don't recall whether there was a specific rationale, or whether it was simply a can of worms we didn't want to explore.

...

Look like it blames to 03feddd (git-check-ref-format: reject funny ref names., 2005-10-13). This looks like the relevant thread:

  http://article.gmane.org/gmane.comp.version-control.git/9874
but I didn't read through it carefully.
-Peff
Junio C Hamano· Oct 13, 2010, 17:42 UTC · re: Jeff King · lore

Re: [RFC] Hidden refs

Jeff King <peff@peff.net> writes:
> Yeah, I believe "." at the front of a directory component is explicitly
> forbidden by check_ref_format. I don't recall whether there was a
> specific rationale, or whether it was simply a can of worms we didn't
> want to explore.

Is "log foo...bar" a symmetric difference between foo and bar, or is it an assymmetric one from foo and .bar?

Jeff King· Oct 13, 2010, 17:46 UTC · re: Junio C Hamano · lore

Re: [RFC] Hidden refs

On Wed, Oct 13, 2010 at 10:42:41AM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Yeah, I believe "." at the front of a directory component is explicitly
> > forbidden by check_ref_format. I don't recall whether there was a
> > specific rationale, or whether it was simply a can of worms we didn't
> > want to explore.
> 
> Is "log foo...bar" a symmetric difference between foo and bar, or is it an
> assymmetric one from foo and .bar?

Thanks, I was sure there was a simple example of how it would make things ambiguous, but for some reason I couldn't think of one.

-Peff
Junio C Hamano· Oct 13, 2010, 17:51 UTC · re: Jeff King · lore

Re: [RFC] Hidden refs

Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> On Wed, Oct 13, 2010 at 10:42:41AM -0700, Junio C Hamano wrote:
>
>> Jeff King <peff@peff.net> writes:
>> 
>> > Yeah, I believe "." at the front of a directory component is explicitly
>> > forbidden by check_ref_format. I don't recall whether there was a
>> > specific rationale, or whether it was simply a can of worms we didn't
>> > want to explore.
>> 
>> Is "log foo...bar" a symmetric difference between foo and bar, or is it an
>> assymmetric one from foo and .bar?
>
> Thanks, I was sure there was a simple example of how it would make
> things ambiguous, but for some reason I couldn't think of one.

Of course, it points at an existing bug as well. --- the example could mean an asymmetric difference from foo. to bar ;-)

Jonathan Nieder· Oct 13, 2010, 17:53 UTC · re: Junio C Hamano · lore

Re: [RFC] Hidden refs

Junio C Hamano wrote:
>> On Wed, Oct 13, 2010 at 10:42:41AM -0700, Junio C Hamano wrote:
>>> Is "log foo...bar" a symmetric difference between foo and bar, or is it an
[...]
> Of course, it points at an existing bug as well.  --- the example could
> mean an asymmetric difference from foo. to bar ;-)

Fixed about a year ago, I think. :) (cbdffe4, check_ref_format(): tighten refname rules, 2009-03-21, part of v1.6.3)

← back to recent threads