From patchwork Fri May 10 08:48:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13661062 Received: from wfout6-smtp.messagingengine.com (wfout6-smtp.messagingengine.com [64.147.123.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 2FC888BE8 for ; Fri, 10 May 2024 08:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715330938; cv=none; b=jZYfeWgnRWWiPWNlqQZkEQgmiMJHkbNoEsmbRSKUxvarIPdMW9oaitoH4hXnqhbtrkVWGQtNF/qna9sDKvD6YejovoRKkUaATPP0ahc5rud6MirJHY5aMzdGH7w5bc10AvgM5GjqDuT0fqRQeN2AfFhE1jVrRskUdofA7ny2kiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715330938; c=relaxed/simple; bh=O+h3lDmgTU2pdHkz0t/J+aJRbmfIHbMINiYGjfozrIY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OXI1NAJf7/za67uBDnq5GZH/GQE72kq06u2g6QKbvwrnIaswmek9bKVH8+xwfX8MBXtb2et9gkMXDkz6OCbV9EkUR7DN9HQ6p74AfqZ1jczhzm8XB7Dj8CpSzuqVqp3NywmbdfmHWV7t3H+L/+pp0KpHIn5410xIX8eBwcvdH+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=mMNaPhYa; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cfuK2p19; arc=none smtp.client-ip=64.147.123.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="mMNaPhYa"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cfuK2p19" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id E60641C000F3; Fri, 10 May 2024 04:48:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 10 May 2024 04:48:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; 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=fm3; t=1715330935; x=1715417335; bh=SeomFHX+9n iIhonAM4APdY+geeUveyCLqfU682b2QRg=; b=mMNaPhYaESM1uIANzUmeo67US3 CiMwBQMXDk9dKbWIQs05WSLzwV5BhW72AWXQZsCi9pxZaW/Wm+deMMRZuQ5PeFX8 sRTEcAd7d1k6Q9bANfQL8cmP7OWhEOAVHXFjF+Emnlpv/ZhqhGGwFQSgbMIERdKW giPBdQkcHm+FP0HhP9YxiaZf6FciguqOK3eDRhpL04lXx0mzcoTx2S02p5tDd0vr j5O11nEFIjIcnC/z3RPuJbR6G5WkvxT+2oDT98GtsY+0atX4Ouijv6InQZW4G0PN OpycNd0t11nEUeQlQV6NNLbMU+DGe2rzQIf3D5xwl8CCEon74wkPZ9ZJjFgA== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715330935; x=1715417335; bh=SeomFHX+9niIhonAM4APdY+geeUv eyCLqfU682b2QRg=; b=cfuK2p190sX85wC3oUasTNTb5KYqb5hf6C5ZQAmoNtYg x/hpR6lXcbgVHi1KMmKqItWrVC+CyTzkfc9+Pkg5oRgCbc/fZvlUSNiZoK1Ura7k 7k/G2FCv5JCEsJ1tCOxTHQVXZWu+fkR7JeP1kX0gmwucIRfo9WPyCWMcE4bXw2R/ +eLgAuJ5ptbNae/F5+o4gKTn81cB+rPW16wYIL4fAfyAn+JiMAcgNypmrq2UUVwe 1+dRZe/9Lw3s4QlZqkTbaJwnrzGYwJr1xBOJ7AUUx/KFBVyZYdIi0dJJreiPx02a zPH+2bOiyDAy0+Nb1cfyZKx2lt7IEhwmOJPJGI6IsA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdefkedgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 May 2024 04:48:53 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 78c28c2a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 10 May 2024 08:48:40 +0000 (UTC) Date: Fri, 10 May 2024 10:48:51 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Karthik Nayak , Phillip Wood , Junio C Hamano , Justin Tobler , Kristoffer Haugsbakk , =?iso-8859-1?q?Jean-No=EBl?= AVILA Subject: [PATCH v4 10/10] refs: refuse to write pseudorefs Message-ID: <640d3b169fc6abaaf121b90f43f5f4c4145ec08d.1715330206.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Pseudorefs are not stored in the ref database as by definition, they carry additional metadata that essentially makes them not a ref. As such, writing pseudorefs via the ref backend does not make any sense whatsoever as the ref backend wouldn't know how exactly to store the data. Restrict writing pseudorefs via the ref backend. Signed-off-by: Patrick Steinhardt --- refs.c | 7 +++++++ t/t5510-fetch.sh | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index c882ece6e7..f2507c5a74 100644 --- a/refs.c +++ b/refs.c @@ -1285,6 +1285,13 @@ int ref_transaction_update(struct ref_transaction *transaction, return -1; } + if (!(flags & REF_SKIP_REFNAME_VERIFICATION) && + is_pseudo_ref(refname)) { + strbuf_addf(err, _("refusing to update pseudoref '%s'"), + refname); + return -1; + } + if (flags & ~REF_TRANSACTION_UPDATE_ALLOWED_FLAGS) BUG("illegal flags 0x%x passed to ref_transaction_update()", flags); diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 33d34d5ae9..4eb569f4df 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -518,7 +518,7 @@ test_expect_success 'fetch with a non-applying branch..merge' ' test_expect_success 'fetch from GIT URL with a non-applying branch..merge [1]' ' one_head=$(cd one && git rev-parse HEAD) && this_head=$(git rev-parse HEAD) && - git update-ref -d FETCH_HEAD && + rm .git/FETCH_HEAD && git fetch one && test $one_head = "$(git rev-parse --verify FETCH_HEAD)" && test $this_head = "$(git rev-parse --verify HEAD)" @@ -530,7 +530,7 @@ test_expect_success 'fetch from GIT URL with a non-applying branch..merge one_ref=$(cd one && git symbolic-ref HEAD) && git config branch.main.remote blub && git config branch.main.merge "$one_ref" && - git update-ref -d FETCH_HEAD && + rm .git/FETCH_HEAD && git fetch one && test $one_head = "$(git rev-parse --verify FETCH_HEAD)" && test $this_head = "$(git rev-parse --verify HEAD)" @@ -540,7 +540,7 @@ test_expect_success 'fetch from GIT URL with a non-applying branch..merge # the merge spec does not match the branch the remote HEAD points to test_expect_success 'fetch from GIT URL with a non-applying branch..merge [3]' ' git config branch.main.merge "${one_ref}_not" && - git update-ref -d FETCH_HEAD && + rm .git/FETCH_HEAD && git fetch one && test $one_head = "$(git rev-parse --verify FETCH_HEAD)" && test $this_head = "$(git rev-parse --verify HEAD)"