From patchwork Mon Jun 3 09:30:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13683410 Received: from wfhigh7-smtp.messagingengine.com (wfhigh7-smtp.messagingengine.com [64.147.123.158]) (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 698601292D3 for ; Mon, 3 Jun 2024 09:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407037; cv=none; b=LGwiW+BrqjjXouUUp79PxQCoKZbO5Y48DFIDNLcnR6gtYOm2LW0uEz0ukL64DzPkcl3NuBtvGf/rOefkO6rcshBrreKN+ADx5Pkc6Pqrzeuy2tCuLBL7t/nR6kcpuxUdzWoB/QaYJJsbW1+ykg20NisMpt1nRQZHvo/UyCzTIs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407037; c=relaxed/simple; bh=xPdg47XABQd9W8LiQCuzjVJCOQmaYUntOXOU4YvYGNg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uOuv8B7GjxloSPE1oQiEa8bnDcBt7v4FXRV7qpOP8UNrR6XkE5jL3mJp8bqA8syGsczvpeoJOiKjKsioxlMkXvGArtEPxk+rRaJ0ND3xMRACgz4b6Vj0F9LcgvqHlest95a+EFsN9oDMUoI+zM+U9au8aSQ2sADJRhsjefYlahk= 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=Ro+ALmGP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hMXvtw0h; arc=none smtp.client-ip=64.147.123.158 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="Ro+ALmGP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hMXvtw0h" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id 798031800107; Mon, 3 Jun 2024 05:30:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 03 Jun 2024 05:30:34 -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=fm1; t=1717407034; x=1717493434; bh=hj+LpBOrQP dhbdOzakeTiy0VVSU33NIpJ1Yc/TmS8sQ=; b=Ro+ALmGPUiqIvo+J15LuWCqIax 08TY72SluCr5HlhsJ31840vavjJ9wC6dlKocbAv6F0b5BCxQF6qB6uJjxcgzLXEE /Hrfc+OWVRF9N+Wn2+u6li/PgsxPtlTqMe2Tj8R+m9b+vWLMA6w0pZao3lCM5vKU EYeCxDJgXBOVo+BFFrJy1xeiSMyq0gJchCwhClZld5Han11WuHWlhkUGrI9w29s4 HRioDFT/AHHVo+I7H4oGp6AWDeRu9iCfaJp800LEa73/vafOqhpo5wfudAX8jvhC I726TQlMdT1yj3HIwNyBJmOqQS2/ebhxEFaDcTiL0NQq+qL1KZdzw/ogwPKg== 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= fm1; t=1717407034; x=1717493434; bh=hj+LpBOrQPdhbdOzakeTiy0VVSU3 3NIpJ1Yc/TmS8sQ=; b=hMXvtw0hxRDk69G3SnUzJXc04tiwt2Mwgh0TkNy3+Uqp 5M67k3HZ87wLZumE349oion99K3e+UAr8KN8HoGk3DiyXf7G/I16Wwnpqu/3CHjB B3IOAxE/apQzE+kR8PCEOPEolVZTSN2FEn4Am22NXIpWtJGzViRKOp+lFY/wUQlK WR0G6az1s6vH5fR0fjZRN0zP73naFEkhL0yDfIrKqdQ7ffYzgUMv0xgoeM9lIz7U pTcDmEFHYgmb0J65DkKYKNNYXOcWsVJyfdwN+XIADmUbdmrJdlI/JB6538rrNH9P 21D6gQTTPMYl10E0E85iMWteN8TdxGSAQVTVxDfw/Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jun 2024 05:30:32 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id fe2d3231 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Jun 2024 09:30:08 +0000 (UTC) Date: Mon, 3 Jun 2024 11:30:30 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Eric Sunshine , Junio C Hamano , Ramsay Jones , Justin Tobler Subject: [PATCH v4 05/12] refs/files: refactor `add_pseudoref_and_head_entries()` Message-ID: <7f9ce5af2eb316477160224aa087ba6290cad672.1717402363.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: The `add_pseudoref_and_head_entries()` function accepts both the ref store as well as a directory name as input. This is unnecessary though as the ref store already uniquely identifies the root directory of the ref store anyway. Furthermore, the function is misnamed now that we have clarified the meaning of pseudorefs as it doesn't add pseudorefs, but root refs. Rename it accordingly. Signed-off-by: Patrick Steinhardt --- refs/files-backend.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index bd0d63bcba..b4e5437ffe 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -324,16 +324,14 @@ static void loose_fill_ref_dir(struct ref_store *ref_store, } /* - * Add pseudorefs to the ref dir by parsing the directory for any files - * which follow the pseudoref syntax. + * Add root refs to the ref dir by parsing the directory for any files which + * follow the root ref syntax. */ -static void add_pseudoref_and_head_entries(struct ref_store *ref_store, - struct ref_dir *dir, - const char *dirname) +static void add_root_refs(struct files_ref_store *refs, + struct ref_dir *dir) { - struct files_ref_store *refs = - files_downcast(ref_store, REF_STORE_READ, "fill_ref_dir"); struct strbuf path = STRBUF_INIT, refname = STRBUF_INIT; + const char *dirname = refs->loose->root->name; struct dirent *de; size_t dirnamelen; DIR *d; @@ -388,8 +386,7 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs, dir = get_ref_dir(refs->loose->root); if (flags & DO_FOR_EACH_INCLUDE_ROOT_REFS) - add_pseudoref_and_head_entries(dir->cache->ref_store, dir, - refs->loose->root->name); + add_root_refs(refs, dir); /* * Add an incomplete entry for "refs/" (to be filled