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

Re: [PATCH] refspec: allow @ on the left-hand side of refspecs

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 30, 2018, 23:14 UTC
Message-ID
<20180730231451.GG945730@genre.crustytoothpaste.net>
In-Reply-To
<20180730175051.GA154732@google.com>
On Mon, Jul 30, 2018 at 10:50:51AM -0700, Brandon Williams wrote:
Show 18 quoted lines
> On 07/29, brian m. carlson wrote:
> > The object ID parsing machinery is aware of "@" as a synonym for "HEAD"
> > and this is documented accordingly in gitrevisions(7).  The push
> > documentation describes the source portion of a refspec as "any
> > arbitrary 'SHA-1 expression'"; however, "@" is not allowed on the
> > left-hand side of a refspec, since we attempt to check for it being a
> > valid ref name and fail (since it is not).
> > 
> > Teach the refspec machinery about this alias and silently substitute
> > "HEAD" when we see "@".  This handles the fact that HEAD is a symref and
> > preserves its special behavior.  We need not handle other arbitrary
> > object ID expressions (such as "@^") when pushing because the revision
> > machinery already handles that for us.
> 
> So this claims that using "@^" should work despite not accounting for it
> explicitly or am I misreading?  Unless I'm mistaken, it looks like we
> don't really support arbitrary rev syntax in refspecs since "HEAD^"
> doesn't work either.
Correct, it does indeed work, at least for me:
genre ok % git push castro HEAD^:refs/heads/temp
Total 0 (delta 0), reused 0 (delta 0)
To https://git.crustytoothpaste.net/git/bmc/git.git
 * [new branch]            HEAD^ -> temp
genre ok % git push castro @^:refs/heads/temp
Total 0 (delta 0), reused 0 (delta 0)
To https://git.crustytoothpaste.net/git/bmc/git.git
 * [new branch]            @^ -> temp

Note that in this case, I had to specify a full ref since it didn't exist on the remote and the left side wasn't a ref name.

Now it doesn't work for fetches, only pushes. Only the left side of a push refspec can be an arbitrary expression.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Brandon WilliamsNext: Brandon Williams
Message 3 of 4 in “refspec: allow @ on the left-hand side of refspecs”
  1. refspec: allow @ on the left-hand side of refspecsbrian m. carlson, Jul 29, 2018
  2. Brandon WilliamsJul 30, 2018
  3. brian m. carlsonJul 30, 2018
  4. Brandon WilliamsJul 31, 2018

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.