From patchwork Tue Dec 7 10:56:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12661591 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 C4DC2C433EF for ; Tue, 7 Dec 2021 10:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235478AbhLGLAZ (ORCPT ); Tue, 7 Dec 2021 06:00:25 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33625 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235472AbhLGLAY (ORCPT ); Tue, 7 Dec 2021 06:00:24 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 739CC5C019E; Tue, 7 Dec 2021 05:56:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 07 Dec 2021 05:56:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=HemMUxYexzt6UrZS38Rast9rIRK q0c+cXxe7osGeW7E=; b=IfxjitxKIM73KzO/cMFdxDWlI1tPF9rRvAsf+Z1WUzr xJyZtIQhL+bAxboGBp+Z5xKm/8vOd6LQLPZll1zjwPOM5Ayqz6v9d0AEbyg6uf4v By494wof8WHltq/G6gvge+MVUfyrIeSaQv98qTmtG7i1x7ulOILnV+OWKHcDLCHq QBiwusNgpWDPyYPKqegRE0aZQjWUOagm5t7DDqCzcVezxRDEwgLlHAj2M/pP0z4w heqovm+PVPtrHh3eQKWcbwLT2JtFrATiA8fYV+glnKDlK6IwGnPqiylDale1o2al Fn1KiUZM+4Vf3SOG9msrR0rTvTw434uss8wMy372gjg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=HemMUx Yexzt6UrZS38Rast9rIRKq0c+cXxe7osGeW7E=; b=XWmQAfwvcrvve3Hb4YidQt 3XnNJlOqmsopJwhV4WLL+KFVTpB5GZZv3dtxeC14etxQDVMTws+/7n03as6HmMwY 8ivK9erkDObyIZur13HzoDwvh5vuX3UhuhzCcUcwjWaPz6lI2YuySnDJ0A6LDT78 BvS+IByZCg1/tESrfEo0bhVENf50F8ZtSLoqqCvqr6Wcjwl+ToNveM96TikODG43 kRlcKbQ5vBg0WU7s0YMDAudaFJD0dR1z+w2K0KaHqhdn2CWFMRMhuwBFk/Q7NBm5 RGuvzNf66suCcNJMyNB9aERGkfzIRiS5W6cgSpo4fXin+SA70jPrYAeAM4Po3xeA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrjeehgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfhnecu vehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkh hsrdhimh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 Dec 2021 05:56:53 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 87838cd9 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Dec 2021 12:26:32 +0000 (UTC) Date: Tue, 7 Dec 2021 11:56:13 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Bryan Turner , Waleed Khan Subject: [PATCH 5/6] refs: do not execute reference-transaction hook on packing refs Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The reference-transaction hook is supposed to track logical changes to references, but it currently also gets executed when packing refs in a repository. This is unexpected and ultimately not all that useful: packing refs is not supposed to result in any user-visible change to the refs' state, and it ultimately is an implementation detail of how refs stores work. Fix this excessive execution of the hook when packing refs. Reported-by: Waleed Khan Signed-off-by: Patrick Steinhardt --- refs/files-backend.c | 6 ++++-- t/t1416-ref-transaction-hooks.sh | 11 +---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 95583dcd00..f2bc72f81b 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1122,7 +1122,8 @@ static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r) if (check_refname_format(r->name, 0)) return; - transaction = ref_store_transaction_begin(&refs->base, 0, &err); + transaction = ref_store_transaction_begin(&refs->base, + REF_TRANSACTION_SKIP_HOOK, &err); if (!transaction) goto cleanup; ref_transaction_add_update( @@ -1193,7 +1194,8 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags) struct strbuf err = STRBUF_INIT; struct ref_transaction *transaction; - transaction = ref_store_transaction_begin(refs->packed_ref_store, 0, &err); + transaction = ref_store_transaction_begin(refs->packed_ref_store, + REF_TRANSACTION_SKIP_HOOK, &err); if (!transaction) return -1; diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh index 0567fbdf0b..f9d3d5213f 100755 --- a/t/t1416-ref-transaction-hooks.sh +++ b/t/t1416-ref-transaction-hooks.sh @@ -150,21 +150,12 @@ test_expect_success 'hook does not get called on packing refs' ' git pack-refs --all && # We only expect a single hook invocation, which is the call to - # git-update-ref(1). But currently, packing refs will also trigger the - # hook. + # git-update-ref(1). cat >expect <<-EOF && prepared $ZERO_OID $POST_OID refs/heads/unpacked-ref committed $ZERO_OID $POST_OID refs/heads/unpacked-ref - prepared - $ZERO_OID $POST_OID refs/heads/unpacked-ref - committed - $ZERO_OID $POST_OID refs/heads/unpacked-ref - prepared - $POST_OID $ZERO_OID refs/heads/unpacked-ref - committed - $POST_OID $ZERO_OID refs/heads/unpacked-ref EOF test_cmp expect actual