From patchwork Wed Feb 23 12:35:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12756868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02193C433EF for ; Wed, 23 Feb 2022 12:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240450AbiBWMgG (ORCPT ); Wed, 23 Feb 2022 07:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239950AbiBWMgE (ORCPT ); Wed, 23 Feb 2022 07:36:04 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F2E08AE46 for ; Wed, 23 Feb 2022 04:35:33 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 9CC5E3201D6A for ; Wed, 23 Feb 2022 07:35:30 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 23 Feb 2022 07:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=5UB2CChNp/T2WLHWQQhQiMy1WWeNyh4EH/YSJ9 GAmDA=; b=FNPjHVCIa5Ufw0PW3ZoM16EIDfrcenJyOPP/yGURDoLAZO8Wjy7glp +CzfakPaL7IagQXUg3X8l84vV1f6PLqJgpgS4V185oYHdsGTbwxmOSA9ilojcxEm 6l9F8KhVNY2+r+zYaA9CoPji/NlyumCN3HkRtWuaOBRmthWVaZNyDmK1nCbjDAoi 56YV+uodixqVKppN5/dzy7EwpfJDhzaQ0GAPAwhbmox/BhwGA4t4iE46eInWJ8Pa xKv7JmGZKGOtLhJ7h2CeiiqfDW6BylsfG/Dy23pgEL9XkcqY7a3TsYLs5VpTs1uh 1SFXrExnyKU+4XdjJW+UhO1TmR+AwAlQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=5UB2CChNp/T2WLHWQ QhQiMy1WWeNyh4EH/YSJ9GAmDA=; b=HVy7UVVtkI9Yy0dZHk8xuA5NLmoLixcvJ NwC3kN4Cvlgp4Ddv6vO0b++W1HzKHBNsSY37xgbw+s5OtFhqe7UDfZgbbR8bSLpq 1vV4a/C9GpxMBVnbGiNCPF5KCdKt39CLpxJtm2VxHKgipemfaStEarQKYLlwfLJv F2oTnkWAlbo12tV2kMQjLOI11NEEXzj4lOIMXOzCVYheWkEd1rEXkOqI70ae3GNV rH6cYkQI4MJz8kUdPUNvDiAm0FVzeyCqu5+gF1n+KG9JsYROYdmGYGGgHO+jMZOw KiDQcUVwAPwYSwxQjkZb8eNtVYY+X2uZsCjiP4CBhmMwWcOgLjt0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrledtgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttdejnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgfejueevjeetudehgffffeffvdejfeejie dvkeffgfekuefgheevteeufeelkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 23 Feb 2022 07:35:29 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 4d3e29f8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 23 Feb 2022 12:35:28 +0000 (UTC) Date: Wed, 23 Feb 2022 13:35:27 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 1/5] upload-pack: look up "want" lines via commit-graph Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org During packfile negotiation the client will send "want" and "want-ref" lines to the server to tell it which objects it is interested in. The server-side parses each of those and looks them up to see whether it actually has requested objects. This lookup is performed by calling `parse_object()` directly, which thus hits the object database. In the general case though most of the objects the client requests will be commits. We can thus try to look up the object via the commit-graph opportunistically, which is much faster than doing the same via the object database. Refactor parsing of both "want" and "want-ref" lines to do so. The following benchmark is executed in a repository with a huge number of references. It uses cached request from git-fetch(1) as input and contains about 876,000 "want" lines: Benchmark 1: git-upload-pack (HEAD~) Time (mean ± σ): 7.113 s ± 0.028 s [User: 6.900 s, System: 0.662 s] Range (min … max): 7.072 s … 7.168 s 10 runs Benchmark 2: git-upload-pack (HEAD) Time (mean ± σ): 6.622 s ± 0.061 s [User: 6.452 s, System: 0.650 s] Range (min … max): 6.535 s … 6.727 s 10 runs Summary 'git-upload-pack (HEAD)' ran 1.07 ± 0.01 times faster than 'git-upload-pack (HEAD~)' Signed-off-by: Patrick Steinhardt --- upload-pack.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 8acc98741b..3a851b3606 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1400,13 +1400,19 @@ static int parse_want(struct packet_writer *writer, const char *line, const char *arg; if (skip_prefix(line, "want ", &arg)) { struct object_id oid; + struct commit *commit; struct object *o; if (get_oid_hex(arg, &oid)) die("git upload-pack: protocol error, " "expected to get oid, not '%s'", line); - o = parse_object(the_repository, &oid); + commit = lookup_commit_in_graph(the_repository, &oid); + if (commit) + o = &commit->object; + else + o = parse_object(the_repository, &oid); + if (!o) { packet_writer_error(writer, "upload-pack: not our ref %s", @@ -1434,7 +1440,7 @@ static int parse_want_ref(struct packet_writer *writer, const char *line, if (skip_prefix(line, "want-ref ", &refname_nons)) { struct object_id oid; struct string_list_item *item; - struct object *o; + struct object *o = NULL; struct strbuf refname = STRBUF_INIT; strbuf_addf(&refname, "%s%s", get_git_namespace(), refname_nons); @@ -1448,7 +1454,15 @@ static int parse_want_ref(struct packet_writer *writer, const char *line, item = string_list_append(wanted_refs, refname_nons); item->util = oiddup(&oid); - o = parse_object_or_die(&oid, refname_nons); + if (!starts_with(refname_nons, "refs/tags/")) { + struct commit *commit = lookup_commit_in_graph(the_repository, &oid); + if (commit) + o = &commit->object; + } + + if (!o) + o = parse_object_or_die(&oid, refname_nons); + if (!(o->flags & WANTED)) { o->flags |= WANTED; add_object_array(o, NULL, want_obj); From patchwork Wed Feb 23 12:35:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12756867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D792BC433F5 for ; Wed, 23 Feb 2022 12:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240363AbiBWMgG (ORCPT ); Wed, 23 Feb 2022 07:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240047AbiBWMgE (ORCPT ); Wed, 23 Feb 2022 07:36:04 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEC779E9C0 for ; Wed, 23 Feb 2022 04:35:34 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 3402B3201464 for ; Wed, 23 Feb 2022 07:35:34 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 23 Feb 2022 07:35:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=WNrVd9TZw72dp++gIuub95XhC9T4rkzfYLy0z/ VuXjk=; b=CXj2cSbzj36fMGua5pyNbBQb6t6zfuENxnlDGzH0VYVxKpc2mCthj+ 0tOY/aqmAus8LRCYcBWhWwM4WCBKqFNVtmBYpizjBd9+HKqPNuef8b8/BPs4Dd0X mlLQuuuSM5g5vebpBWY1/XN1CWjAwfYfZynTe+942oHlWXvAeTxO2obl4mhTzfpB +C4SbZ0Sin8PS52M0On0UdR4xkt6m7WwyXizgR0uLmkzGjipG2eQYE4KOPX8vS24 g/pOD1ObRu5A0Sq6oD3NYNjfAbWF47rhAcrR8Wq1oEmW13LkekKNPXn6pWnrA1Vy AWTr5LZNXBsEEZFxQ4eCOEtdAMCPqggw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=WNrVd9TZw72dp++gI uub95XhC9T4rkzfYLy0z/VuXjk=; b=dQgdHMoCHkR7iNLnxAanX/IdaBCcGn4a2 EF3f2wtJWfA001W1QbIIv8VE1ttFAc+6hua9E84h6BRBBWaeLgjC3Ral3Ito4wUQ u8wrAmNdO/2S6CxxrPdkG106JTNpfRVkE3Wtw/41o/DwCp44qEZKpwCqjsnqluYr 3WAFOGFpEzeAoFVrnT4PRriBkJ0ehbvDsFkH4gda2U+53H+DsIblJKP02JW/QXto 8ubtqZEwyh5kFle6BXqIVU3m8OobT77mARc53Za91BdOZau0FqD1TgrOZ//Q4eEN AwQBiPGQ4jGR+0MSlE5bOydXRpI15RIAUEObKq+lG0dfxwj8q86Rg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrledtgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttdejnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgfejueevjeetudehgffffeffvdejfeejie dvkeffgfekuefgheevteeufeelkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 23 Feb 2022 07:35:33 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 7b2604ad (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 23 Feb 2022 12:35:32 +0000 (UTC) Date: Wed, 23 Feb 2022 13:35:31 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 2/5] fetch: avoid lookup of commits when not appending to FETCH_HEAD Message-ID: <80f993dddd521133154a751aeaab86adee409eea.1645619224.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When fetching from a remote repository we will by default write what has been fetched into the special FETCH_HEAD reference. The order in which references are written depends on whether the reference is for merge or not, which, despite some other conditions, is also determined based on whether the old object ID the reference is being updated from actually exists in the repository. To write FETCH_HEAD we thus loop through all references thrice: once for the references that are about to be merged, once for the references that are not for merge, and finally for all references that are ignored. For every iteration, we then look up the old object ID to determine whether the referenced object exists so that we can label it as "not-for-merge" if it doesn't exist. It goes without saying that this can be expensive in case where we are fetching a lot of references. While this is hard to avoid in the case where we're writing FETCH_HEAD, users can in fact ask us to skip this work via `--no-write-fetch-head`. In that case, we do not care for the result of those lookups at all because we don't have to order writes to FETCH_HEAD in the first place. Skip this busywork in case we're not writing to FETCH_HEAD. The following benchmark performs a mirror-fetch in a repository with about two million references: Benchmark 1: git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD~) Time (mean ± σ): 75.388 s ± 1.942 s [User: 71.103 s, System: 8.953 s] Range (min … max): 73.184 s … 76.845 s 3 runs Benchmark 2: git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD) Time (mean ± σ): 69.486 s ± 1.016 s [User: 65.941 s, System: 8.806 s] Range (min … max): 68.864 s … 70.659 s 3 runs Summary 'git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD)' ran 1.08 ± 0.03 times faster than 'git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD~)' Signed-off-by: Patrick Steinhardt --- builtin/fetch.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index e8305b6662..4d12c2fd4d 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1146,7 +1146,6 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, want_status <= FETCH_HEAD_IGNORE; want_status++) { for (rm = ref_map; rm; rm = rm->next) { - struct commit *commit = NULL; struct ref *ref = NULL; if (rm->status == REF_STATUS_REJECT_SHALLOW) { @@ -1157,21 +1156,34 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, } /* - * References in "refs/tags/" are often going to point - * to annotated tags, which are not part of the - * commit-graph. We thus only try to look up refs in - * the graph which are not in that namespace to not - * regress performance in repositories with many - * annotated tags. + * When writing FETCH_HEAD we need to determine whether + * we already have the commit or not. If not, then the + * reference is not for merge and needs to be written + * to the reflog after other commits which we already + * have. We're not interested in this property though + * in case FETCH_HEAD is not to be updated, so we can + * skip the classification in that case. */ - if (!starts_with(rm->name, "refs/tags/")) - commit = lookup_commit_in_graph(the_repository, &rm->old_oid); - if (!commit) { - commit = lookup_commit_reference_gently(the_repository, - &rm->old_oid, - 1); - if (!commit) - rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE; + if (fetch_head->fp) { + struct commit *commit = NULL; + + /* + * References in "refs/tags/" are often going to point + * to annotated tags, which are not part of the + * commit-graph. We thus only try to look up refs in + * the graph which are not in that namespace to not + * regress performance in repositories with many + * annotated tags. + */ + if (!starts_with(rm->name, "refs/tags/")) + commit = lookup_commit_in_graph(the_repository, &rm->old_oid); + if (!commit) { + commit = lookup_commit_reference_gently(the_repository, + &rm->old_oid, + 1); + if (!commit) + rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE; + } } if (rm->fetch_head_status != want_status) From patchwork Wed Feb 23 12:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12756870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27140C433F5 for ; Wed, 23 Feb 2022 12:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240479AbiBWMgK (ORCPT ); Wed, 23 Feb 2022 07:36:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240429AbiBWMgG (ORCPT ); Wed, 23 Feb 2022 07:36:06 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EB2D9E9DC for ; Wed, 23 Feb 2022 04:35:38 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DCFD53201464 for ; Wed, 23 Feb 2022 07:35:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 23 Feb 2022 07:35:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=VO041jxTbrMxPNE4/i+uf8ccmMznPA7J/VmHh3 Xrjto=; b=LRGjQT3dGkkiJP2CSDv3WPSwkA1y46qSxmtPXUR7Cpq32/Suww98xT BdCsFXYD78ZjAy4YBg4/re7uZ/wrGwmp2hoPXG5qbAkxU1iiqmCG4Vnr+crhZ+jh mS3yX25HGe216J3HBRUUKY1jccsLdwdEgtgfD9rAU9aXlONGl5fvyefWuoqTlfjh MulWmb67PEWum04QQsdISoAZMsFiRlnFkL3Sn4dXi5yl8V3BdV0yJ3Oly7BmYcmD a7Gt207ikYSc3F8pIT6QpH/q9EtngGx0vOX09lb5pMAYYO0Z3e03K9LveKn56X2f xwwzG+z8GlcdyjZD68CJKv5S95KHZ6sw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=VO041jxTbrMxPNE4/ i+uf8ccmMznPA7J/VmHh3Xrjto=; b=XdKCtxGRw/h5jRakGZfE+wc4Z8XaM5QZp QeQXHh3dzVnifyyjRKTfZUenQrmOIuuMkYJL13JhYQ50FnPRCV/Fmu9rbcTuB+sr kRTuNt/cyrsGLRA1syAvV84rv5rOnQa3btD6Tz417Ah6aoyKMgr7/QbXvCGp3Jmf aWXsRKd5GH6+10R6rr42Eoc+yPqStT3LFW+5j8Yuht11M428d5MCia3rS5FO8o+C /gppXMRnz6VGAvE+PTODNAuoTdqCWrcdnKFntTBZquKUNalojTzjiGOgXoxR1+3c sfERd3bYlpiCnzuxV/H8iho4B8EkIqe/weLAi5M1VEPFE8YTmD1/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrledtgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 23 Feb 2022 07:35:36 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id cc34f9e3 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 23 Feb 2022 12:35:36 +0000 (UTC) Date: Wed, 23 Feb 2022 13:35:35 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 3/5] refs: add ability for backends to special-case reading of symbolic refs Message-ID: <28cacbdbe2e7dd38f96ea2d37aa438adb9e5a270.1645619224.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reading of symbolic and non-symbolic references is currently treated the same in reference backends: we always call `refs_read_raw_ref()` and then decide based on the returned flags what type it is. This has one downside though: symbolic references may be treated different from normal references in a backend from normal references. The packed-refs backend for example doesn't even know about symbolic references, and as a result it is pointless to even ask it for one. There are cases where we really only care about whether a reference is symbolic or not, but don't care about whether it exists at all or may be a non-symbolic reference. But it is not possible to optimize for this case right now, and as a consequence we will always first check for a loose reference to exist, and if it doesn't, we'll query the packed-refs backend for a known-to-not-be-symbolic reference. This is inefficient and requires us to search all packed references even though we know to not care for the result at all. Introduce a new function `refs_read_symbolic_ref()` which allows us to fix this case. This function will only ever return symbolic references and can thus optimize for the scenario layed out above. By default, if the backend doesn't provide an implementation for it, we just use the old code path and fall back to `read_raw_ref()`. But in case the backend provides its own, more efficient implementation, we will use that one instead. Note that this function is explicitly designed to not distinguish between missing references and non-symbolic references. If it did, we'd be forced to always search the packed-refs backend to see whether the symbolic reference the user asked for really doesn't exist, or if it exists as a non-symbolic reference. Signed-off-by: Patrick Steinhardt --- refs.c | 17 +++++++++++++++++ refs.h | 3 +++ refs/debug.c | 1 + refs/files-backend.c | 1 + refs/packed-backend.c | 1 + refs/refs-internal.h | 16 ++++++++++++++++ 6 files changed, 39 insertions(+) diff --git a/refs.c b/refs.c index 1598fb13e2..0b79bdd7c3 100644 --- a/refs.c +++ b/refs.c @@ -1673,6 +1673,23 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname, type, failure_errno); } +int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname, + struct strbuf *referent) +{ + struct object_id oid; + int ret, failure_errno = 0; + unsigned int type = 0; + + if (ref_store->be->read_symbolic_ref) + return ref_store->be->read_symbolic_ref(ref_store, refname, referent); + + ret = refs_read_raw_ref(ref_store, refname, &oid, referent, &type, &failure_errno); + if (ret || !(type & REF_ISSYMREF)) + return -1; + + return 0; +} + const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname, int resolve_flags, diff --git a/refs.h b/refs.h index 1ae12c410a..23479c7ee0 100644 --- a/refs.h +++ b/refs.h @@ -82,6 +82,9 @@ int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags); int read_ref(const char *refname, struct object_id *oid); +int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname, + struct strbuf *referent); + /* * Return 0 if a reference named refname could be created without * conflicting with the name of an existing reference. Otherwise, diff --git a/refs/debug.c b/refs/debug.c index 2b0771ca53..c590d37720 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -435,6 +435,7 @@ struct ref_storage_be refs_be_debug = { debug_ref_iterator_begin, debug_read_raw_ref, + NULL, debug_reflog_iterator_begin, debug_for_each_reflog_ent, diff --git a/refs/files-backend.c b/refs/files-backend.c index f59589d6cc..f3428a9f12 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3286,6 +3286,7 @@ struct ref_storage_be refs_be_files = { files_ref_iterator_begin, files_read_raw_ref, + NULL, files_reflog_iterator_begin, files_for_each_reflog_ent, diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 27dd8c3922..f56e2cc635 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1684,6 +1684,7 @@ struct ref_storage_be refs_be_packed = { packed_ref_iterator_begin, packed_read_raw_ref, + NULL, packed_reflog_iterator_begin, packed_for_each_reflog_ent, diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 6e15db3ca4..001ef15835 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -649,6 +649,21 @@ typedef int read_raw_ref_fn(struct ref_store *ref_store, const char *refname, struct object_id *oid, struct strbuf *referent, unsigned int *type, int *failure_errno); +/* + * Read a symbolic reference from the specified reference store. This function + * is optional: if not implemented by a backend, then `read_raw_ref_fn` is used + * to read the symbolcic reference instead. It is intended to be implemented + * only in case the backend can optimize the reading of symbolic references. + * + * Return 0 on success, or -1 on failure. `referent` will be set to the target + * of the symbolic reference on success. This function explicitly does not + * distinguish between error cases and the reference not being a symbolic + * reference to allow backends to optimize this operation in case symbolic and + * non-symbolic references are treated differently. + */ +typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refname, + struct strbuf *referent); + struct ref_storage_be { struct ref_storage_be *next; const char *name; @@ -668,6 +683,7 @@ struct ref_storage_be { ref_iterator_begin_fn *iterator_begin; read_raw_ref_fn *read_raw_ref; + read_symbolic_ref_fn *read_symbolic_ref; reflog_iterator_begin_fn *reflog_iterator_begin; for_each_reflog_ent_fn *for_each_reflog_ent; From patchwork Wed Feb 23 12:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12756871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94F19C433F5 for ; Wed, 23 Feb 2022 12:35:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240476AbiBWMgS (ORCPT ); Wed, 23 Feb 2022 07:36:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240478AbiBWMgK (ORCPT ); Wed, 23 Feb 2022 07:36:10 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD1BA1479 for ; Wed, 23 Feb 2022 04:35:42 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 7233D3201805 for ; Wed, 23 Feb 2022 07:35:42 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 23 Feb 2022 07:35:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=Giu0OPHv20pjZgogtRRyrp+R+l/l7a8KO7ceBo byli0=; b=k5vqDuhrNDfC6mREJGJg9jxOj5L5FpCobswR2gHy5/p8uMfan/1BkQ Xyugg+6yKzDTxak+Z+07pIXz110r3cnebTeDas01MY9dIrdN+7Gejz+aYe6WZmht 4BlclWVOkmQ55qSq9EtYdLhT7PE7bd171zQowM0NaQZEnKfoKFjTcvsHQ21wcYxC AaXBportp7MH5fPEgiDTie6CzE6ao5WzwEMTcyVwz69Yv3Gj4b/SdH4VPA72IOi1 ZZTL3EbpE7S4ds5NhO4cFB5bk4ymtQwDWULLzOFYhrYo2C/g+kZJVr7H4g2j1NtH jLlYTHBSW6d0MvmIXp7PBF2rxJTCSd/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Giu0OPHv20pjZgogt RRyrp+R+l/l7a8KO7ceBobyli0=; b=ZLmMdcUNGQFZuPOnFBCOdyqsxpmJkrLMX NuWyvP3wRhsDNgRYZSN40Q60VSRrOh6v+HmHKwCjbKmrjG3/Z7yErAKj9igc08zq GP6hU2VL2O8HBWU03NofZf16Y8Kki4gFn7z/FZbMXu14wt34MPejaZOSCGeik8UU 0F5EuMlI98HPwkcwYUuvXv4sa5Xh7OblhRIA+hdJV7lKCpBsbG9WMoJv7pVrgWMD VsAiyoDU+mziUEFnquJe/78MnESfwLWVlbcYVVR5ZxWB/cnWWRAPnrRHJyVKfGyb /44bvLGH569uQnG3rYoR/EwKmM6CGlDLnx/A7uK2BNt3fCYzbywjw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrledtgdegudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 23 Feb 2022 07:35:41 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 71224808 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 23 Feb 2022 12:35:40 +0000 (UTC) Date: Wed, 23 Feb 2022 13:35:39 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 4/5] remote: read symbolic refs via `refs_read_symbolic_ref()` Message-ID: <1d24101fe4fb296257110eb82da67c95b5e03189.1645619224.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have two cases in the remote code where we check whether a reference is symbolic or not, but don't mind in case it doesn't exist or in case it exists but is a non-symbolic reference. Convert these two callsites to use the new `refs_read_symbolic_ref()` function, whose intent is to implement exactly that usecase. No change in behaviour is expected from this change. Signed-off-by: Patrick Steinhardt --- builtin/remote.c | 8 +++++--- remote.c | 14 +++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index 6f27ddc47b..0142ed09b5 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -766,13 +766,15 @@ static int mv(int argc, const char **argv) for_each_ref(read_remote_branches, &rename); for (i = 0; i < remote_branches.nr; i++) { struct string_list_item *item = remote_branches.items + i; - int flag = 0; + struct strbuf referent = STRBUF_INIT; - read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag); - if (!(flag & REF_ISSYMREF)) + if (refs_read_symbolic_ref(get_main_ref_store(the_repository), item->string, + &referent)) continue; if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF)) die(_("deleting '%s' failed"), item->string); + + strbuf_release(&referent); } for (i = 0; i < remote_branches.nr; i++) { struct string_list_item *item = remote_branches.items + i; diff --git a/remote.c b/remote.c index c97c626eaa..42a4e7106e 100644 --- a/remote.c +++ b/remote.c @@ -1945,13 +1945,9 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err) return branch->push_tracking_ref; } -static int ignore_symref_update(const char *refname) +static int ignore_symref_update(const char *refname, struct strbuf *scratch) { - int flag; - - if (!resolve_ref_unsafe(refname, 0, NULL, &flag)) - return 0; /* non-existing refs are OK */ - return (flag & REF_ISSYMREF); + return !refs_read_symbolic_ref(get_main_ref_store(the_repository), refname, scratch); } /* @@ -1964,6 +1960,7 @@ static int ignore_symref_update(const char *refname) static struct ref *get_expanded_map(const struct ref *remote_refs, const struct refspec_item *refspec) { + struct strbuf scratch = STRBUF_INIT; const struct ref *ref; struct ref *ret = NULL; struct ref **tail = &ret; @@ -1971,11 +1968,13 @@ static struct ref *get_expanded_map(const struct ref *remote_refs, for (ref = remote_refs; ref; ref = ref->next) { char *expn_name = NULL; + strbuf_reset(&scratch); + if (strchr(ref->name, '^')) continue; /* a dereference item */ if (match_name_with_pattern(refspec->src, ref->name, refspec->dst, &expn_name) && - !ignore_symref_update(expn_name)) { + !ignore_symref_update(expn_name, &scratch)) { struct ref *cpy = copy_ref(ref); cpy->peer_ref = alloc_ref(expn_name); @@ -1987,6 +1986,7 @@ static struct ref *get_expanded_map(const struct ref *remote_refs, free(expn_name); } + strbuf_release(&scratch); return ret; } From patchwork Wed Feb 23 12:35:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12756872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A694BC433EF for ; Wed, 23 Feb 2022 12:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240488AbiBWMgT (ORCPT ); Wed, 23 Feb 2022 07:36:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240491AbiBWMgQ (ORCPT ); Wed, 23 Feb 2022 07:36:16 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CB0FA27B1 for ; Wed, 23 Feb 2022 04:35:46 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id E90D6320187F for ; Wed, 23 Feb 2022 07:35:45 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 23 Feb 2022 07:35:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=EOnloiPcWIzchY5d3Qqpa8v/o0Iw8YS5SpJsLi NtTL4=; b=AOyB6P5eN/Gq/verw8TIyftJAmlkku2YLVbQHgZQgywDEDvMt2TPlb cgyy5bp++mpWUddSmuxZTTdcejNRUVW7Xd7+5+yT4BN/1NEbzM4gw6uOhdS8GuuW Y5I2DvWkRhc8IJwXsNZuB9h6gE9It95HQMwFidmi2Y+tBz9FTbk7tkW9xJ2pBx8y 36w+fihUYpGSmODNeEgkJpj+4JB4dm3zC9hIOOlDhRxgzpj4GfuEzZnlx8TjGdZX qgU6AURTbBCEQdZmd1npmC8PumNJCZoHjbAUnvegdvT5OiRc6IFSFEctKpigCl01 eFdGDjvZMaJu0QRCEvdEu5zhw4oZtZ8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=EOnloiPcWIzchY5d3 Qqpa8v/o0Iw8YS5SpJsLiNtTL4=; b=IIre5g0WNO4E5VoRHEftkPHtzQue+QKtB LjLG0ocVW1BOTm8jt+RSflE2gLfHhrC8pvnCUicaF8/WvHYszNB6iKJdgwoRW9c1 3hBBe+SGqK7Qj+wPKY2KvaYIkOrviQNM+qqqvueQ25yDhEn10uizu7ZDvGN3Clxd kTp0IPA61AetjfizLEYoRJ2MxisS99+gXx3uOY1hzjSM5ZGv423kFeexE72YBulK kHcE2MPznWk9QbAhc6gAWXQvuw5bNgJczb3VtpBhydiEzYzChKELe/sWXQ91hH4+ OtFOIFv3mgZekuGFzWChFi5MMz1EiYouGwwKoh1gWTyZJGxEjyZlQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrledtgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttdejnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgfejueevjeetudehgffffeffvdejfeejie dvkeffgfekuefgheevteeufeelkeenucevlhhushhtvghrufhiiigvpedunecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 23 Feb 2022 07:35:44 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 8da4dcec (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 23 Feb 2022 12:35:44 +0000 (UTC) Date: Wed, 23 Feb 2022 13:35:43 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 5/5] refs/files-backend: optimize reading of symbolic refs Message-ID: <7213ffdbddc7b14c8665974e41bda9449f66de4a.1645619224.git.ps@pks.im> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When reading references via `files_read_raw_ref()` we always consult both the loose reference, and if that wasn't found, we also consult the packed-refs file. While this makes sense to read a generic reference, it is wasteful in the case where we only care about symbolic references: the packed-refs backend does not support them, and thus it cannot ever return one for us. Special-case reading of symbolic references for the files backend such that we always skip asking the packed-refs backend. We use `refs_read_symbolic_ref()` extensively to determine whether we need to skip updating local symbolic references during a fetch, which is why the change results in a significant speedup when doing fetches in repositories with huge numbers of references. The following benchmark executes a mirror-fetch in a repository with about 2 million references: Benchmark 1: git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD~) Time (mean ± σ): 68.372 s ± 2.344 s [User: 65.629 s, System: 8.786 s] Range (min … max): 65.745 s … 70.246 s 3 runs Benchmark 2: git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD) Time (mean ± σ): 60.259 s ± 0.343 s [User: 61.019 s, System: 7.245 s] Range (min … max): 60.003 s … 60.649 s 3 runs Summary 'git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD)' ran 1.13 ± 0.04 times faster than 'git fetch --prune --no-write-fetch-head +refs/*:refs/* (HEAD~)' Signed-off-by: Patrick Steinhardt --- refs/files-backend.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index f3428a9f12..0457ecdb42 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -338,9 +338,9 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs) return refs->loose; } -static int files_read_raw_ref(struct ref_store *ref_store, const char *refname, - struct object_id *oid, struct strbuf *referent, - unsigned int *type, int *failure_errno) +static int read_ref_internal(struct ref_store *ref_store, const char *refname, + struct object_id *oid, struct strbuf *referent, + unsigned int *type, int *failure_errno, int skip_packed_refs) { struct files_ref_store *refs = files_downcast(ref_store, REF_STORE_READ, "read_raw_ref"); @@ -381,7 +381,7 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname, if (lstat(path, &st) < 0) { int ignore_errno; myerr = errno; - if (myerr != ENOENT) + if (myerr != ENOENT || skip_packed_refs) goto out; if (refs_read_raw_ref(refs->packed_ref_store, refname, oid, referent, type, &ignore_errno)) { @@ -425,7 +425,8 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname, * ref is supposed to be, there could still be a * packed ref: */ - if (refs_read_raw_ref(refs->packed_ref_store, refname, oid, + if (skip_packed_refs || + refs_read_raw_ref(refs->packed_ref_store, refname, oid, referent, type, &ignore_errno)) { myerr = EISDIR; goto out; @@ -470,6 +471,27 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname, return ret; } +static int files_read_raw_ref(struct ref_store *ref_store, const char *refname, + struct object_id *oid, struct strbuf *referent, + unsigned int *type, int *failure_errno) +{ + return read_ref_internal(ref_store, refname, oid, referent, type, failure_errno, 0); +} + +static int files_read_symbolic_ref(struct ref_store *ref_store, const char *refname, + struct strbuf *referent) +{ + struct object_id oid; + int failure_errno, ret; + unsigned int type; + + ret = read_ref_internal(ref_store, refname, &oid, referent, &type, &failure_errno, 1); + if (ret) + return ret; + + return !(type & REF_ISSYMREF); +} + int parse_loose_ref_contents(const char *buf, struct object_id *oid, struct strbuf *referent, unsigned int *type, int *failure_errno) @@ -3286,7 +3308,7 @@ struct ref_storage_be refs_be_files = { files_ref_iterator_begin, files_read_raw_ref, - NULL, + files_read_symbolic_ref, files_reflog_iterator_begin, files_for_each_reflog_ent,