From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id A074A1F5AE for ; Mon, 3 Aug 2020 20:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbgHCUpE (ORCPT ); Mon, 3 Aug 2020 16:45:04 -0400 Received: from cloud.peff.net ([104.130.231.41]:46812 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbgHCUpE (ORCPT ); Mon, 3 Aug 2020 16:45:04 -0400 Received: (qmail 29296 invoked by uid 109); 3 Aug 2020 20:45:04 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Mon, 03 Aug 2020 20:45:04 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 4430 invoked by uid 111); 3 Aug 2020 20:45:03 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Mon, 03 Aug 2020 16:45:03 -0400 Authentication-Results: peff.net; auth=none Date: Mon, 3 Aug 2020 16:45:03 -0400 From: Jeff King To: Taylor Blau Cc: Matt McCutchen , git@vger.kernel.org Subject: Re: Renaming the "master" branch without breaking existing clones Message-ID: <20200803204503.GB2715275@coredump.intra.peff.net> References: <20200803160051.GA50799@syl.lan> <20200803194006.GA2715275@coredump.intra.peff.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200803194006.GA2715275@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Aug 03, 2020 at 03:40:06PM -0400, Jeff King wrote: > On Mon, Aug 03, 2020 at 12:00:51PM -0400, Taylor Blau wrote: > > > This is more-or-less what I was proposing in the message that I linked > > above. Maybe a more solidified proposal might look something as follows: > > > > - We could introduce a mechanism to mark certain refs as aliases to > > other refs. For example, a remote might publish its > > 'refs/heads/master' as an alias to 'refs/heads/main', so that any > > reads or writes to the former get applied to the latter > > transparently. > > I think symrefs do this already. Try this: Looks like Junio already mentioned symrefs. I guess I should have read the whole thread. :) As he noted, they don't work if you want to free up the original name. But I think in the master/main renaming case that most people wouldn't care that much about doing so. > > - A ref alias can be annotated to say "I am a transition ref alias", > > i.e., that clients should be taught to rename their copy of 'master' > > to 'main' (and update remote-tracking refs accordingly). > > It's not specifically marked as a transition, but a client could act on > the symref advertisement above. Something like this script could be run on the clients: remote=origin git ls-remote --symref $remote | grep ^ref: | while read junk to from; do if test "$from" = HEAD; then old=$(git symbolic-ref refs/remotes/$remote/HEAD) echo "Upstream switched their HEAD:" echo " old: $old" echo " new: $to" echo "Update to match?" read r /dev/null 2>&1 || continue echo "Upstream is redirecting a branch:" echo " branch: $from" echo " points to: $to" echo "And you have a local $from; should we rename it?" read r