From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78FC242A96 for ; Wed, 19 Aug 2026 20:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787170947; cv=none; b=H80MOXELxtDSxXesb27ry3pbQqatRZ5Q/2v5vNCEGLBK8tXH22bfA8RjGApLB86FrqwZ1AfKWUn2RAB1BhZ2Xc9vnxhegjvKMusOqOWMQAs0xSOSbmrW0SHRrGMowial66phadABpdgmPGTlIkvKD+vL4p4Z8NTST7XWk/KC/hw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787170947; c=relaxed/simple; bh=/B5WZ2IPoxXCjy0xKaVc8urVYLLSfivY1LZ8rwgtqos=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=n8Pm/CsKKj4cR9zVkB+IshYoTSoHziz9j079Yz+/Ujo8d9Uap/+AE69DK0HvelZfUnr0qso6Lo0uBOj55BgKgtdbaIHxyh72J4fUtExMTiRzDNzjXqTVXKSi5z9a9IucwvHIXgZfO2aKLq4LMYafAI4Alvlktn+zc//Ku1sAzbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=Y5AVhb0F; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YeIGX+Km; arc=none smtp.client-ip=202.12.124.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="Y5AVhb0F"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YeIGX+Km" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 9CF061D00176; Wed, 19 Aug 2026 16:22:25 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-05.internal (MEProxy); Wed, 19 Aug 2026 16:22:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1787170945; x=1787257345; bh=5dxWyiQB/F OejNgkFtr1MDzjL6uw67kPC59ai6HhCtk=; b=Y5AVhb0FFbYFTEbsUFvqGedsh2 RLF4DZC1MgamdsiZtQy8Wl67q2hfjVlM/3sB6x9Ox+HShzFibm+mH2wNa9kavu+e RpkwerAZplekUR05QpE9haC+Z9y+THvGHNGGNn/9poqg7NsGtJ6HiAsZi4S3ty82 YeaObQNW9389i3PRQHzjaeks4vOTn7VWzj0yFH3THckSL6usuKA60q/QjTwv7um5 6b0sEIxvNAkYhmq7AB44KN8ADkSyvLMYJgwpJrRyZW/Y3xXKNhOYgFBl9b5WebNj vC5WLQU2XmJWvMdsCqcQ5+8ISUNE0jj/j0KpUxeqTspKpLlWikl+NcGjtvWQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1787170945; x=1787257345; bh=5dxWyiQB/FOejNgkFtr1MDzjL6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XG4PW7hLHCM+tAFZmQ X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 19 Aug 2026 16:22:24 -0400 (EDT) From: Junio C Hamano To: Patrick Steinhardt Cc: Nikolaus Schuetz via GitGitGadget , git@vger.kernel.org, Nikolaus Schuetz Subject: Re: [PATCH] t1402: test forbidden characters in refnames In-Reply-To: (Patrick Steinhardt's message of "Wed, 19 Aug 2026 13:20:06 +0200") References: Date: Wed, 19 Aug 2026 13:22:23 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Patrick Steinhardt writes: > On Thu, Aug 13, 2026 at 08:43:56PM +0000, Nikolaus Schuetz via GitGitGadget wrote: >> From: Nikolaus Schuetz >> >> git-check-ref-format(1) documents that a refname cannot contain a >> space, tilde, caret, colon, question-mark, asterisk or open-bracket, >> and that it cannot be the single character "@". Of these, only "?" >> was tested as a character embedded in an otherwise-valid refname; >> "*" was checked only as a lone character or with --refspec-pattern. >> >> Add the remaining forbidden characters in that embedded form, and >> check that "@" alone is rejected even with --allow-onelevel -- where >> "@" is otherwise a valid refname component, as "refs/@" confirms. > > Okay. > >> diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh >> index cabc516ae9..bc1e878a0f 100755 >> --- a/t/t1402-check-ref-format.sh >> +++ b/t/t1402-check-ref-format.sh >> @@ -51,12 +51,20 @@ invalid_ref '.refs/foo' >> invalid_ref 'refs/heads/foo.' >> invalid_ref 'heads/foo..bar' >> invalid_ref 'heads/foo?bar' >> +invalid_ref 'heads/foo~bar' >> +invalid_ref 'heads/foo^bar' >> +invalid_ref 'heads/foo:bar' >> +invalid_ref 'heads/foo*bar' >> +invalid_ref 'heads/foo[bar' >> +invalid_ref 'heads/foo bar' > > This feels a tiny bit excessive, but I guess it does not hurt to enforce > this property, especially now that it's so easy to add new backends. "Why would we even care to check these insane cases?" was my first reaction, but I agree with you that these are to protect authors of new backends from stupid mistakes. > One thing I was briefly wondering is whether we could maybe have a > simple loop here, as this feels quite repetitive. We could for example: > > for c in '?' '~' '^' ':' '*' '[' ' ' > do > invalid_ref "heads/foo${c}bar" > done True. And c does not have to be a single byte. ".." can also be part of the repertoire. > By the way, one weird bit: is it intentional that all of these really > use "heads/something" instead of "refs/heads/something"? I guess it > ultimately doesn't matter. > >> valid_ref 'foo./bar' >> invalid_ref 'heads/foo.lock' >> invalid_ref 'heads///foo.lock' >> invalid_ref 'foo.lock/bar' >> invalid_ref 'foo.lock///bar' >> valid_ref 'heads/foo@bar' >> +valid_ref 'refs/@' >> +invalid_ref '@' --allow-onelevel > > This one certainly is a good addition, as these are quite a bit more > subtle. > > Thanks! > > Patrick