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 && From patchwork Tue Apr 9 09:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13622100 Received: from wfhigh8-smtp.messagingengine.com (wfhigh8-smtp.messagingengine.com [64.147.123.159]) (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 579A182D62 for ; Tue, 9 Apr 2024 09:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656659; cv=none; b=Cya5Q0O0+w1YCznT/77l75T/50VRi6OV4VDdNV48uAnSW95jduaiD5KD2Mt35X5zzqbgG+5a3QH2cyo8FAPSA1m0EDbX7/8iVJQnFCMyU/vuXrEEzSfzjeCGljDSysAMiOfhky/JUw/RlADl+Yo+Utu+6jXy4VPmT+6ELVblH50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656659; c=relaxed/simple; bh=Jvv3w/m9ZBENvpZYlW1kP6Y2rEEX6QHvqoznvSwP6oc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IgVf4a/ZcQ+XcSnClvGdCTTnigMN0SJdOXs71rmZrCVpkFUcxunqjUF6Ji/FwvjCuxAYhFmLljn3ArwA2F/9fz3gZ8RnWcGP5YVXYMPwekkXNa0/MyUzRdhyhK+xzT+JwrMwB7JCzJsElNHdqLbzZin1xIZesCQcpt18d2Ytgzo= 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=iz6MVXCS; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sllzSX0X; arc=none smtp.client-ip=64.147.123.159 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="iz6MVXCS"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sllzSX0X" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.west.internal (Postfix) with ESMTP id 168B6180010D; Tue, 9 Apr 2024 05:57:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 09 Apr 2024 05:57:37 -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=1712656656; x=1712743056; bh=bA/iDYX+W9 PfoMFGcyRgqOHaAbgGUfKgt5wfG+J1C60=; b=iz6MVXCSsBJAO6jvnEyM4frn/c JU4dmQpIeWbZAn2JDC/OqTxsV9+gCPyHwmYVit3kekYYlalUVl6HVT77q0RpS/Wa Xwomo4hYQYjtPk6VmXOlJEMyfT86mNS/mQhn6sauJYVwlQiofwAN+Afs8ezYmGcH bWZ8X1I8rMgeKisuvsbim6J1+FQUQEpAG72LgCTiNaegdwk0cAssG7jMFbSUuEGo ro3SfwlfAnwltXq9u1rGd1mZDbNHHMkMMb8VWQ06MA/xdxlhj66+Xmd2xqyJISqy V0Us9voPr+pp8yzv25iM2mVgEj17s8gw/y6Gcd4GSERCyWH8GCDu7xltMxAw== 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=1712656656; x=1712743056; bh=bA/iDYX+W9PfoMFGcyRgqOHaAbgG UfKgt5wfG+J1C60=; b=sllzSX0XcCbdQBohTG9ne7qliaQ9bXjr7Bv/T0VIxbDv 9wdgqXsiLlFgGSvnxACMzIRx6gc86PTlYezuVPxVv8qGbl8wxmTNScHdnSBr6q6a CR9KMVriPwIFCiN6j6vvCbwXnA5Usen7kdNs8sXBugAMrRKT3NA8Sl/UFiQx0L+1 +9zZoBTGmtH2azKQQurJvLu9+IMCYnPJj5eHUhPt7TDPnK7G3f/ZS+bYFhSdU3hU 8nuvfbddoZHJGXXPw5EM/1ArVm0oD2aRV0A9CYA42a5jJ2kpNCm3O0sjXg1eSFY2 B/sxMOP515MWgeI7L2DjJ9szzF7MyoDPQk08SiPSlQ== 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:34 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 53df742f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 9 Apr 2024 09:57:26 +0000 (UTC) Date: Tue, 9 Apr 2024 11:57:32 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Josh Steadmon , Luca Milanesio , Eric Sunshine , Junio C Hamano Subject: [PATCH 2/2] t0610: execute git-pack-refs(1) with specified umask 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: The tests for git-pack-refs(1) with the `core.sharedRepository` config execute git-pack-refs(1) outside of the shell that has the expected umask set. This is wrong because we want to test the behaviour of that command with different umasks. The issue went unnoticed because most distributions have a default umask of 0022, and we only ever test with `--shared=true`, which re-adds the group write bit. Fix the issue by moving git-pack-refs(1) into the umask'd shell and add a bunch of test cases that exercise behaviour more thoroughly. Note that we drop the check for whether `core.sharedRepository` was set to the correct value to make the test setup a bit easier. We should be able to rely on git-init(1) doing its thing correctly. Furthermore, to help readability, we convert tests that pass `--shared=true` to instead pass the equivalent `--shared=group`. Signed-off-by: Patrick Steinhardt --- t/t0610-reftable-basics.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh index a3269c20e0..8ffecefadc 100755 --- a/t/t0610-reftable-basics.sh +++ b/t/t0610-reftable-basics.sh @@ -105,8 +105,7 @@ test_expect_reftable_perms () { test_when_finished "rm -rf repo" && ( umask $umask && - git init --shared=$shared repo && - test 1 = "$(git -C repo config core.sharedrepository)" + git init --shared=$shared repo ) && test_expect_perms "$expect" repo/.git/reftable/tables.list && for table in repo/.git/reftable/*.ref @@ -122,9 +121,9 @@ test_expect_reftable_perms () { umask $umask && git init --shared=$shared repo && test_commit -C repo A && - test_line_count = 3 repo/.git/reftable/tables.list + test_line_count = 3 repo/.git/reftable/tables.list && + git -C repo pack-refs ) && - git -C repo pack-refs && test_expect_perms "$expect" repo/.git/reftable/tables.list && for table in repo/.git/reftable/*.ref do @@ -134,8 +133,17 @@ test_expect_reftable_perms () { ' } -test_expect_reftable_perms 002 true "-rw-rw-r--" -test_expect_reftable_perms 022 true "-rw-rw-r--" +test_expect_reftable_perms 002 umask "-rw-rw-r--" +test_expect_reftable_perms 022 umask "-rw-r--r--" +test_expect_reftable_perms 027 umask "-rw-r-----" + +test_expect_reftable_perms 002 group "-rw-rw-r--" +test_expect_reftable_perms 022 group "-rw-rw-r--" +test_expect_reftable_perms 027 group "-rw-rw----" + +test_expect_reftable_perms 002 world "-rw-rw-r--" +test_expect_reftable_perms 022 world "-rw-rw-r--" +test_expect_reftable_perms 027 world "-rw-rw-r--" test_expect_success 'clone: can clone reftable repository' ' test_when_finished "rm -rf repo clone" &&