What’s the intended/reasonable usage patterns for symrefs?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This was posted in 2011:

“What's the definition of a valid Git symbolic reference?”

https://lore.kernel.org/git/AANLkTinsJkzYggMtNrLRv-qNxRncrXSe6A46Z=d8xkw7@xxxxxxxxxxxxxx/

And the answer said that:

> Emeric Fermas <emeric.fermas@xxxxxxxxx> writes:
>
> >  Once again, by reading at the code I can understand how those commands
> > currently work. What I'm trying to achieve is to understand what
> > should be their recommended usage.
>
> There are only two valid kinds of symrefs right now:
>
>  - .git/HEAD, pointing at somewhere under refs/heads/ hierarchy;
>
>  - .git/refs/remotes/<some remote name>/HEAD, pointing at somewhere under
>    refs/remotes/<the same remote name>/ hierarchy.
>
> The code may be prepared to resolve recursive symrefs, symrefs other than
> the above two kinds, symrefs that point at elsewhere, but all of them are
> outside of the design scope of what the mechanism was intended to support.
> What the code do to them (without crashing) is not the design, but simply
> an undefined behaviour.
>
> This won't change very much if we decide to reorganize the remote tracking
> hierarchies in 1.8.0.  The former won't change at all, and the latter will
> start pointing at refs/remotes/<the same remote name>/heads hierarchy
> instead.
>
> I vaguely recall tg abused the symref mechanism to point .git/HEAD at
> funny locations; it may still be doing so, and if that is the case we
> should extend the above list to cover that usage.

https://lore.kernel.org/git/7vsjvpq0jk.fsf@xxxxxxxxxxxxxxxxxxxxxxxx/

This was motivated by a StackOverflow[1] question/thread.  Which should
maybe get an update if this thread reveals some new information.

🔗 1: https://stackoverflow.com/a/5000668/1725151

This seems overly restrictive for this day and age though? No?

I only know that

1. Symref manipulation is a plumbing command
2. That means that you can do weird stuff without getting slapped on the
   wrist
3. The plumbing man pages sometimes feel inert, like they either don’t
   fit into a greater whole or they don’t want to tell you
   (git-rev-list(1) is apparently the plumbing dual to git-log(1) but
   all I can see is some references at the bottom like “see also the
   porcelain git-log(1)” (in a 1200 line page)

In conclusion: I might end up doing things which I’m not really supposed
to. Because these commands are unopinionated.

What I’ve done lately that might give *weird* results:

• Create a one-level symref (one-level “because it’s short”)
• Then you might get “ambigious” warnings if some branch ref has the
  same name

But what seems fine so far:

• Create a `refs/heads/<symref>` which points to a remote-tracking branch

This is so that I can

• Have a short name for some long-living branches (sometimes they live
  longer than we would have planned for)
• So that I can rebase and set upstream on the remote-tracking branch.
  That way I don’t need to maintain a branch which just follows the
  remote-tracking one

Is this okay?  And what can you reasonably do in general terms with
symrefs?

Just as an example of something that is probably not fine: I’ve read
that symrefs are dereferenced only to a depth of four.  And then you
don’t want to create some contraption which relies on many levels of
dereferencing.

Thanks!

-- 
Kristoffer





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux