* Pushing symbolic references to remote repositories?
@ 2012-12-21 19:53 Dun Peal
2012-12-21 21:54 ` Shawn Pearce
0 siblings, 1 reply; 6+ messages in thread
From: Dun Peal @ 2012-12-21 19:53 UTC (permalink / raw)
To: Git ML
Hi,
I need to share a symbolic reference - essentially, a named pointer to
another reference - among multiple repositories.
As shown in the code below, I can successfully create a local
symbolic-ref `foo_ptr` to branch `foo`, but can't push it to a remote,
in this case `origin`:
$ git branch foo; git symbolic-ref foo_ptr refs/heads/foo; git rev-parse foo_ptr
fbfec27dc6d42d48ca5d5b178caa34c666a4c39b
$ git push origin foo foo_ptr
error: dst ref refs/heads/foo receives from more than one src.
Is there a clean and reliable way to do that, or are symbolic
references just not meant to be shared?
Thanks, D.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pushing symbolic references to remote repositories?
2012-12-21 19:53 Pushing symbolic references to remote repositories? Dun Peal
@ 2012-12-21 21:54 ` Shawn Pearce
2012-12-21 23:11 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Shawn Pearce @ 2012-12-21 21:54 UTC (permalink / raw)
To: Dun Peal; +Cc: Git ML
On Fri, Dec 21, 2012 at 11:53 AM, Dun Peal <dunpealer@gmail.com> wrote:
> I need to share a symbolic reference - essentially, a named pointer to
> another reference - among multiple repositories.
>
> As shown in the code below, I can successfully create a local
> symbolic-ref `foo_ptr` to branch `foo`, but can't push it to a remote,
> in this case `origin`:
>
> $ git branch foo; git symbolic-ref foo_ptr refs/heads/foo; git rev-parse foo_ptr
> fbfec27dc6d42d48ca5d5b178caa34c666a4c39b
> $ git push origin foo foo_ptr
> error: dst ref refs/heads/foo receives from more than one src.
>
> Is there a clean and reliable way to do that, or are symbolic
> references just not meant to be shared?
There is no support for symbolic references in the network protocol,
so they cannot currently be shared by git push or git fetch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pushing symbolic references to remote repositories?
2012-12-21 21:54 ` Shawn Pearce
@ 2012-12-21 23:11 ` Junio C Hamano
2012-12-22 9:26 ` Andreas Schwab
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2012-12-21 23:11 UTC (permalink / raw)
To: Dun Peal; +Cc: Shawn Pearce, Git ML
Shawn Pearce <spearce@spearce.org> writes:
> On Fri, Dec 21, 2012 at 11:53 AM, Dun Peal <dunpealer@gmail.com> wrote:
>>
>> Is there a clean and reliable way to do that, or are symbolic
>> references just not meant to be shared?
>
> There is no support for symbolic references in the network protocol,
> so they cannot currently be shared by git push or git fetch.
What Shawn said is technically correct, but do not read it as "we
know what protocol update we want at the network level, but we
haven't got around implementing it".
It is unclear what it means to send symrefs across repositories
(rather, what we want it to mean). In that sense, the reality is
closer to the latter of your choices.
There are three primary kinds of symrefs to consider:
* worktree/.git/HEAD is meant to point at the branch that is
currently checked out. This is designed to be under sole control
of the person who is working in such a repository and the outside
people have no business knowing which branch he happens to be
working on at this very moment (it can change the next minute).
* worktree/.git/refs/remotes/$name/HEAD is meant to point at the
remote-tracking branch of the named remote (e.g. 'origin') the
local user is interested in, to let "git checkout -b topic
origin" work, instead of a longer "git checkout -b topic
origin/master".
* bare.git/HEAD is meant to point at the "primary" branch at a
bare, distribution repository nobody works in directly. The
branch pointed at by the symref rarely, if ever, changes.
Nobody will imagine flipping worktree/.git/HEAD from outside by
pushing into it (unless you are trying to pull a prank on the user
who is working in that repository). Also, nobody would want to
update this symref by fetching from outside. So we won't have to
consider updating the first kind in the following discussion.
It is unlikely that anybody sane wants to update the remote-tracking
worktree/.git/refs/remotes/origin/HEAD from outside by pushing.
It *may* make sense to update it upon fetching, though, in some
cases. You first clone from bare.git/HEAD and learn [*1*] that the
primary branch at the time of cloning was 'master', and
remote/origin/HEAD in your repository is set to point at
origin/master. Now the upstream designates a different branch as
the primary (perhaps 'trunk'), and you may want your next "git
fetch" to repoint your remote/origin/HEAD to point at
'remote/origin/trunk'.
However, even this one is not unconditionally a good idea. The
branch you are interested in might be different from what your
remote designates as its primary branch in the first place. You may
for example want to follow along 'next' after cloning from me. E.g.
$ git clone git://git.kernel.org/pub/scm/git/git.git git
$ cd git
$ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/next
It is not clear if it is a good idea to allow "git fetch" to repoint
your remotes/origin/HEAD to whatever I chose to point my HEAD at.
So for the second kind, pushing is irrelevant, and fetching is
"perhaps sometimes it may make sense".
I think that the only one and a half sensible use cases that
unconditionally make sense to update symrefs across repositories are
to update bare.git/HEAD symref:
- update bare.git/HEAD of a repository that is a local mirror of a
more authoritative repository with "git fetch --mirror", in which
case you do want to follow what branch is designated as the
primary by the project you are mirroring from;
- update bare.git/HEAD from outside by some means to change which
branch is the primary one for the project. Only because your
hosting site does not give you an easy way to do so, pushing from
another repository that happens to point its HEAD at a different
branch seems to be one plausible way to do so, but that does not
have to be the only way.
[Footnote]
*1* We would need to update the network protocol for this purpose,
as most transports do not carry this information and clone has to
guess which branch bare.git/HEAD points at.
The purpose of this message, though, is to illustrate that the
protocol update to carry the information is not the end of the
story, but merely is an enabling beginning. We need to know what
semantics we would want to implement on top of that transfer.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pushing symbolic references to remote repositories?
2012-12-21 23:11 ` Junio C Hamano
@ 2012-12-22 9:26 ` Andreas Schwab
2012-12-22 18:27 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2012-12-22 9:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Dun Peal, Shawn Pearce, Git ML
Junio C Hamano <gitster@pobox.com> writes:
> I think that the only one and a half sensible use cases that
> unconditionally make sense to update symrefs across repositories are
> to update bare.git/HEAD symref:
>
> - update bare.git/HEAD of a repository that is a local mirror of a
> more authoritative repository with "git fetch --mirror", in which
> case you do want to follow what branch is designated as the
> primary by the project you are mirroring from;
>
> - update bare.git/HEAD from outside by some means to change which
> branch is the primary one for the project. Only because your
> hosting site does not give you an easy way to do so, pushing from
> another repository that happens to point its HEAD at a different
> branch seems to be one plausible way to do so, but that does not
> have to be the only way.
This is not limited to HEAD, any ref may want to be set up as a symref
at a remote repo. For example, I want to set up a symref master ->
trunk at a repository I have no shell access to. Without this I get
spurious error whenever I fetch from that remote (where master and trunk
are separate refs) into a local mirror which does have the symref:
>From git://repo.or.cz/emacs
f0ae89f..5595931 master -> master
error: Ref refs/heads/trunk is at 559593152b9de5a1c144729e0583fa7968abab22 but expected f0ae89f92326beb3f5a19e90c8f4fe0ab6197926
! f0ae89f..5595931 trunk -> trunk (unable to update local ref)
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pushing symbolic references to remote repositories?
2012-12-22 9:26 ` Andreas Schwab
@ 2012-12-22 18:27 ` Junio C Hamano
2012-12-23 1:10 ` Sitaram Chamarty
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2012-12-22 18:27 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Dun Peal, Shawn Pearce, Git ML
Andreas Schwab <schwab@linux-m68k.org> writes:
> This is not limited to HEAD, any ref may want to be set up as a symref
> at a remote repo. For example, I want to set up a symref master ->
> trunk at a repository I have no shell access to.
That is exactly the "hosting side does not give you an easy way so
pushing seems to be one plausible but not necessarily has to be the
only way" case, so it is already covered in the discussion.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pushing symbolic references to remote repositories?
2012-12-22 18:27 ` Junio C Hamano
@ 2012-12-23 1:10 ` Sitaram Chamarty
0 siblings, 0 replies; 6+ messages in thread
From: Sitaram Chamarty @ 2012-12-23 1:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andreas Schwab, Dun Peal, Shawn Pearce, Git ML
On Sat, Dec 22, 2012 at 11:57 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> This is not limited to HEAD, any ref may want to be set up as a symref
>> at a remote repo. For example, I want to set up a symref master ->
>> trunk at a repository I have no shell access to.
>
> That is exactly the "hosting side does not give you an easy way so
> pushing seems to be one plausible but not necessarily has to be the
> only way" case, so it is already covered in the discussion.
Just a minor FYI (and at the risk of tooting my own horn) but if the
hosting side is gitolite, you can.set it up so that any user with
write permissions to the repo can run 'git symbolic-ref' with
arbitrary arguments even though he does not get a shell.
The "-m <reason>" has some constraints because gitolite does not allow
a lot of characters in arguments to remote commands but that's mostly
useless unless you have core.logAllRefUpdates set anyway.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-23 1:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-21 19:53 Pushing symbolic references to remote repositories? Dun Peal
2012-12-21 21:54 ` Shawn Pearce
2012-12-21 23:11 ` Junio C Hamano
2012-12-22 9:26 ` Andreas Schwab
2012-12-22 18:27 ` Junio C Hamano
2012-12-23 1:10 ` Sitaram Chamarty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).