From patchwork Wed Nov 4 14:57:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 11880895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37562C2D0A3 for ; Wed, 4 Nov 2020 14:57:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94243221E2 for ; Wed, 4 Nov 2020 14:57:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="Rz83auZU"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BHdsInBa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730688AbgKDO5W (ORCPT ); Wed, 4 Nov 2020 09:57:22 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:46427 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730312AbgKDO5V (ORCPT ); Wed, 4 Nov 2020 09:57:21 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8B91B2D5; Wed, 4 Nov 2020 09:57:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 04 Nov 2020 09:57:20 -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=Tk0rizpbOUHOTA97MH1n9+poayf wwaAiAMz2dg4QF6Y=; b=Rz83auZUv0r86iSB9QmVkn36Ghp14t45leH10h7DFqi cekBfsB1iPVOjMmi0W0j/d1FBsl7/29GBUAGKm1TZn+Vkp2sggxjqJaQcGjQhKfK ocT3DFrm7oXvcKqickqAN0TSBGhQDUy6Ms1Zm79CzWXl4AcenkU/1cAo827Q4NZ4 hxi4wfsjA8MEZw3AFGq2nOwg1b6HtKCbVtn+Er8eKiP6uC0ePuu4iaRdmFGcrtkx UrXrHAlt7p2vfKtyfIYTnb+dCEFdeRRCFMvv5BCm0GSYSrYOq55wF88546R+UcG0 b5Fpus3sBziN047TUPYtWqpQ61Kjz7z0Bj8VBPYJ9Rg== 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=Tk0riz pbOUHOTA97MH1n9+poayfwwaAiAMz2dg4QF6Y=; b=BHdsInBahG5kI2rdnVG+W6 pD01YQsUx4qitOt3kCuasBQvJQp9Og2A25pg+iGo6n5giRwfpMhzz0I35FIN6NA1 4u6xNIplbpUA7cBlWH+ruT3vq+/TkERMRLKefym/SIqnJmqF5iKJRylJiUXZZaBD Bgzb5rmqIwB+ISHNjTxk5v3v4eDJFtZvK6M7k396zTTixF3K4EnKDZtdEi0tNUT3 dz5elZ0KiZmsleR8iRs5HLjz04KkFouWPd3itxCxyN5DZ1CYdnkTw6YBAGcTfy+2 4Qc8DJAmYY2wVsGUfOTkogFp/FxncwtwC+vIYtcuy44aWKGTCrLO896QAISOep4A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddthedgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecukfhppeejjedrudeluddrheegrdehnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrd himh X-ME-Proxy: Received: from vm-mail.pks.im (x4dbf3605.dyn.telefonica.de [77.191.54.5]) by mail.messagingengine.com (Postfix) with ESMTPA id 9D0733280392; Wed, 4 Nov 2020 09:57:19 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 05d215c3 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 4 Nov 2020 14:57:18 +0000 (UTC) Date: Wed, 4 Nov 2020 15:57:17 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: peff@peff.net Subject: [PATCH 1/2] update-ref: Allow creation of multiple transactions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org While git-update-ref has recently grown commands which allow interactive control of transactions in e48cf33b61 (update-ref: implement interactive transaction handling, 2020-04-02), it is not yet possible to create multiple transactions in a single session. To do so, one currently still needs to invoke the executable multiple times. This commit addresses this shortcoming by allowing the "start" command to create a new transaction if the current transaction has already been either committed or aborted. Signed-off-by: Patrick Steinhardt --- Documentation/git-update-ref.txt | 3 +- builtin/update-ref.c | 13 ++++++++- t/t1400-update-ref.sh | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt index d401234b03..48b6683071 100644 --- a/Documentation/git-update-ref.txt +++ b/Documentation/git-update-ref.txt @@ -125,7 +125,8 @@ option:: start:: Start a transaction. In contrast to a non-transactional session, a transaction will automatically abort if the session ends without an - explicit commit. + explicit commit. This command may create a new empty transaction when + the current one has been committed or aborted already. prepare:: Prepare to commit the transaction. This will create lock files for all diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 8a2df4459c..bb65129012 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -446,7 +446,18 @@ static void update_refs_stdin(void) state = cmd->state; break; case UPDATE_REFS_CLOSED: - die("transaction is closed"); + if (cmd->state != UPDATE_REFS_STARTED) + die("transaction is closed"); + + /* + * Open a new transaction if we're currently closed and + * get a "start". + */ + state = cmd->state; + transaction = ref_transaction_begin(&err); + if (!transaction) + die("%s", err.buf); + break; } diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 4c01e08551..72d995aece 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -1526,4 +1526,54 @@ test_expect_success 'transaction with prepare aborts by default' ' test_path_is_missing .git/$b ' +test_expect_success 'transaction can commit multiple times' ' + cat >stdin <<-EOF && + start + create refs/heads/branch-1 $A + commit + start + create refs/heads/branch-2 $B + commit + EOF + git update-ref --stdin actual && + printf "%s: ok\n" start commit start commit >expect && + test_cmp expect actual && + echo "$A" >expect && + git rev-parse refs/heads/branch-1 >actual && + test_cmp expect actual && + echo "$B" >expect && + git rev-parse refs/heads/branch-2 >actual && + test_cmp expect actual +' + +test_expect_success 'transaction can create and delete' ' + cat >stdin <<-EOF && + start + create refs/heads/create-and-delete $A + commit + start + delete refs/heads/create-and-delete $A + commit + EOF + git update-ref --stdin actual && + printf "%s: ok\n" start commit start commit >expect && + test_path_is_missing .git/refs/heads/create-and-delete +' + +test_expect_success 'transaction can commit after abort' ' + cat >stdin <<-EOF && + start + create refs/heads/abort $A + abort + start + create refs/heads/abort $A + commit + EOF + git update-ref --stdin actual && + printf "%s: ok\n" start abort start commit >expect && + echo "$A" >expect && + git rev-parse refs/heads/abort >actual && + test_cmp expect actual +' + test_done From patchwork Wed Nov 4 14:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 11880893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E70BC2D0A3 for ; Wed, 4 Nov 2020 14:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A15D2074B for ; Wed, 4 Nov 2020 14:57:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="GEkDH63Q"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JP0NWVnj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730643AbgKDO5a (ORCPT ); Wed, 4 Nov 2020 09:57:30 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:45631 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730312AbgKDO51 (ORCPT ); Wed, 4 Nov 2020 09:57:27 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 45D0AA8F; Wed, 4 Nov 2020 09:57:25 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 04 Nov 2020 09:57:25 -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=tQD+QvMSrXY3HioRPUOQA3ahBpb iByd/NpUNpOdR1YE=; b=GEkDH63QvRg2CFLaUqgiodL8JP0pruLacy1+Qb5izZS hqRz94qRnMiU9yn5pNZg2YHo3fPTYWrpvfMwpc3gxHQ0yJcw26jQnrUhKyXAN7jP MtDNI03euFNf7q+lHWzMvaP+wXXf1aBf+R8KfYdo2mhij+uO80I4pg79BIvTTRx+ q6DJSTTPZFJoP06bdWiNgVnlaoyxW5m85EiWBZ0uMXCRmKA2RGBZwfiLnN0Iaz7v pmiDSZYyRjFFHlgyeXUYqWetKfeGZzLC+LnUXLBzD2yF8PTUV9xbRF75/vuuL0eo zdtumq6qdLqephxHyEa/ctTG/dNbOofRU3eNiWvdj4Q== 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=tQD+Qv MSrXY3HioRPUOQA3ahBpbiByd/NpUNpOdR1YE=; b=JP0NWVnjlNOsMNm/dCV6TS z5Wc37CJ+kezQUt7WdnNkDmKdpF7KCnhTx1LM/+Ti1twTbr71CjTj0FprNBYIbN5 p5EKmjK4Y0mAC9LeuF8Uv+HV9hPBCNi8KWvTQ0B8UY7aVptzZxWG+We/DwNuaSew OSYgXE3C0FfoZPnkNdrW1hD19BaDc0E2fBLPLGXyRec/IhHwHMRNU0l0C4dmN996 PmXEFhV/gCxAtCcGe5yRL4+wUWAv31ri5urj9IUvRhtLkCdSZZTdT3RxW3ggclmW A2EAEO0CkqTzWvJduk7OrRHwlZtB0qaEeEEHBje4aXQYCktILZ1Uze9w7Yh6k10A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddthedgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecukfhppeejjedrudeluddrheegrdehnecuvehl uhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrd himh X-ME-Proxy: Received: from vm-mail.pks.im (x4dbf3605.dyn.telefonica.de [77.191.54.5]) by mail.messagingengine.com (Postfix) with ESMTPA id 46CEB328038E; Wed, 4 Nov 2020 09:57:24 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id e698efc7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 4 Nov 2020 14:57:23 +0000 (UTC) Date: Wed, 4 Nov 2020 15:57:22 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: peff@peff.net Subject: [PATCH 2/2] p1400: Use `git-update-ref --stdin` to test multiple transactions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In commit 0a0fbbe3ff (refs: remove lookup cache for reference-transaction hook, 2020-08-25), a new benchmark was added to p1400 which has the intention to exercise creation of multiple transactions in a single process. As git-update-ref wasn't yet able to create multiple transactions with a single run we instead used git-push. As its non-atomic version creates a transaction per reference update, this was the best approximation we could make at that point in time. Now that `git-update-ref --stdin` supports creation of multiple transactions, let's convert the benchmark to use that instead. It has less overhead and it's also a lot clearer what the actual intention is. Signed-off-by: Patrick Steinhardt --- t/perf/p1400-update-ref.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/t/perf/p1400-update-ref.sh b/t/perf/p1400-update-ref.sh index ce5ac3ed85..dda8a74866 100755 --- a/t/perf/p1400-update-ref.sh +++ b/t/perf/p1400-update-ref.sh @@ -7,13 +7,14 @@ test_description="Tests performance of update-ref" test_perf_fresh_repo test_expect_success "setup" ' - git init --bare target-repo.git && test_commit PRE && test_commit POST && - printf "create refs/heads/%d PRE\n" $(test_seq 1000) >create && - printf "update refs/heads/%d POST PRE\n" $(test_seq 1000) >update && - printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete && - git update-ref --stdin instructions ' test_perf "update-ref" ' @@ -26,14 +27,7 @@ test_perf "update-ref" ' ' test_perf "update-ref --stdin" ' - git update-ref --stdin /dev/null ' test_done From patchwork Mon Nov 9 10:06:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 11890877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05E12C4741F for ; Mon, 9 Nov 2020 10:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EFBF20663 for ; Mon, 9 Nov 2020 10:07:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="OL+Hnuuu"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TjJOahdI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729146AbgKIKHA (ORCPT ); Mon, 9 Nov 2020 05:07:00 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:57399 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728979AbgKIKHA (ORCPT ); Mon, 9 Nov 2020 05:07:00 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 78D781292; Mon, 9 Nov 2020 05:06:59 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 09 Nov 2020 05:06:59 -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=nl7nXpnoFLZT+vdMo1UDOwx/RZ1 fdPSAg/UMRA1RDKM=; b=OL+Hnuuu0eTGrjbMazdM1IpeN1No7pSu128somFUJiq VsV7DFl/rrIS6z+VhIM5tlyAu0vRGxFVqPn7Hzfg4qunq/iyRTnUq7284GNlzL8L g5oVLpzghzLC6lowwcLQ9w7f09EGAAIzCVR00qXxsTugSihd+Qrr58lJvzj/dmwz 50Vjz9DF4ErQhTDNJsQaF12D7iMdXVcedcU7VxY8fw3q5SpCEoFaO57G0cvsgVUN o3qgDJCMmJcxqY9bf7HpkRk3inhF0gu3A6ABZXXfe4T7DQM4VmajdTBct9kH+Uks ncgKXrDgvmY46vdmyOVQ/uWPBLu6G0B7zgSNg3RXcwg== 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=nl7nXp noFLZT+vdMo1UDOwx/RZ1fdPSAg/UMRA1RDKM=; b=TjJOahdIZk/NX6/kevNOkI 95p70UafDbaPzMRhDqFvukXgETh08yE5Z3btxpurCKCLmV34n6w6oPnjswg3cxps By5G2pOp795bPPxWRwojLI56UqPf0bFQOJPUjCSmVxfb7QN9aVMt69Sn1ftnhL87 bO8CrzbRKkJCPgX8m3UxnSRTumD2j8QBtEisfrZ1Mjd75+2NgpXAwyg3m4IM9ko1 A5rwHkwABGdwqzJaz9ObyCrFcErmVK/QC2s5xh7rSfCYdJ6qfIPc8TpAxkCooVkE JCebZUGlYWCCHOg7LL428idSJm3lxrA9uq8dPYlGDY2hykLzNYHfQj8lxQaU9dIQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudduhedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecukfhppeekledruddvrdegledrvdduleenucev lhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Received: from vm-mail.pks.im (dynamic-089-012-049-219.89.12.pool.telefonica.de [89.12.49.219]) by mail.messagingengine.com (Postfix) with ESMTPA id 6C1363063082; Mon, 9 Nov 2020 05:06:58 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id a79a671c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 9 Nov 2020 10:06:58 +0000 (UTC) Date: Mon, 9 Nov 2020 11:06:57 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: peff@peff.net, gitster@pobox.com Subject: [PATCH v2 3/4] p1400: Use `git-update-ref --stdin` to test multiple transactions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In commit 0a0fbbe3ff (refs: remove lookup cache for reference-transaction hook, 2020-08-25), a new benchmark was added to p1400 which has the intention to exercise creation of multiple transactions in a single process. As git-update-ref wasn't yet able to create multiple transactions with a single run we instead used git-push. As its non-atomic version creates a transaction per reference update, this was the best approximation we could make at that point in time. Now that `git-update-ref --stdin` supports creation of multiple transactions, let's convert the benchmark to use that instead. It has less overhead and it's also a lot clearer what the actual intention is. Signed-off-by: Patrick Steinhardt --- t/perf/p1400-update-ref.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/t/perf/p1400-update-ref.sh b/t/perf/p1400-update-ref.sh index ce5ac3ed85..dda8a74866 100755 --- a/t/perf/p1400-update-ref.sh +++ b/t/perf/p1400-update-ref.sh @@ -7,13 +7,14 @@ test_description="Tests performance of update-ref" test_perf_fresh_repo test_expect_success "setup" ' - git init --bare target-repo.git && test_commit PRE && test_commit POST && - printf "create refs/heads/%d PRE\n" $(test_seq 1000) >create && - printf "update refs/heads/%d POST PRE\n" $(test_seq 1000) >update && - printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete && - git update-ref --stdin instructions ' test_perf "update-ref" ' @@ -26,14 +27,7 @@ test_perf "update-ref" ' ' test_perf "update-ref --stdin" ' - git update-ref --stdin /dev/null ' test_done From patchwork Mon Nov 9 10:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 11890873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FB1BC4741F for ; Mon, 9 Nov 2020 10:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F13E20663 for ; Mon, 9 Nov 2020 10:07:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="qvuLKvtP"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TSvsMgsu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729223AbgKIKHF (ORCPT ); Mon, 9 Nov 2020 05:07:05 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:53591 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728108AbgKIKHE (ORCPT ); Mon, 9 Nov 2020 05:07:04 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4094610E4; Mon, 9 Nov 2020 05:07:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 09 Nov 2020 05:07:04 -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=70az/y8KTAsJ4BrK1QhVINvFuTf ph+rkrc/2eGHI7Io=; b=qvuLKvtPbrJ6bEvkoCBfgMhKl8tseuFSDTEvCCbD2oa oML//K3+MWzf5iGaoeHyNTWYm1hQSrH7DmY1Ndwetoa/CAhNOW5YQbw81vWVhfE8 95tPAAGVgyGphPH11X0rLEmPp9R0uY1wWUHEkDUB2KQ7Vq73HrQtInO84/NlAaYD vNwkNC/csjhYgHZ//LJmzEz9T7jfD00qSjwsjCz+kgvzVLxNQHUY8eKhgSYCbZXt lmxts1tI62zn0uSddLsLkiTMrHykL+Kst2zt+N64WW5rzC6ZcMEWmEcC/oln+M0y DHYHG4UU0tWzqXEWrQKFdsMXszE/LsZyXtINSp1mPIQ== 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=70az/y 8KTAsJ4BrK1QhVINvFuTfph+rkrc/2eGHI7Io=; b=TSvsMgsuvvlWBag/lnbBz6 VFfCLUiOX7qf08Hf7UxtumKKAC2U8LfDS+zCSrF7W5usk+J/kGxd8MLsnf7+YFCD uzOLUDGzHGDV/z97HEBPxtuK4bTnTFgBYj8jcdaZXYBaRaSNFLtXhFSKflyrdINh huv+Otu3qgF83cFXMWGpniuJZm5d00HZpcYk94gd5RvEWAmaQnSUHLSA2ufmtmb0 vrg8Q1IFQSOM4nMQCzrlEnmcbIfltpyT0Hips7+lPWmO+LXRXXJKWQduqXsmur71 IngeieCG5EziCVTMnCZfxz6sAWdFNbWt5oVEhfzIj7u1flqj13l5so/hfSmbDcOQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudduhedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecukfhppeekledruddvrdegledrvdduleenucev lhhushhtvghrufhiiigvpeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhksh drihhm X-ME-Proxy: Received: from vm-mail.pks.im (dynamic-089-012-049-219.89.12.pool.telefonica.de [89.12.49.219]) by mail.messagingengine.com (Postfix) with ESMTPA id 306ED3063082; Mon, 9 Nov 2020 05:07:03 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 1a9fdc4f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 9 Nov 2020 10:07:02 +0000 (UTC) Date: Mon, 9 Nov 2020 11:07:01 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: peff@peff.net, gitster@pobox.com Subject: [PATCH v2 4/4] update-ref: Disallow restart of ongoing transactions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It is currently possible to write multiple "start" commands into git-update-ref(1) for a single session, which doesn't make a lot of sense to do in the first place. It's also not quite obvious what should actually happen. Would this just go on with the current transaction as if nothing was written or would it recreate a new session which doesn't yet have any references? Silently ignoring this usage isn't helping either as it may indicate erroneous use of the interface. This commit catches this use and instead raises an error if the user is trying to restart an ongoing transaction. Signed-off-by: Patrick Steinhardt --- builtin/update-ref.c | 2 ++ t/t1400-update-ref.sh | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/builtin/update-ref.c b/builtin/update-ref.c index bb65129012..6029a80544 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -436,6 +436,8 @@ static void update_refs_stdin(void) switch (state) { case UPDATE_REFS_OPEN: case UPDATE_REFS_STARTED: + if (state == UPDATE_REFS_STARTED && cmd->state == UPDATE_REFS_STARTED) + die("cannot restart ongoing transaction"); /* Do not downgrade a transaction to a non-transaction. */ if (cmd->state >= state) state = cmd->state; diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 7ed41bb328..e53d973d04 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -1583,4 +1583,15 @@ test_expect_success 'transaction can commit after abort' ' test_cmp expect actual ' +test_expect_success 'transaction cannot restart ongoing transaction' ' + cat >stdin <<-EOF && + start + create refs/heads/restart $A + start + commit + EOF + test_must_fail git update-ref --stdin actual && + test_must_fail git show-ref --verify refs/heads/restart +' + test_done