From patchwork Mon Apr 29 13:41:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13646999 Received: from wfout5-smtp.messagingengine.com (wfout5-smtp.messagingengine.com [64.147.123.148]) (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 07BA36F510 for ; Mon, 29 Apr 2024 13:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714398091; cv=none; b=XwFh8ohp1CzUIPwWtqD15+X/00sqkZlTxFBM72FzI6mb/TxBjcnHXST5hid2eKN+Ag9zVCR7cngIolTCK9CIHN16aO+FFhCBMddufLZKvaTv6J+4eXmobLJXxBYGw9ROZ6eqF1EnSA5ae+w8eU0DQR/5lpCqO+HuHE9/y4syR7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714398091; c=relaxed/simple; bh=3Ue7uzpbD2fi4x6v6hFbQ7KFVdxF2INBF6aJBay53O8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qLi+OR4cqE0MbCzoyDFYiCn2UVR+UIKMmOyDMfKVO1Ibn09ttkTaFfoLYSLMWdlhppcCMrWyRFx3IrPfZJ/ren/6H2GTZUyHGt4uZyvbAs71bcLKVnpbAAn3JYLLnOgCBqRNzAqFnfjtLFIBKqmgsrkeAYG6DBLUwVjInOycFOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none 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=Pjg5FoBV; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hotQq0Qx; arc=none smtp.client-ip=64.147.123.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none 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="Pjg5FoBV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hotQq0Qx" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 17C851C00171; Mon, 29 Apr 2024 09:41:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 29 Apr 2024 09:41:28 -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=1714398087; x=1714484487; bh=l2EkZY1Ba7 3wexEf7sVNvbaEM1OJN20D8IfWn5NTRZg=; b=Pjg5FoBV4IQhwkqTjCThiARzBW MFZdMUdzVc9MeRfYcz/ACcYW3VHQ/qVjtF+PTDiKGkgYWORNCSLxvSTqVknzLgOe 8XLFKHw78ZMOxrgbuWHKvRVguM6h24IXDGG5rtkHMipinjgtQCQHtva4N78ZuNfx FuR0kMoY9U+1w7Awihf21CsjSKtA+DR9nk+4TROFLqE7uyBsaB/RRL+Jw5fPTE/y XKwQpWTRvMdMASlXOpZlxofZYfdbWylD0QA0lG17jQtbqksmNIboqyk3Syhwf6+F /A+6bvcTZL+6AgdYPeUcqY/dYMUqNFkJ7dgIhP2DlEUaWVEAW3xGWd+LtFqw== 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=1714398087; x=1714484487; bh=l2EkZY1Ba73wexEf7sVNvbaEM1OJ N20D8IfWn5NTRZg=; b=hotQq0QxowoWzBDWBQ4u8E5Uxl5fnoQkbaFGl3jNjO+m 4/YviLkuSv/I+Rq9X/vJYtcg0GO7fz11030FOcT34WbogmD87ejdOK3B0yjMmZSv OTP++buOBdKLdfZYJsFkveEa/ZjjVxIyUuOlS+ij5g5i+3i/yacmK4nP+ZLeLJPh QAJbW7KbJYU8SUI7ULq63HMWTCLNwFk+cAAGxRnEf8+7A76NqnXDdsi6Y/s4sUBJ Di44Pd+MzgHnuF5yjfyTlTAAPqqr1g0+LjhXBqWb4B5onl8YLUWuItluji8eVwee o04NWq3tQKeEdQqVNwvP8V8fCc6a+g72P5Np7pi/iQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdduuddgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Apr 2024 09:41:26 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id de24b269 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 29 Apr 2024 13:41:06 +0000 (UTC) Date: Mon, 29 Apr 2024 15:41:24 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Karthik Nayak Subject: [PATCH 1/3] refs: move `is_special_ref()` Message-ID: 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: Move `is_special_ref()` further up so that we can start using it in `is_pseudo_ref()`. Signed-off-by: Patrick Steinhardt --- refs.c | 62 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/refs.c b/refs.c index 55d2e0b2cb..c64f66bff9 100644 --- a/refs.c +++ b/refs.c @@ -844,6 +844,37 @@ int is_per_worktree_ref(const char *refname) starts_with(refname, "refs/rewritten/"); } +static int is_special_ref(const char *refname) +{ + /* + * Special references are refs that have different semantics compared + * to "normal" refs. These refs can thus not be stored in the ref + * backend, but must always be accessed via the filesystem. The + * following refs are special: + * + * - FETCH_HEAD may contain multiple object IDs, and each one of them + * carries additional metadata like where it came from. + * + * - MERGE_HEAD may contain multiple object IDs when merging multiple + * heads. + * + * Reading, writing or deleting references must consistently go either + * through the filesystem (special refs) or through the reference + * backend (normal ones). + */ + static const char * const special_refs[] = { + "FETCH_HEAD", + "MERGE_HEAD", + }; + size_t i; + + for (i = 0; i < ARRAY_SIZE(special_refs); i++) + if (!strcmp(refname, special_refs[i])) + return 1; + + return 0; +} + static int is_pseudoref_syntax(const char *refname) { const char *c; @@ -1876,37 +1907,6 @@ static int refs_read_special_head(struct ref_store *ref_store, return result; } -static int is_special_ref(const char *refname) -{ - /* - * Special references are refs that have different semantics compared - * to "normal" refs. These refs can thus not be stored in the ref - * backend, but must always be accessed via the filesystem. The - * following refs are special: - * - * - FETCH_HEAD may contain multiple object IDs, and each one of them - * carries additional metadata like where it came from. - * - * - MERGE_HEAD may contain multiple object IDs when merging multiple - * heads. - * - * Reading, writing or deleting references must consistently go either - * through the filesystem (special refs) or through the reference - * backend (normal ones). - */ - static const char * const special_refs[] = { - "FETCH_HEAD", - "MERGE_HEAD", - }; - size_t i; - - for (i = 0; i < ARRAY_SIZE(special_refs); i++) - if (!strcmp(refname, special_refs[i])) - return 1; - - return 0; -} - int refs_read_raw_ref(struct ref_store *ref_store, const char *refname, struct object_id *oid, struct strbuf *referent, unsigned int *type, int *failure_errno)