From patchwork Thu Jan 13 06:11:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12712318 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 23FC5C433F5 for ; Thu, 13 Jan 2022 06:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231465AbiAMGLr (ORCPT ); Thu, 13 Jan 2022 01:11:47 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:60007 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbiAMGLq (ORCPT ); Thu, 13 Jan 2022 01:11:46 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 1D1793200495; Thu, 13 Jan 2022 01:11:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 13 Jan 2022 01:11:46 -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=fm3; bh=F5DeawsKhb8Q5J+fCd9Nx94Yg8+ RIlXG/EsPuSrtfVk=; b=lLQ/yqkfKbmcNfrzLUm2tz4hHI0pUova8mZvEBBybtY 2zsIAx/w8+1unnUlB9cuz1HAF6f/qeLor/zYax6y3WbMIMbK+n8NmWVa7LcZd3tq 0tEd2VrZNOnOMrdw5WG3cN/HxBfoZOxn6IHP/WbzyCZvzlXTjfhCxlBejb25KuY/ RFI2VcjkbcHxtTj/b5gnB9q8gHAbzGxu1Dv2Ynw3xJYQBh5y6Hlaa6KVxYKWOPy+ DuBs2OFoomZX+g/ZY+sSYf63k4xc+/CJZXOPYwPQOKvZ8etHkRALiZqeXdnBAKzg Icc6py/foXhHfn+cBH2hRWAdiqJ2e9a6jZjSXbqCMqQ== 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=F5Deaw sKhb8Q5J+fCd9Nx94Yg8+RIlXG/EsPuSrtfVk=; b=UOOFKazSmljQ7KffV8Z8s8 fF3YdbVSeOQwb2G6+VaPNg3ipROOE6ubVP0At2qoyO/MH84Y3RFbKRgKQ1HBOH4+ NEc8GvHKa/Vct1KjmKfyLBKmRPuwdm/ZzVYM4VLbDwzLBercvHvtFUnsNBf/Fiq5 Hr23ydJi0xnN7JKSMiJXvJoj7c0tAd/hkf7MPV1K6REv+8UGc6Fzhthy6mEc2+Ww lps0AHusHWA8ZDbjAluQccBPljU9nL06DrMsAlM8NsvJN9pFYO4e6PCKFz+MsPym sZpxIGVitGL7SDLzFQmbRWdOzP7gLlEqDIAwuN4WoaHaHS4P0JrcB/B6Fzi633aQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrtddvgdeludcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfhnecu vehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkh hsrdhimh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Jan 2022 01:11:44 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id ac3dfee4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 13 Jan 2022 06:11:43 +0000 (UTC) Date: Thu, 13 Jan 2022 07:11:42 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Bryan Turner , Waleed Khan , =?iso-8859-1?q?=C6var_Arnfj=F6r=F0?= Bjarmason , Han-Wen Nienhuys Subject: [PATCH v3 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 ecf88cee04..3c0f3027fe 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1121,7 +1121,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( @@ -1192,7 +1193,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