From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 41EB11F953 for ; Sat, 8 Jan 2022 01:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232450AbiAHBbJ (ORCPT ); Fri, 7 Jan 2022 20:31:09 -0500 Received: from pb-smtp21.pobox.com ([173.228.157.53]:54919 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbiAHBbI (ORCPT ); Fri, 7 Jan 2022 20:31:08 -0500 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 4ED0C16FD92; Fri, 7 Jan 2022 20:31:08 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=sasl; bh=bwhK+a4Nzya8oxrB+d05bHSgMCy1pRWRfDA/dOamqfQ=; b=tlSG BdRddcIonb8HGTc8Xgo/D7PHdNcjRR5ZExctwnAAodMY9wbpp/ZQlx1bLS4ZLbL3 56l+mCkjyL9YDsMNs9A5d7agFtbMi8NAMHCcraRWtN6Ja5CwYDqdLNccEY+VJpxd W+VkmE4ffAJTa/qtLXuJLcvEDrnc3UarcbZ28OI= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 4723B16FD91; Fri, 7 Jan 2022 20:31:08 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id BFA8A16FD8E; Fri, 7 Jan 2022 20:31:05 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Patrick Steinhardt Cc: git@vger.kernel.org, Jeff King , Bryan Turner , Waleed Khan Subject: Re: [PATCH v2 4/6] refs: demonstrate excessive execution of the reference-transaction hook References: Date: Fri, 07 Jan 2022 17:31:04 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: A601A56E-7022-11EC-AC7B-CBA7845BAAA9-77302942!pb-smtp21.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Patrick Steinhardt writes: > Add tests which demonstate which demonstrates that we're executing the You demonstrate too often, which may be the point of the test, but looks wrong. I actually think this should be done as part of the fix to the code itself, which presumably is a single-liner to tell the "skip when running delete in packed-refs backend". IOW, just fix the code and test how the externally observable behaviour of the code should be in new tests, in the same commit. > 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