From: Jeff King <peff@peff.net>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>, git@vger.kernel.org
Subject: Re: Deleting remote branch pointed by remote HEAD
Date: Wed, 21 Jan 2009 11:19:40 -0500 [thread overview]
Message-ID: <20090121161940.GA20702@coredump.intra.peff.net> (raw)
In-Reply-To: <49773E48.90302@drmicha.warpmail.net>
On Wed, Jan 21, 2009 at 04:24:56PM +0100, Michael J Gruber wrote:
> So, you get these errors on the local repo when dealing with the remote
> repo, right? I guess this means two things:
>
> 1) You are deleting a remote branch
Actually, he doesn't have to delete the remote branch; somebody else
can. The problem is that the HEAD pointer for his remote tracking
branches points to a branch that doesn't exist. This can happen because
we sometimes update the tracking branches (including deletion) without
impacting the HEAD pointer.
There are two ways that I can think of (and there may be more) to
provoke this:
1. delete a remote branch via push. The local side will helpfully
delete your local tracking branch to match what happened on the
remote. If it was the remote's HEAD, then you get a broken state
(and while we discourage pushing to the remote HEAD on a non-bare
repo, it is perfectly OK for a bare one).
2. somebody else deletes the remote branch that is the HEAD, and you
update your tracking branches via "git remote prune", which deletes
your tracking branches corresponding to any deleted remote branches.
And actually there is a slight variant on both of the above. The deleted
branch does not actually have to be the current HEAD on the remote. It
just has to match your _idea_ of the current HEAD on the remote, which
may be out of date.
Situation (1) happens entirely locally. So it can be fixed fairly easily
by checking whether the remote tracking HEAD points to a branch we are
deleting, and deleting the HEAD in that case (the code should be in
builtin-send-pack.c:update_tracking_ref). Of course you have probably
also created a broken situation on the remote, so perhaps receive-pack
should handle that.
Situation (2) could do something similar: when we see that we are about
to delete the ref pointed to by the remote tracking HEAD, we could
delete the HEAD.
But both situations are a little hack-ish to me. You are deleting the
HEAD because you don't know what the right value is from the remote end.
A better fix would be to actually pull the HEAD information down during
fetch. And I seem to recall a patch about that at some point (it
required a new protocol extension), but I don't know what become of it.
However, even if we kept the tracking HEAD totally in sync with the
remote's HEAD, it still may be possible that the remote HEAD is broken.
In which case it might be nice to detect that when pulling it down and
just leave the tracking HEAD unset.
-Peff
next prev parent reply other threads:[~2009-01-21 16:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-21 13:02 Deleting remote branch pointed by remote HEAD Marc-André Lureau
2009-01-21 14:33 ` Michael J Gruber
2009-01-21 14:38 ` Marc-André Lureau
2009-01-21 15:24 ` Michael J Gruber
2009-01-21 15:41 ` Marc-André Lureau
2009-01-21 16:19 ` Jeff King [this message]
2009-01-21 18:30 ` Daniel Barkalow
2009-01-21 19:09 ` Boyd Stephen Smith Jr.
2009-01-21 19:12 ` Jeff King
2009-01-21 19:14 ` Jeff King
2009-01-21 19:50 ` Daniel Barkalow
2009-01-21 19:53 ` Jeff King
2009-03-12 9:02 ` Felipe Contreras
2009-03-12 11:39 ` Jeff King
2009-03-12 12:47 ` Felipe Contreras
2009-03-12 12:50 ` Jeff King
2009-01-21 20:42 ` Junio C Hamano
2009-01-21 18:31 ` Felipe Contreras
2009-01-21 19:16 ` Jeff King
2009-01-21 19:20 ` Felipe Contreras
2009-01-21 14:41 ` Adeodato Simó
2009-01-21 14:52 ` Sitaram Chamarty
2009-01-21 22:56 ` GUI and detatched HEAD (was Re: Deleting remote branch pointed by remote HEAD) Daniel Barkalow
2009-01-22 14:20 ` Sitaram Chamarty
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090121161940.GA20702@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=marcandre.lureau@gmail.com \
/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.
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).