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=-3.8 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 386F31F66F for ; Tue, 10 Nov 2020 21:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731955AbgKJVfp (ORCPT ); Tue, 10 Nov 2020 16:35:45 -0500 Received: from cloud.peff.net ([104.130.231.41]:53540 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726467AbgKJVfp (ORCPT ); Tue, 10 Nov 2020 16:35:45 -0500 Received: (qmail 9472 invoked by uid 109); 10 Nov 2020 21:35:45 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 10 Nov 2020 21:35:45 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 6047 invoked by uid 111); 10 Nov 2020 21:35:44 -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; Tue, 10 Nov 2020 16:35:44 -0500 Authentication-Results: peff.net; auth=none Date: Tue, 10 Nov 2020 16:35:44 -0500 From: Jeff King To: Junio C Hamano Cc: "Demi M. Obenour" , Git Subject: Re: check_refname_format allows refs with components that begin with -, even though `git tag` does not Message-ID: <20201110213544.GA3263091@coredump.intra.peff.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, Nov 10, 2020 at 12:09:55PM -0800, Junio C Hamano wrote: > > The best idea I had for a fix is to print names beginning with `-` > > using the fully-qualified form, such as "refs/tags/-a". Also, `--` > > is used as a delimiter in many commands, and can’t be escaped, > > so disallowing it might be a good idea. > > I do not think there is anything to fix. > > Command line parsers of some commands may have to learn how to > disambiguate such a strangely named tags and branches, though. Some > commands do not know --end-of-options convention, for example. I think there is at least one thing to fix: rev-parse never learned about --end-of-options. It also seems to have some weirdness around "--". Here's a series which fixes it. [1/3]: rev-parse: don't accept options after dashdash [2/3]: rev-parse: put all options under the "-" check [3/3]: rev-parse: handle --end-of-options Documentation/git-rev-parse.txt | 8 ++- builtin/rev-parse.c | 100 ++++++++++++++++++-------------- t/t1503-rev-parse-verify.sh | 13 +++++ t/t1506-rev-parse-diagnosis.sh | 25 ++++++++ 4 files changed, 99 insertions(+), 47 deletions(-) -Peff