From patchwork Thu Jan 13 06:11:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12712317 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 C9A15C433EF for ; Thu, 13 Jan 2022 06:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231462AbiAMGLn (ORCPT ); Thu, 13 Jan 2022 01:11:43 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:51389 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231424AbiAMGLm (ORCPT ); Thu, 13 Jan 2022 01:11:42 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9349A3200E5F; Thu, 13 Jan 2022 01:11:41 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 13 Jan 2022 01:11:42 -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=kofozq5wgu1I+yJI9Q4D7hrB/Tu dQavTXiH8/SvSvRs=; b=mha58rKbjPwhO4Xvb2JR0fLdOMIbL7tXciDoNkxTMCm UiUZ5qf31UUnXHP8e6Zfm778i4zQzeTVb6L03CjnZZorSteqbekK+3HREpK758A8 sHzAwGuvhfX3/HEXVuK0c1eNWTC3Vpp7e4yuHNigdqAJis+qL0S5mQ0nw4pbLVTc NUoZfnyst16g0LuGirZ5No3kLMhUzkUgrfJYPN2w23qQNMylZ8XpiR0zAFidB/0b jVcrSrE8AZq6GFvGfeZ+j48Ei+yyzz/0YMNXIZwFYD/3NuLEuSdK2jCT/m26O/Jc SlS/87gIKaFbGemvzwNZsT6BMijpOEpw9oGmUNxQ9Hw== 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=kofozq 5wgu1I+yJI9Q4D7hrB/TudQavTXiH8/SvSvRs=; b=nJZQJzzpiO1tCZhTfZ8sgO bsXat8MSelgrwcH+nO58zAqWh4Bb81160VcbtK1zj9m/X9B8TfkyRQv9Cso2jEzK /nJ3VReG/Nt0npZcdyMY9MuPOjuek0KTjrH0Tn5NreBTnv54Q458bT6RxYkhtGdI +gUS+h7opOQPkrOCnCXLi9Z9fe1vEOIJ1+18egxBG0tYLc2qJR1GZ1L1Tivz6KmQ FSAe2s1W6d4hmH68kAahol3zmF0K4MwAWzqO7e/5sO5eDxNgCkL5sHcwwFKxjmTU U2eI8oi7nQ6YKtnmyPmnvVUF5niR5qePq/7Ixp74xF6AgbwYR3kpcw9tg2zThxtA == 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:39 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id bee9e227 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 13 Jan 2022 06:11:39 +0000 (UTC) Date: Thu, 13 Jan 2022 07:11:38 +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 4/6] refs: demonstrate excessive execution of the reference-transaction hook Message-ID: <662a6e624420d405d9459cec196e79280bf238a7.1642054003.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 Add tests which demonstate that we're executing the reference-transaction hook too often in some cases, which thus leaks implementation details about the reference store's implementation itself. Behaviour will be fixed in follow-up commits. Signed-off-by: Patrick Steinhardt --- t/t1416-ref-transaction-hooks.sh | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh index 6c941027a8..0567fbdf0b 100755 --- a/t/t1416-ref-transaction-hooks.sh +++ b/t/t1416-ref-transaction-hooks.sh @@ -136,4 +136,68 @@ test_expect_success 'interleaving hook calls succeed' ' test_cmp expect target-repo.git/actual ' +test_expect_success 'hook does not get called on packing refs' ' + # Pack references first such that we are in a known state. + git pack-refs --all && + + write_script .git/hooks/reference-transaction <<-\EOF && + echo "$@" >>actual + cat >>actual + EOF + rm -f actual && + + git update-ref refs/heads/unpacked-ref $POST_OID && + 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. + 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 +' + +test_expect_success 'deleting packed ref calls hook once' ' + # Create a reference and pack it. + git update-ref refs/heads/to-be-deleted $POST_OID && + git pack-refs --all && + + write_script .git/hooks/reference-transaction <<-\EOF && + echo "$@" >>actual + cat >>actual + EOF + rm -f actual && + + git update-ref -d refs/heads/to-be-deleted $POST_OID && + + # We only expect a single hook invocation, which is the logical + # deletion. But currently, we see two interleaving transactions, once + # for deleting the loose refs and once for deleting the packed ref. + cat >expect <<-EOF && + prepared + $ZERO_OID $ZERO_OID refs/heads/to-be-deleted + prepared + $POST_OID $ZERO_OID refs/heads/to-be-deleted + committed + $ZERO_OID $ZERO_OID refs/heads/to-be-deleted + committed + $POST_OID $ZERO_OID refs/heads/to-be-deleted + EOF + + test_cmp expect actual +' + test_done