From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 9E52A20437 for ; Sat, 14 Oct 2017 02:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753364AbdJNCLD (ORCPT ); Fri, 13 Oct 2017 22:11:03 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:53467 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753240AbdJNCLC (ORCPT ); Fri, 13 Oct 2017 22:11:02 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 84B979DDAF; Fri, 13 Oct 2017 22:11:02 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=DCdAi4AENuXH4qbAQvLAYOmykDo=; b=A5sLB4 mKj/dj8vM8zsAGYoTOjGq/ZyMbp28jiaCaIvRMIhM2lv0EvAPPK6B54M4QXXwl2J Etndbw/+35+BsUHOntifz8e68NIIN9N+XkBv902Bt3MkbA0G3kbCeDyjvV97z2ej CmR/O7P4H0IvI+mbhf9UnSlKjbgSw6JWC8hos= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=YUkFRWv3vDhLHctVtlJrRp2u7eoWCMRo R9V/wS/0aLtzZzCc9eNi2O+UUwSQAQrpgsihXmjxTfpGqB/juIKm5ALjJrEpp//M anPIFxmx9Yq65jBTxCFztA8KyO359WhIuJweIMoWBkSZeiG7tz5jNK9OGxtDB1bV RD+3zb59FtA= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 7D6219DDAE; Fri, 13 Oct 2017 22:11:02 -0400 (EDT) Received: from pobox.com (unknown [104.132.0.95]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id EEA9A9DDAD; Fri, 13 Oct 2017 22:11:01 -0400 (EDT) From: Junio C Hamano To: Jeff King Cc: git@vger.kernel.org Subject: Re: [PATCH 3/3] branch: forbid refs/heads/HEAD References: <20171013051132.3973-1-gitster@pobox.com> <20171013051132.3973-4-gitster@pobox.com> <20171013131501.3qarwhanktfvgjqd@sigill.intra.peff.net> Date: Sat, 14 Oct 2017 11:11:00 +0900 In-Reply-To: <20171013131501.3qarwhanktfvgjqd@sigill.intra.peff.net> (Jeff King's message of "Fri, 13 Oct 2017 09:15:01 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: ED353EDA-B084-11E7-8951-575F0C78B957-77302942!pb-smtp2.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Jeff King writes: > On Fri, Oct 13, 2017 at 02:11:32PM +0900, Junio C Hamano wrote: > >> strbuf_check_branch_ref() is the central place where many codepaths >> see if a proposed name is suitable for the name of a branch. It was >> designed to allow us to get stricter than the check_refname_format() >> check used for refnames in general, and we already use it to reject >> a branch whose name begins with a '-'. >> >> Use it to also reject "HEAD" as a branch name. > > Heh, I just pointed somebody to this a day or two ago as #leftoverbit. I > guess it's taken now. :) Didn't notice /remember it; sorry about that. I can retract it if you want, but perhaps they cannot unsee it ;-) >> diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh >> index e88349c8a0..3ecb2eab0c 100755 >> --- a/t/t1430-bad-ref-name.sh >> +++ b/t/t1430-bad-ref-name.sh >> @@ -331,4 +331,12 @@ test_expect_success 'update-ref --stdin -z fails delete with bad ref name' ' >> grep "fatal: invalid ref format: ~a" err >> ' >> >> +test_expect_success 'branch rejects HEAD as a branch name' ' >> + test_must_fail git branch HEAD HEAD^ >> +' >> + >> +test_expect_success 'checkout -b rejects HEAD as a branch name' ' >> + test_must_fail git checkout -B HEAD HEAD^ >> +' > > Should we test that: > > git update-ref refs/heads/HEAD HEAD^ > > continues to work? Perhaps. Also we may want to make sure that "git branch -D HEAD" still works as a way to recover from historical mistakes.