From: Jeff King <peff@peff.net>
To: Christian Couder <christian.couder@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: Syncing HEAD
Date: Tue, 14 Aug 2018 17:06:16 -0400 [thread overview]
Message-ID: <20180814210616.GA32367@sigill.intra.peff.net> (raw)
In-Reply-To: <CAP8UFD0_jpKdcDvNx5CYnmyDMagE_O-E7cef5VthaT_w-=4xsA@mail.gmail.com>
On Tue, Aug 14, 2018 at 10:09:37PM +0200, Christian Couder wrote:
> When cloning with --mirror, the clone gets its HEAD initialized with
> the value HEAD has in its origin remote. After that if HEAD changes in
> origin there is no simple way to sync HEAD at the same time as the
> refs are synced.
>
> It looks like the simplest way to sync HEAD is:
>
> 1) git remote show origin
> 2) parse "HEAD branch: XXX" from the output of the above command
> 3) git symbolic-ref HEAD refs/heads/XXX
How about:
git remote set-head origin -a
?
> It looks like it would be quite easy to add an option to `fetch` to
> sync HEAD at the same time as regular refs are synced because every
> fetch from an origin that uses a recent Git contains something like:
I think the "remote set-head" option is not very discoverable, since
people are used to working with "fetch", making it the natural place to
look. Just like we ported "remote update" over to "fetch --all", I think
it would be sensible to have "fetch --update-head" or similar.
One tricky thing is that the name "refs/remotes/<remote>/HEAD" is only
special by convention, and that convention is known on the writing side
only by git-clone and git-remote. So obviously:
git fetch --update-head https://example.com/
is nonsense. We don't even have a ref. What should:
git config remote.origin.fetch refs/heads/*:refs/remotes/foo/*
git fetch --update-head origin
do? Should it update based no the remote name, or based on the refspec?
What happens if there are several refspecs? Etc.
99% of the time those questions won't come up. But we should design so
that we do the obvious thing in those 99%, and something sane in the
other 1%.
-Peff
next prev parent reply other threads:[~2018-08-14 21:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-14 20:09 Syncing HEAD Christian Couder
2018-08-14 20:58 ` Stefan Beller
2018-08-14 21:08 ` Brandon Williams
2018-08-14 21:06 ` Jeff King [this message]
2018-08-14 21:47 ` Jeff King
2018-08-15 5:49 ` Christian Couder
2018-08-17 1:47 ` Jeff King
2018-08-17 16:28 ` Junio C Hamano
2018-08-17 16:48 ` Jeff King
2018-08-14 22:05 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180814210616.GA32367@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).