git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Remove restriction on notes ref base

From
Johan Herland <johan@herland.net>
Date
Nov 5, 2010, 01:29 UTC
Message-ID
<201011050229.15941.johan@herland.net>
In-Reply-To
<20101104145817.GA27580@sigill.intra.peff.net>
On Thursday 04 November 2010, Jeff King wrote:
Show 26 quoted lines
> On Thu, Nov 04, 2010 at 01:49:47AM +0100, Johan Herland wrote:
> > I'd probably suggest a more straightforward (and hopefully less
> > confusing)
> > 
> > setup like this:
> >   Remote repo    ->   Local repo
> >   ------------------------------------------------
> >   refs/heads/*        refs/remotes/$remote/heads/*
> >   refs/tags/*         refs/remotes/$remote/tags/*
> >   refs/notes/*        refs/remotes/$remote/notes/*
> > 
> > ...and these would all be set in the config, i.e. no implicit/magic
> > refspecs.
> 
> I have often considered that something like that would be simpler, too.
> But just specifying
> 
>   fetch = refs/tags/*:refs/remotes/$remote/tags/*
> 
> would pull down _all_ tags from the remote. Right now we only pull down
> tags for things that we are actually fetching (i.e., auto-follow).
> 
> Now you could argue that auto-follow is not worth the effort. It is
> somewhat confusing, and I can't think of a time when it ever actually
> reduced the set of objects I was fetching (as opposed to just fetching
> all tags). But maybe others have use cases where it matters.

Actually, I don't have anything against auto-follow per se, and we could easily enough extend the refspec to specify auto-follow behaviour: There is currently the "+" prefix for specifying a forced (non-fast-forward) update. We could for example add a "~" prefix for specifying that the refs matched by this refspec should only be fetched if they are part of the history fetched by other refspecs. We could then reproduce the current auto-follow behaviour with the following pair of refspecs:

  +refs/heads/*:refs/remotes/origin/*
  ~+refs/tags/*:refs/tags/*
or in my above proposal:
  +refs/heads/*:refs/remotes/$remote/heads/*
  ~+refs/tags/*:refs/remotes/$remote/tags/*
  +refs/notes/*:refs/remotes/$remote/notes/*
Show 17 quoted lines
> > We would, for example, extend the ref disambiguation of <name> (as
> > documented in the "SPECIFYING REVISIONS" section of git-rev-parse(1)),
> > so that in the cases where <name> is of the form "<foo>/<bar>" AND
> > <foo> is an existing remote, we also check for the following refs
> > (after none of the
> > 
> > existing checks have returned a match):
> >   7. refs/remotes/<foo>/tags/<bar>
> >   8. refs/remotes/<foo>/heads/<bar>
> 
> This codifies that refs for remote $foo are in refs/remotes/$foo, which
> is something we have avoided so far. For example, when finding the
> "upstream" branch, we have the name of the remote and the merge branch,
> look up the fetch refspecs in the config, and then figure out where that
> branch would be fetched to. Which of course turns out as you say (as
> remotes/$remote_name/$branch) in the default config, but we don't
> restrict people to that.

We can do the same for "foo/bar" as well, although things become slightly more fiddly:

When "foo" exists as a remote, look up its fetch refspec(s), and determine possible mappings for name "bar". I.e. given the following (non-default) refspecs for remote "foo":

  +refs/heads/*:refs/remotes/spam/heads/*
  +refs/tags/*:refs/remotes/eggs/tags/*
  +refs/notes/*:refs/remotes/bacon/notes/*

we know that the intersection between the left side of these refspec and the ref disambiguation rules consists of "refs/tags/bar" and "refs/heads/bar" (in that order). We can then map these to the right side of the refspec to get "refs/remotes/eggs/tags/bar" and "refs/remotes/spam/heads/bar" (in that order). We would then use the first match from these alternatives.

...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Jeff KingNext: Jeff King
Message 19 of 21 in “Remove restriction on notes ref base”
  1. Remove restriction on notes ref baseKenny Root, Nov 2, 2010
  2. Jonathan NiederNov 2, 2010
  3. Johan HerlandNov 2, 2010
  4. Shawn PearceNov 2, 2010
  5. Jeff KingNov 2, 2010
  6. Johan HerlandNov 2, 2010
  7. Junio C HamanoNov 2, 2010
  8. Johan HerlandNov 2, 2010
  9. Chris ForbesNov 2, 2010
  10. Jonathan NiederNov 3, 2010
  11. Junio C HamanoNov 3, 2010
  12. Sverre RabbelierNov 3, 2010
  13. Johan HerlandNov 4, 2010
  14. Sverre RabbelierNov 4, 2010
  15. Tag refspecs (was Re: [PATCH] Remove restriction on notes ref base)Marc Branchaud, Nov 4, 2010
  16. Johan HerlandNov 5, 2010
  17. Marc BranchaudNov 5, 2010
  18. Jeff KingNov 4, 2010
  19. Johan HerlandNov 5, 2010
  20. Jeff KingNov 5, 2010
  21. Jonathan NiederNov 3, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.