git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Jan Krüger" <jk@jk.gs>
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	Git ML <git@vger.kernel.org>,
	obrien654j@gmail.com
Subject: Re: Deleting the "current" branch in remote bare repositories
Date: Sun, 8 Feb 2009 03:44:53 -0500	[thread overview]
Message-ID: <20090208084453.GA4392@coredump.intra.peff.net> (raw)
In-Reply-To: <20090208011802.2b7b9e74@perceptron>

On Sun, Feb 08, 2009 at 01:18:02AM +0100, Jan Krüger wrote:

> Okay, somehow I missed that. To reiterate the things from that
> discussion that I think are most reasonable:
> 
> 1) a local broken symref should generally be ignored unless we actually
>    need the symref.

I think this is almost as easy as:

diff --git a/refs.c b/refs.c
index 024211d..9601101 100644
--- a/refs.c
+++ b/refs.c
@@ -276,7 +276,6 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
 				continue;
 			}
 			if (!resolve_ref(ref, sha1, 1, &flag)) {
-				error("%s points nowhere!", ref);
 				continue;
 			}
 			list = add_ref(ref, sha1, flag, list, NULL);

Since this is just called when enumerating all of the loose refs (via
get_loose_refs(), which is generally called from for_each_ref).

However, there is one other complication. rename_ref uses get_loose_refs
to check whether the destination space is available:

  if (!is_refname_available(newref, oldref, get_loose_refs(), 0))
        return 1;

so you can get funny behavior through:

  git branch -m foo bar

when "bar" is a symref pointing to a non-existent ref. Of course, we are
not _changing_ that behavior, since we always just ignored that symref.
But we are removing the warning message that might clue the user that
something confusing is about to happen.

> 2) there should be a more convenient (porcelain) way to change a
>    refs/remotes/foo/HEAD symref, e.g. git remote set-default, possibly
>    with an option to re-sync from the remote head (we could even make
>    that an option for git remote update).

Yes, I think that is a good idea (optionally with a switch to just
re-grab the information from the remote).

> Regarding 2): if we managed to add an option to that to change the
> remote HEAD, we could disallow deleting a remote branch that HEAD
> points to, and refer to this command. I think the problem is that we
> would have to add symref updating logic for all types of remote
> protocols.

Yes, the protocol support would make this a much bigger patch (and you
would have to handle the case where the remote side didn't support it).
But bear in mind that deleting the remote HEAD breaks things not just
for you, but for other people who are cloning that remote. Maybe we
should refuse such updates unless "-f" is given (similar to
non-fast-forward updates); I haven't looked to see if we even have the
remote's HEAD information during push, though.

> If people agree with these ideas I think I'll write up a couple of
> patches to implement these changes. So, any protests?

I say go for it.

-Peff

  reply	other threads:[~2009-02-08  8:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-07 15:27 Deleting the "current" branch in remote bare repositories Jan Krüger
2009-02-07 22:05 ` Felipe Contreras
2009-02-08  0:18   ` Jan Krüger
2009-02-08  8:44     ` Jeff King [this message]
2009-02-08  9:42     ` Junio C Hamano
2009-02-08 11:18       ` Jeff King
2009-02-08 19:05         ` Junio C Hamano
2009-02-09  9:09           ` [PATCH 0/6] Deleting the "current" branch in a remote repository Junio C Hamano
2009-02-09  9:09             ` [PATCH 1/6] builtin-receive-pack.c: do not initialize statics to 0 Junio C Hamano
2009-02-09  9:09               ` [PATCH 2/6] t5400: allow individual tests to fail Junio C Hamano
2009-02-09  9:09                 ` [PATCH 3/6] receive-pack: receive.denyDeleteCurrent Junio C Hamano
2009-02-09  9:09                   ` [PATCH 4/6] remote prune: warn dangling symrefs Junio C Hamano
2009-02-09  9:09                     ` [PATCH 5/6] Warn use of "origin" when remotes/origin/HEAD is dangling Junio C Hamano
2009-02-09  9:09                       ` [PATCH 6/6] receive-pack: default receive.denyDeleteCurrent to refuse Junio C Hamano
2009-02-09 19:15                     ` [PATCH 4/6] remote prune: warn dangling symrefs Jeff King
2009-02-11 17:30                       ` Junio C Hamano
2009-02-11 18:35                         ` Jeff King
2009-02-11 18:42                           ` Jeff King
2009-02-09 18:53                   ` [PATCH 3/6] receive-pack: receive.denyDeleteCurrent Jeff King
2009-02-09 19:22                     ` Jeff King
2009-02-09 21:38                       ` Junio C Hamano
2009-02-10 12:07                         ` Jeff King
2009-02-10 15:15                           ` Junio C Hamano
2009-02-09 18:46                 ` [PATCH 2/6] t5400: allow individual tests to fail Jeff King
2009-02-09 19:08                   ` Junio C Hamano
2009-02-09 21:39                     ` Junio C Hamano
2009-02-10 12:01                       ` Jeff King
2009-02-09 18:28           ` Deleting the "current" branch in remote bare repositories Jeff King
2009-02-09 18:36             ` Jeff King

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=20090208084453.GA4392@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jk@jk.gs \
    --cc=obrien654j@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).