From patchwork Thu Jan 13 06:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12712316 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 51669C433F5 for ; Thu, 13 Jan 2022 06:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbiAMGLi (ORCPT ); Thu, 13 Jan 2022 01:11:38 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:54413 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231424AbiAMGLh (ORCPT ); Thu, 13 Jan 2022 01:11:37 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0A7DB3200E79; Thu, 13 Jan 2022 01:11:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 13 Jan 2022 01:11:37 -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=rqD2Papo/j3GLQ8UZyYjKX5zUMm aboRD6mjg2rEqa5o=; b=N92EzE7L6ROuEfR1ydvhJ5Se3k7YfRHDPneFKFtVsX/ WNbargJ8KKM1lemv0B3KCaFso8fnnm4QIbERUYyb9Gi+Nqviw7cJl9NDyS3WB3Pd h/EDc/R2tTN2ze9nniczlMZBZF49GfwLpdgUq+5jnM05GW7d3s6aLQN4ZGoORE4m /nP/1PwSIe85jR4dAS7txwSch44//c7wAf8KydTg0VldFviKNJedq0Qf1qSaaFwV WVw6k3Ov2naGPnY6+BB6bqzWSpdi75D+dTHoAXtFYCmo57xul5q3WslBuov8s6+n 4pSXlxd8wySLtHIz8Y+CfSnrkDMgQls5gKYI8gtW1fQ== 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=rqD2Pa po/j3GLQ8UZyYjKX5zUMmaboRD6mjg2rEqa5o=; b=R8UnGnsPP7FuS6AbKR7Vyj p6MnITF7IFZ4/GK3+54AAmCod7fXF52Ens2rbsZAjTCfW8r19FgwJ5aSzQvzJjUU zY71zjo0j6CXrBevNiTF9OpzcMwnXieJb0TSf/4o44UnrJ6zH+MSIN4fRcY6HQ3q gGdbLJjAmj3SYgNr85+4q3aCObHdAMrQc6ri+JFXIai/BPXi1YwYBHuLuwdZ7LZA v/L0N38G9FWTdXRDRBLHzL+8/QJHpBDT918PYfb5xmx5iCuASdZkSpU0/DT66nYf 3OXTrnGkX0Tshk7VnvLVXB2HtvCXafaCo5HkuC46u6YulKDQcJdfERBW3/VotGcg == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrtddvgdeludcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfhnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkh hsrdhimh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Jan 2022 01:11:35 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 1e4d1b4c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 13 Jan 2022 06:11:35 +0000 (UTC) Date: Thu, 13 Jan 2022 07:11:34 +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 3/6] refs: allow skipping the reference-transaction hook 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 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 7415864b62..526bf5ed97 100644 --- a/refs.c +++ b/refs.c @@ -2084,6 +2084,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 31f7bf9642..d4056f9fe2 100644 --- a/refs.h +++ b/refs.h @@ -568,6 +568,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().