From patchwork Tue Dec 7 10:56:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12661587 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 23BF7C433F5 for ; Tue, 7 Dec 2021 10:56:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235463AbhLGLAR (ORCPT ); Tue, 7 Dec 2021 06:00:17 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44857 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235466AbhLGLAQ (ORCPT ); Tue, 7 Dec 2021 06:00:16 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3D2F25C0039; Tue, 7 Dec 2021 05:56:46 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 07 Dec 2021 05:56: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=fm2; bh=z/MQqbskvrmSpKBAcDfjMcY0Lkm u//JN6oxgS/8PpMk=; b=q57wPpj4uBmirYPxV7oI/djAClmXQw7Mlo1nhvzsJlj tVd5SvD62NCj9noGiB7Kq4yHl4rf9IukQoPqK+8h8nmjdVuegNp3qBndMLEgbzl6 BDtjO+0X4UVJOzhv4NO3SlPfxv3yDcdnjf24MNkTZfDvYXmv1pS+FdUvWpyV8k4c xP4l6R7dpfw9o5zOcqpy0pfdmr2HfuBI3QhCtmqshaoJF+ag1qyefUCCUrksK4gZ H+UlhK5P9GVmf1DX7Xy9TDXmWVXd0kj/603DNooaNk1ArXPrgSFNY71GwvGmWEmD shvcY96vPvQIECBsyLLco24q+CRhgECPQrtRVdmn7Dw== 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=z/MQqb skvrmSpKBAcDfjMcY0Lkmu//JN6oxgS/8PpMk=; b=SxFF3MaYZptGnQk28tq+MA fhOkh8y/80/7FZpk3OU58xFbfnzCWZEejzraLUIB1Wni9dmIwy9sLbEbIJ94wUS4 ExK/d8nba9cdUYFyqSkFqrS4MoJBILfAod3ETTYeSKIhdHQS8AwFQuj/KN8a3g+R Z8byyLw052rksWuWHSkXbtjyG+GoJt+3qn7mSgpeVHgid8gLmJNi+wt5ZZC0Cw/T lj5frw7hkfu09y17yRmc8GwPjQntENMpN9ajuiJRKt0tjeFfLYM0Xdks/2mjDzpK QlluDYB2a5cW8zaxwMr5WnRHSpr5rWr7kWSiRlf6sZCNhfs7xT2EM2G3NFt9HRjQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrjeehgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfhnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkh hsrdhimh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 Dec 2021 05:56:45 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 044aa871 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 Dec 2021 12:26:23 +0000 (UTC) Date: Tue, 7 Dec 2021 11:56:05 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Bryan Turner , Waleed Khan Subject: [PATCH 3/6] refs: allow skipping the reference-transaction hook Message-ID: <0e42fc07f80903135bae10ac91e139f85ca9db54.1638874287.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 The reference-transaction hook is executing whenever we prepare, commit or abort a reference transaction. While this is mostly intentional, in case of the files backend we're leaking the implementation detail that the store is in fact a composite store with one loose and one packed backend to the caller. So while we want to execute the hook for all logical updates, executing it for such implementation details is unexpected. Prepare for a fix by adding a new flag which allows to skip execution of the hook. Signed-off-by: Patrick Steinhardt --- refs.c | 3 +++ refs.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/refs.c b/refs.c index 1c8a0c01f1..462e629d37 100644 --- a/refs.c +++ b/refs.c @@ -2076,6 +2076,9 @@ static int run_transaction_hook(struct ref_transaction *transaction, const char *hook; int ret = 0, i; + if (transaction->flags & REF_TRANSACTION_SKIP_HOOK) + return 0; + hook = find_hook("reference-transaction"); if (!hook) return ret; diff --git a/refs.h b/refs.h index e3d3b7aa14..840fa02613 100644 --- a/refs.h +++ b/refs.h @@ -546,6 +546,11 @@ enum action_on_err { UPDATE_REFS_QUIET_ON_ERR }; +/* + * Skip executing the reference-transaction hook. + */ +#define REF_TRANSACTION_SKIP_HOOK (1 << 0) + /* * Begin a reference transaction. The reference transaction must * be freed by calling ref_transaction_free().