Thread (4 messages) flat view 4 messages, 2 authors, 2018-07-31

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

From: Brandon Williams <hidden>
Date: 2018-07-31 16:02:18

On 07/30, brian m. carlson wrote:
On Mon, Jul 30, 2018 at 10:50:51AM -0700, Brandon Williams wrote:
quoted
On 07/29, brian m. carlson wrote:
quoted
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.
That's what I was missing, a full refspec! Thanks for the illustration.
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


-- 
Brandon Williams
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help