From patchwork Tue Apr 9 09:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13622099 Received: from wfout8-smtp.messagingengine.com (wfout8-smtp.messagingengine.com [64.147.123.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D82180620 for ; Tue, 9 Apr 2024 09:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656656; cv=none; b=sHuONC+Djrm0lIUh/QldvjL3gLCenly74ZYdYsmAAOmUcWjp+J3YHIMvDvKzp7ssZj8cAievmqR8/gFxT7isloesstnh3/G1mQdfYvwNJYcvTNQwaL6w3DVNiCCPCNbtplovUFVJ15SwZB8SpS/XIm3mYkP0uN1loI4tWaBjFmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656656; c=relaxed/simple; bh=bSAUPiU6xTjwAPvCW1kHvbZIjHGoSjEIK7t1dgluahA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nalyrNoTmcRgqvJx0ZAk5sn1dhMzwcl5ft92cnliGqEJmdMMc8zuO5D2iNqOceh/c32LSCFm1N/opRmMn1jLsab/6ojbUSopMCww1mCp2GUAqio4AerNV8TRxtE4pdgsqgqOIOBJw3UF2Q7lM/Oi3mZ1+eRz7KzErFt9DY013iE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=NOQRMdgI; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cz9a4O93; arc=none smtp.client-ip=64.147.123.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="NOQRMdgI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cz9a4O93" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id 0D2DF1C000B3; Tue, 9 Apr 2024 05:57:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 09 Apr 2024 05:57:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1712656652; x=1712743052; bh=QIJtoTzFC2 pYMeyR1t92m1EabLBJkpCjm9V+ByinDUc=; b=NOQRMdgIkRt98ILa3jxBnp6BBi 5E9G1KdM6N9tg1EcdNztt38nEsSqbic7LUWl9XhMc+ArkFu6nXdYHDoCgO/s3E2z B9js23NyLgSFpdeAx4OGc7tWRVw4SLGE2Du4Pt/yKOPY7mhuiLHtBh55HbQD4Dg1 PDRceRKT3OXd/+2FKfSU/78DO7F+ilgVgBR9HhozZ4KnSMlNm9y4cKtSKjblZptk bPTYwGDVRUdYnLRbD8IUFvqVk2rksAO3QMtIHdLmFmZAEELnuAWGQs2gDiZyCt1B /GOyd898V+GTTFU32HSu+R1L6ySysvvse7PlpuL0lqaicJTeVIo3AfKMYi6w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712656652; x=1712743052; bh=QIJtoTzFC2pYMeyR1t92m1EabLBJ kpCjm9V+ByinDUc=; b=cz9a4O93qzXS6AU29fb58ic6PWK2TbG4/ZC8BMcHO0Ny k1YdVQM4wso+BVsUlJ6lLEF6BXE4ZkeIhjXWyU0b16Q4rhe+TT3YIKjrhXBcpZhB zmV1OK+owJ+jHO02PzLsXcbMed7CxSv0jJKOCtmPrARSSHBo+dsLlGpxQcbLXDQB ehpik+sNOOLVzfzoeStuSH6oHxCmy4AiOgpCUxwFwbBvFOlvVGJcbYq09nQPGU0s f25MDPkjgFvXoddyv/fmXQNICJVoAEMX6tJizQBARyaX4Xi9YJlcvl3E5r/tMWvV 57Q+MZWABNbVVg7E4i3g9eruDXJFIaOlykILzm5vvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudegledguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Apr 2024 05:57:30 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 4acda0eb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 9 Apr 2024 09:57:21 +0000 (UTC) Date: Tue, 9 Apr 2024 11:57:27 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Josh Steadmon , Luca Milanesio , Eric Sunshine , Junio C Hamano Subject: [PATCH 1/2] t0610: make `--shared=` tests reusable Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We have two kinds of `--shared=` tests, one for git-init(1) and one for git-pack-refs(1). Merge them into a reusable function such that we can easily add additional testcases with different umasks and flags for the `--shared=` switch. Signed-off-by: Patrick Steinhardt --- t/t0610-reftable-basics.sh | 57 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh index 686781192e..a3269c20e0 100755 --- a/t/t0610-reftable-basics.sh +++ b/t/t0610-reftable-basics.sh @@ -96,23 +96,46 @@ test_expect_perms () { esac } -for umask in 002 022 -do - test_expect_success POSIXPERM 'init: honors core.sharedRepository' ' +test_expect_reftable_perms () { + local umask="$1" + local shared="$2" + local expect="$3" + + test_expect_success POSIXPERM "init: honors --shared=$shared with umask $umask" ' test_when_finished "rm -rf repo" && ( umask $umask && - git init --shared=true repo && + git init --shared=$shared repo && test 1 = "$(git -C repo config core.sharedrepository)" ) && - test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list && + test_expect_perms "$expect" repo/.git/reftable/tables.list && for table in repo/.git/reftable/*.ref do - test_expect_perms "-rw-rw-r--" "$table" || + test_expect_perms "$expect" "$table" || return 1 done ' -done + + test_expect_success POSIXPERM "pack-refs: honors --shared=$shared with umask $umask" ' + test_when_finished "rm -rf repo" && + ( + umask $umask && + git init --shared=$shared repo && + test_commit -C repo A && + test_line_count = 3 repo/.git/reftable/tables.list + ) && + git -C repo pack-refs && + test_expect_perms "$expect" repo/.git/reftable/tables.list && + for table in repo/.git/reftable/*.ref + do + test_expect_perms "$expect" "$table" || + return 1 + done + ' +} + +test_expect_reftable_perms 002 true "-rw-rw-r--" +test_expect_reftable_perms 022 true "-rw-rw-r--" test_expect_success 'clone: can clone reftable repository' ' test_when_finished "rm -rf repo clone" && @@ -371,26 +394,6 @@ test_expect_success 'pack-refs: does not prune non-table files' ' test_path_is_file repo/.git/reftable/garbage ' -for umask in 002 022 -do - test_expect_success POSIXPERM 'pack-refs: honors core.sharedRepository' ' - test_when_finished "rm -rf repo" && - ( - umask $umask && - git init --shared=true repo && - test_commit -C repo A && - test_line_count = 3 repo/.git/reftable/tables.list - ) && - git -C repo pack-refs && - test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list && - for table in repo/.git/reftable/*.ref - do - test_expect_perms "-rw-rw-r--" "$table" || - return 1 - done - ' -done - test_expect_success 'packed-refs: writes are synced' ' test_when_finished "rm -rf repo" && git init repo &&