From patchwork Mon Feb 3 06:29:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956822 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 DAC0E1D63DD for ; Mon, 3 Feb 2025 06:29:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564188; cv=none; b=KQyX7wTYxRuGIZwwtpF5GUzdaqRdXhohtP3mfC/3+5olpMSzwnky5YDHFQJjO2zmGMMlwyH+PwAJOyY69lmyuGRQy3jSmH6ls8AidibPtfgzVeKvEJKk/fbxtxxDnUdDQsgLbgbnVDqjDk2OQ7p0Qy39gVAi0+StNec59JvbzR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564188; c=relaxed/simple; bh=VGYVGVzADvFJi920HxjTNNlr/xldFe1DUy6hDcwHgfY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f6bT+zhUw9UJGWTG59BhScJMRY2qPGyV9s12JgrSpiGSPU+vZ5ZRVuT5NR3tvmAFp/jdnA7HNxWo9NCyOUzmeQya6jmSaNjnSoW2sKKQtZmVAOTEPxglKmmW4+oMvLT0fdGZy2fcYU8cAtMTBx9aPH2tZ9+A+jYMi3CxraJFV4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=m3bSWMh2; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=0uTb4Yuj; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="m3bSWMh2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="0uTb4Yuj" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id C712B1140174; Mon, 3 Feb 2025 01:29:45 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Mon, 03 Feb 2025 01:29:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564185; x=1738650585; bh=2EM6yGfIcRKfHB0cAvM0gQt5x0ZGXVK55FzZP43vO/Y=; b= m3bSWMh2Xr02/yZ3eZuaQ9ZeIBLvZACg2LAlWbzUfQccXgUPeIATwUSNQ3j4fyQq 3VcgvHAgqYXKozhJrs7xfIy4I9jmjV9wYBMg0Cm3oQP700v4xB5E6W73IodVW+BQ 3pb7kGGFzxU2hvH5swIZOD1xMrkGwusK9kZVvl22PgYmGBsO1ZTitdv4vyX/jI8x 6Fk8NY4bjrS6sBNqkDXWX7Zj+TNyB3TXTIhZFQ+wT7816kSLUjul5Nn9Bvs/SAtu V2aAV6jx0lX0V1j0m5cWjQTzgbML1Ra2tC2PdUDWTseG5E3kpxnhp7USK5BEzf9n prQMLW6yKGa9TtrUHpu32g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564185; x= 1738650585; bh=2EM6yGfIcRKfHB0cAvM0gQt5x0ZGXVK55FzZP43vO/Y=; b=0 uTb4Yuj4gpPXaCG/efUg6hAgIqBlaqQcaXyVTcm6J5xhTNWyaql1ulgSSDi6qEm2 9oBQ0IcEzmGQcF2R9H3Tnn99q4t60+vzLj9soUhzIcCdOOjBg1aeyZRwPX4Co/4o h9uFDR4+61FT6rmFp3O2wz3DrzRcXRY6kopTaEUvFqaXMbdzZTnDD56kXa/51STW /gN/HwnnhbQkBTtkkC9FBug8qbtudtEbyIfz9bPidu4/QYQThZTrl03zDx+8uS+O YIFypACrO84jUsr/p7dRZ1SgkwGv6I0cHLVgqpi52/KDRPcytRc+fxVokfXYDH9w TeiDw+3zHArKl/llwGP6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepffeuiedujedvkeehuedvkeefffeivdeuleetkedu heejteekgedvudfgtdfgieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepghhithhsthgvrhesphhosghogidrtghomhdprh gtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhu nhhshhhinhgvsehsuhhnshhhihhnvggtohdrtghomhdprhgtphhtthhopeiihhhihihouh drjhigsegrlhhisggrsggrqdhinhgtrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:44 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id cee124e5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:42 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:31 +0100 Subject: [PATCH v5 1/8] t5504: modernize test by moving heredocs into test bodies Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-1-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 We have several heredocs in t5504 located outside of any particular test bodies. Move these into the test bodies to match our modern coding style. Signed-off-by: Patrick Steinhardt --- t/t5504-fetch-receive-strict.sh | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index e273ab29c7..58074506c5 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -64,12 +64,6 @@ test_expect_success 'fetch with transfer.fsckobjects' ' ) ' -cat >exp <exp <<-\EOF && + To dst + ! refs/heads/main:refs/heads/test [remote rejected] (missing necessary objects) + Done + EOF test_must_fail git push --porcelain dst main:refs/heads/test >act && test_cmp exp act ' @@ -94,11 +93,6 @@ test_expect_success 'push with !receive.fsckobjects' ' test_cmp exp act ' -cat >exp <exp <<-\EOF && + To dst + ! refs/heads/main:refs/heads/test [remote rejected] (unpacker error) + EOF test_must_fail git push --porcelain dst main:refs/heads/test >act && test_cmp exp act ' @@ -129,15 +127,14 @@ test_expect_success 'repair the "corrupt or missing" object' ' git fsck ' -cat >bogus-commit < 1234567890 +0000 - -This commit object intentionally broken -EOF - test_expect_success 'setup bogus commit' ' + cat >bogus-commit <<-EOF && + tree $EMPTY_TREE + author Bugs Bunny 1234567890 +0000 + committer Bugs Bunny 1234567890 +0000 + + This commit object intentionally broken + EOF commit="$(git hash-object --literally -t commit -w --stdin X-Patchwork-Id: 13956823 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 D987C1D86C3 for ; Mon, 3 Feb 2025 06:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564189; cv=none; b=VBYlGSCR/oWgCCt7lUybT+ckLmYte+V7Wwu7N7hg0I1x2FQw0FEyFeX5p7JFbE+ch18hJnAztnfGeicSD0+wZhR7rS50Extu98l0ypJ6G5FDugTJDYxT4v1s/rY55zzpTnEwIGKTOlZP3X3WVB3uc0IdOEqMX2QTXHZ/kmEbaQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564189; c=relaxed/simple; bh=pKLx5AbYFplEym75aQ36nZRYMN4gAJi9rTE1bVyXkxE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mNEGEPAWBw4SsE/W0BWtNPMW9EZbFRetSq5q980JENPB5vxtYdW6VdY30cYV9W61dzvfXHYS84V6I/bvQ/y4lVpTiKDgKl4IixCzLSga1muzCVv3+iDxJZfF7wXPXaw3qsS1HUG8PVCOnbhzqawyInjSrRxX2F/WbhxhUjkoyhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=YG4+DTvi; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Vz2ZDk34; arc=none smtp.client-ip=103.168.172.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="YG4+DTvi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Vz2ZDk34" Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id E28401380601; Mon, 3 Feb 2025 01:29:46 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Mon, 03 Feb 2025 01:29:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564186; x=1738650586; bh=8rOCIbgznNeydvWMf/Vh1x1sEOIcV6oLc7deQU33H0E=; b= YG4+DTviKTd0tIMt+2XKbkVwpHBqYEAFeLGqqfOZEzYfPtQaUAeadk5mFtQV4G41 85bUH42aMS44WZZynIOFz7iUOUKlakbHWVWIASPCqnA8S36W2e9AalAJbdILXRzW Hjl9bU2EuEpFo3b5eUbyiMIxr05a3aVPS2qad0Ko5odVsVToaYetugFccnl7cwP7 U5k1rg8uIbt0V+eDIzYsW/VkQxVeRK8FFu/7iO5aCjzhCR4ulEMeHwcfFbpTnUoM XDDbwo/fnkgVJqFDwwYnbaVPGPeaK2PeuLGNEDgfxVl9D8rLZ0MIn9Y4WiZUejRh Wu2dNz82lkC93f5SBakU5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564186; x= 1738650586; bh=8rOCIbgznNeydvWMf/Vh1x1sEOIcV6oLc7deQU33H0E=; b=V z2ZDk34yxp9nFWyMp4C0sLkziCWmj9qX9RpDdwbcqKMOgAJKYEESspEbbyMdol/5 kzicgzamKqr6sysfeD8JyAmJWNeDTuubTkhIWMiStWnoR9f3hLqrjlehCBXZhGxC +ssjMfYpYAgNdjGbZjmpq5Um2QhTCmCNkJTeYvqBdnWkwd/gunSyz6fz2vZwDYfl AW3ViDkI5ihs4/DaEJI1XpJnEa6NPnawFBTyFYDfXr694ky0fVQg67i3cQWhxe0b BCX3TLeON+Qxm4eaKiObK2DR2x1a8ckY5CXetXXs3+CvwPqnnEsm39B/+kyn8ekK Js4wK7m+i5pgzQbGjwZZw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepvdejteetffehjeevledvffffffevhfffieejffel iefghfevieegffdvhedtkedunecuffhomhgrihhnpehhthhtphgurdhshhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm pdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeiihh hihihouhdrjhigsegrlhhisggrsggrqdhinhgtrdgtohhmpdhrtghpthhtohepghhithhs thgvrhesphhosghogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtohepshhunhhshhhinhgvsehsuhhnshhhihhnvggtohdrtgho mh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:45 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6c763354 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:43 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:32 +0100 Subject: [PATCH v5 2/8] t5548: refactor to reuse setup_upstream() function Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-2-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 From: Jiang Xin Refactor the function setup_upstream_and_workbench(), extracting create_upstream_template() and setup_upstream() from it. The former is used to create the upstream repository template, while the latter is used to rebuild the upstream repository and will be reused in subsequent commits. To ensure that setup_upstream() works properly in both local and HTTP protocols, the HTTP settings have been moved to the setup_upstream() and setup_upstream_and_workbench() functions. Signed-off-by: Jiang Xin Signed-off-by: Patrick Steinhardt --- t/t5548-push-porcelain.sh | 83 ++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 6282728eaf..1bf4d48cd9 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -54,29 +54,65 @@ format_and_save_expect () { sed -e 's/^> //' -e 's/Z$//' >expect } +create_upstream_template () { + git init --bare upstream-template.git && + git clone upstream-template.git tmp_work_dir && + create_commits_in tmp_work_dir A B && + ( + cd tmp_work_dir && + git push origin \ + $B:refs/heads/main \ + $A:refs/heads/foo \ + $A:refs/heads/bar \ + $A:refs/heads/baz + ) && + rm -rf tmp_work_dir +} + +setup_upstream () { + if test $# -ne 1 + then + BUG "location of upstream repository is not provided" + fi && + rm -rf "$1" && + if ! test -d upstream-template.git + then + create_upstream_template + fi && + git clone --mirror upstream-template.git "$1" && + # The upstream repository provides services using the HTTP protocol. + if ! test "$1" = "upstream.git" + then + git -C "$1" config http.receivepack true + fi +} + setup_upstream_and_workbench () { + if test $# -ne 1 + then + BUG "location of upstream repository is not provided" + fi + upstream="$1" + # Upstream after setup : main(B) foo(A) bar(A) baz(A) # Workbench after setup : main(A) test_expect_success "setup upstream repository and workbench" ' - rm -rf upstream.git workbench && - git init --bare upstream.git && - git init workbench && - create_commits_in workbench A B && + setup_upstream "$upstream" && + rm -rf workbench && + git clone "$upstream" workbench && ( cd workbench && + git update-ref refs/heads/main $A && # Try to make a stable fixed width for abbreviated commit ID, # this fixed-width oid will be replaced with "". git config core.abbrev 7 && - git remote add origin ../upstream.git && - git update-ref refs/heads/main $A && - git push origin \ - $B:refs/heads/main \ - $A:refs/heads/foo \ - $A:refs/heads/bar \ - $A:refs/heads/baz + git config advice.pushUpdateRejected false ) && - git -C "workbench" config advice.pushUpdateRejected false && - upstream=upstream.git + # The upstream repository provides services using the HTTP protocol. + if ! test "$upstream" = "upstream.git" + then + git -C workbench remote set-url origin "$HTTPD_URL/smart/upstream.git" + fi ' } @@ -88,7 +124,7 @@ run_git_push_porcelain_output_test() { ;; file) PROTOCOL="builtin protocol" - URL_PREFIX="\.\." + URL_PREFIX=".*" ;; esac @@ -247,10 +283,8 @@ run_git_push_porcelain_output_test() { ' } -# Initialize the upstream repository and local workbench. -setup_upstream_and_workbench +setup_upstream_and_workbench upstream.git -# Run git-push porcelain test on builtin protocol run_git_push_porcelain_output_test file ROOT_PATH="$PWD" @@ -258,21 +292,10 @@ ROOT_PATH="$PWD" . "$TEST_DIRECTORY"/lib-httpd.sh . "$TEST_DIRECTORY"/lib-terminal.sh start_httpd - -# Re-initialize the upstream repository and local workbench. -setup_upstream_and_workbench - -test_expect_success "setup for http" ' - git -C upstream.git config http.receivepack true && - upstream="$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" && - mv upstream.git "$upstream" && - - git -C workbench remote set-url origin $HTTPD_URL/smart/upstream.git -' - setup_askpass_helper -# Run git-push porcelain test on HTTP protocol +setup_upstream_and_workbench "$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" + run_git_push_porcelain_output_test http test_done From patchwork Mon Feb 3 06:29:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956824 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 D98191D7E42 for ; Mon, 3 Feb 2025 06:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564189; cv=none; b=UqOD+F23JcrVdGuHvYgOsbuxvU60NRR3FXKUktxij4PHQ1V0HT8L9PKW211iRWrWLKPOdULQbptevsXUU6HOM+Km3KLs+kjM1bYNX7bfXqmPvUHw2kt23t6rjpMZB1FCRVFXaVfDV9MAnZ4MZkyYFalb4K0JK80CuH4tIBQTKuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564189; c=relaxed/simple; bh=gp9gr6f2CtR6JbaxnktAQHv/7LHu64nW4DNFKazr9og=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kry2zM1Jc6fo5umf1/vqDLqD5dvWv5bmI/5ZSzeeKKSBkhFRaY1Ckn1SW61niSrTGvuxJS2aWawEt4pIzLNqmvmMQ51s0YUWgqvcodFTNUmtOCemiT2CUdVQslQBaTXAgAnHua8B3HnaCkp+3CnFhAQT5Fxv4F+YG+K6ltIIXcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=OMccnbbr; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=of2sFEkM; arc=none smtp.client-ip=103.168.172.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="OMccnbbr"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="of2sFEkM" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 08AF3138063E; Mon, 3 Feb 2025 01:29:47 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Mon, 03 Feb 2025 01:29:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564187; x=1738650587; bh=3mQwCzky9tzOZuX4icIW65uRoMfQop0ECEBd+QCpS7Y=; b= OMccnbbrLj/eypKHoNbIXRwIPAM3QJLh2X9xEPW1kvUjwe662hQ2N445pZB1rhaf kXnxBFFC/A5h+nSuNSvdNAiztKmqt6Fw2RHBcAS8+o33H7uTunHQlbayiNYNCFd0 8016F2fLKmIBxlQvYAST8knt2A1+ivzvH2PYtqXgVL3u5zF5gOJ2nfreND809e6S gjLrRaCwt6wiEBPMXOrzU/KXxetHiqvKZS+SKX7iYNmmRV6KVJz+Ev1Bia/GHSZw y6meojv0DjLs16+mC35vUXdgr6lAmKT1j6PPUM3VEmPw6wVdjbYelzg2H/wamJL3 qjn1AFILX57xKT2KgDup/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564187; x= 1738650587; bh=3mQwCzky9tzOZuX4icIW65uRoMfQop0ECEBd+QCpS7Y=; b=o f2sFEkMxgFtb4gGvqZVrCzIbvY8OqDhyqRWymTs8if4ph5Eir0r58CxJ+1tBls/n bUIK5YH54OHlaRqTV4M0oTRxZ+PIO8+4Zfu9Vqi2rISjtaSgMcx28X/EOrPZsXA9 EjSBsxpYwx7vtjkZEpQcqkB6HbQpDmEnTS0S7frFYNcuqrf5EQNaUKDwg79JCuNO q47kcK4JEU93D6zBfq6mb+G+8BeqazvgAY7hZG/89rUxfbpBWSeJC8C/ZaPeP8sx F5bfflG99HWTLmiApwki8ruV2ghbNeiDj7Z6Wlv0JWV01sSvBKgnNZkcKKs7UlrO pQYSznBFfP3Z1SOTz605g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepffeuiedujedvkeehuedvkeefffeivdeuleetkedu heejteekgedvudfgtdfgieelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepghhithhsthgvrhesphhosghogidrtghomhdprh gtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhu nhhshhhinhgvsehsuhhnshhhihhnvggtohdrtghomhdprhgtphhtthhopeiihhhihihouh drjhigsegrlhhisggrsggrqdhinhgtrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:45 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 88390498 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:44 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:33 +0100 Subject: [PATCH v5 3/8] t5548: refactor test cases by resetting upstream Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-3-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 From: Jiang Xin Refactor the test cases with the following changes: - Calling setup_upstream() to reset upstream after running each test case. - Change the initial branch tips of the workspace to reduce the branch setup operations in the workspace. - Reduced the two steps of setting up and cleaning up the pre-receive hook by moving the operations into the corresponding test case, Signed-off-by: Jiang Xin Signed-off-by: Patrick Steinhardt --- t/t5548-push-porcelain.sh | 149 +++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 82 deletions(-) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 1bf4d48cd9..f9aeb5a9d9 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -94,8 +94,8 @@ setup_upstream_and_workbench () { fi upstream="$1" - # Upstream after setup : main(B) foo(A) bar(A) baz(A) - # Workbench after setup : main(A) + # Upstream after setup: main(B) foo(A) bar(A) baz(A) + # Workbench after setup: main(A) baz(A) next(A) test_expect_success "setup upstream repository and workbench" ' setup_upstream "$upstream" && rm -rf workbench && @@ -103,6 +103,8 @@ setup_upstream_and_workbench () { ( cd workbench && git update-ref refs/heads/main $A && + git update-ref refs/heads/baz $A && + git update-ref refs/heads/next $A && # Try to make a stable fixed width for abbreviated commit ID, # this fixed-width oid will be replaced with "". git config core.abbrev 7 && @@ -131,19 +133,14 @@ run_git_push_porcelain_output_test() { # Refs of upstream : main(B) foo(A) bar(A) baz(A) # Refs of workbench: main(A) baz(A) next(A) # git-push : main(A) NULL (B) baz(A) next(A) - test_expect_success "porcelain output of successful git-push ($PROTOCOL)" ' - ( - cd workbench && - git update-ref refs/heads/main $A && - git update-ref refs/heads/baz $A && - git update-ref refs/heads/next $A && - git push --porcelain --force origin \ - main \ - :refs/heads/foo \ - $B:bar \ - baz \ - next - ) >out && + test_expect_success ".. git-push --porcelain --force ($PROTOCOL)" ' + test_when_finished "setup_upstream \"$upstream\"" && + git -C workbench push --porcelain --force origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && make_user_friendly_and_stable_output actual && format_and_save_expect <<-EOF && > To @@ -167,115 +164,103 @@ run_git_push_porcelain_output_test() { test_cmp expect actual ' - # Refs of upstream : main(A) bar(B) baz(A) next(A) - # Refs of workbench: main(B) bar(A) baz(A) next(A) - # git-push : main(B) bar(A) NULL next(A) - test_expect_success "atomic push failed ($PROTOCOL)" ' - ( - cd workbench && - git update-ref refs/heads/main $B && - git update-ref refs/heads/bar $A && - test_must_fail git push --atomic --porcelain origin \ - main \ - bar \ - :baz \ - next - ) >out && + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git push --porcelain --atomic ($PROTOCOL)" ' + test_when_finished "setup_upstream \"$upstream\"" && + test_must_fail git -C workbench push --porcelain --atomic origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && make_user_friendly_and_stable_output actual && format_and_save_expect <<-EOF && - To - > = refs/heads/next:refs/heads/next [up to date] - > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) - > ! (delete):refs/heads/baz [rejected] (atomic push failed) - > ! refs/heads/main:refs/heads/main [rejected] (atomic push failed) - Done + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > ! :refs/heads/bar [rejected] (atomic push failed) + > ! (delete):refs/heads/foo [rejected] (atomic push failed) + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > ! refs/heads/next:refs/heads/next [rejected] (atomic push failed) + > Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output actual && cat >expect <<-EOF && - refs/heads/bar + refs/heads/bar refs/heads/baz - refs/heads/main - refs/heads/next + refs/heads/foo + refs/heads/main EOF test_cmp expect actual ' - test_expect_success "prepare pre-receive hook ($PROTOCOL)" ' - test_hook --setup -C "$upstream" pre-receive <<-EOF - exit 1 + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. pre-receive hook declined ($PROTOCOL)" ' + test_when_finished "rm -f \"$upstream/hooks/pre-receive\" && + setup_upstream \"$upstream\"" && + test_hook --setup -C "$upstream" pre-receive <<-EOF && + exit 1 EOF - ' - - # Refs of upstream : main(A) bar(B) baz(A) next(A) - # Refs of workbench: main(B) bar(A) baz(A) next(A) - # git-push : main(B) bar(A) NULL next(A) - test_expect_success "pre-receive hook declined ($PROTOCOL)" ' - ( - cd workbench && - git update-ref refs/heads/main $B && - git update-ref refs/heads/bar $A && - test_must_fail git push --porcelain --force origin \ - main \ - bar \ - :baz \ - next - ) >out && + test_must_fail git -C workbench push --porcelain --force origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && make_user_friendly_and_stable_output actual && format_and_save_expect <<-EOF && - To - > = refs/heads/next:refs/heads/next [up to date] - > ! refs/heads/bar:refs/heads/bar [remote rejected] (pre-receive hook declined) - > ! :refs/heads/baz [remote rejected] (pre-receive hook declined) + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > ! :refs/heads/bar [remote rejected] (pre-receive hook declined) + > ! :refs/heads/foo [remote rejected] (pre-receive hook declined) > ! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined) - Done + > ! refs/heads/next:refs/heads/next [remote rejected] (pre-receive hook declined) + > Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output actual && cat >expect <<-EOF && - refs/heads/bar + refs/heads/bar refs/heads/baz - refs/heads/main - refs/heads/next + refs/heads/foo + refs/heads/main EOF test_cmp expect actual ' - test_expect_success "remove pre-receive hook ($PROTOCOL)" ' - rm "$upstream/hooks/pre-receive" - ' - - # Refs of upstream : main(A) bar(B) baz(A) next(A) - # Refs of workbench: main(B) bar(A) baz(A) next(A) - # git-push : main(B) bar(A) NULL next(A) - test_expect_success "non-fastforward push ($PROTOCOL)" ' + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) next(A) + test_expect_success ".. non-fastforward push ($PROTOCOL)" ' ( cd workbench && test_must_fail git push --porcelain origin \ main \ - bar \ - :baz \ next ) >out && make_user_friendly_and_stable_output actual && format_and_save_expect <<-EOF && - To - > = refs/heads/next:refs/heads/next [up to date] - > - :refs/heads/baz [deleted] - > refs/heads/main:refs/heads/main .. - > ! refs/heads/bar:refs/heads/bar [rejected] (non-fast-forward) - Done + > To + > * refs/heads/next:refs/heads/next [new branch] + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output actual && cat >expect <<-EOF && - refs/heads/bar + refs/heads/bar + refs/heads/baz + refs/heads/foo refs/heads/main refs/heads/next EOF From patchwork Mon Feb 3 06:29:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956825 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 2A1301D9A54 for ; Mon, 3 Feb 2025 06:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564190; cv=none; b=a5SvRjvBsuXG7vJUBAqY+FUWkTEvv/wpssc7l2PvVS+7/uTJUQwVZ5LNWq8d9MPlDyZd8kaLQ+BuftwTib5k7YrMS3x3yAdnus8VlK6piDJIr0nUAXPseGBp26VOmeyZLdF9qvwwZwpTigrwLJLy8i8bcbiUr7vurtZmStNEnI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564190; c=relaxed/simple; bh=FK+JBySU+E4cF1jULUXIRPkz1yRdw0jWDSSY7Gc/CWI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZQCl4RULeeizgU+/CbAbPnf+xB3O1WYwdLR3vvinwYcoF3SMlk8dqa+oOOO6C6vqCT67OYs93tIjUwOxy0q91vs7p3F53tDsuHdwRSh1cr4M4vN6yvVytoOnavfTuMBXPd8MOGsrE+V7mamFnqBjBwJyBG5sXRmx6L0Zx3zhBbw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=RfxPSRZw; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UEWF29K/; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="RfxPSRZw"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UEWF29K/" Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 27AAD114017A; Mon, 3 Feb 2025 01:29:48 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Mon, 03 Feb 2025 01:29:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564188; x=1738650588; bh=fAt7v//KG7U43weF+K6vSqkstjXvLbyLNtEAxS0OY+4=; b= RfxPSRZwS/ZkpQAI1ucRnT3k6BGvVFEga2gasI7Ajlzxl8LY7cLd9FZStEa0ZHIr U0fXKs91DDMkGr2TZd5w9B4tLcLI3n1b2UYvO2gp6PIz0GFSQqUSaSs2+j4cezfE 5OGK2A4Zfc8ttSENkwXwcXxZNzEEzVuqkldx71agAdqjImUq/H72vIhJfUBK5ChJ PMFJIHkn9W6vl9pK1ECrispFvPdnl9gNUWEeT/DBoStWrhuHPkffXi6c25A3zA+9 /J83ERaN5D/w/ogtPRYY0uQKHa+5cZdKaphYjJTjFAMXEM20zCVcVB+QsmRyuaM5 JNKe79X14kVV/yEYw6aimA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564188; x= 1738650588; bh=fAt7v//KG7U43weF+K6vSqkstjXvLbyLNtEAxS0OY+4=; b=U EWF29K/edcoJQrm9lj20p4oj2mfs93GK1OjDHWnLVSsCSJpcsu6HimSXNzNnYhme Nktk1ivabUam6fzDfbc61lXJ9DpVNMlM9AY4gStHoBtwWnWUv+F+ffmG26T1IUJF sgS9LPE6CgjW9vB3N/dsglFG0W1+mmhP5tTeJHqNwyjSWdOFVjTHMZRh4BniZCFR yLipv9I0WLhoBlajWO0fVmwIJDbglC3aCZMIHgcBVEEjg45Z485u1Raabfd7f6Rr GHtDAGS+/n1MDay6BPF+BjMf9LdtK5O2kLmPRwtsiLSdoFHeCIyhcwJE1aLbVQQZ Uui4z5gi6XEtT9kf2I5Jw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepffeuiedujedvkeehuedvkeefffeivdeuleetkedu heejteekgedvudfgtdfgieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrgh dprhgtphhtthhopehgihhtshhtvghrsehpohgsohigrdgtohhmpdhrtghpthhtohepshhu nhhshhhinhgvsehsuhhnshhhihhnvggtohdrtghomhdprhgtphhtthhopeiihhhihihouh drjhigsegrlhhisggrsggrqdhinhgtrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:47 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6f07915d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:45 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:34 +0100 Subject: [PATCH v5 4/8] t5548: add new porcelain test cases Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-4-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 Add two more test cases exercising git-push(1) with `--procelain`, one exercising a non-atomic and one exercising an atomic push. Based-on-patch-by: Jiang Xin Signed-off-by: Patrick Steinhardt --- t/t5548-push-porcelain.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index f9aeb5a9d9..5d724145d2 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -130,6 +130,40 @@ run_git_push_porcelain_output_test() { ;; esac + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git-push --porcelain ($PROTOCOL)" ' + test_when_finished "setup_upstream \"$upstream\"" && + test_must_fail git -C workbench push --porcelain origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-\EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > * refs/heads/next:refs/heads/next [new branch] + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > Done + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output actual && + cat >expect <<-EOF && + refs/heads/bar + refs/heads/baz + refs/heads/main + refs/heads/next + EOF + test_cmp expect actual + ' + # Refs of upstream : main(B) foo(A) bar(A) baz(A) # Refs of workbench: main(A) baz(A) next(A) # git-push : main(A) NULL (B) baz(A) next(A) @@ -240,6 +274,7 @@ run_git_push_porcelain_output_test() { # Refs of workbench: main(A) baz(A) next(A) # git-push : main(A) next(A) test_expect_success ".. non-fastforward push ($PROTOCOL)" ' + test_when_finished "setup_upstream \"$upstream\"" && ( cd workbench && test_must_fail git push --porcelain origin \ @@ -266,6 +301,39 @@ run_git_push_porcelain_output_test() { EOF test_cmp expect actual ' + + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git push --porcelain --atomic --force ($PROTOCOL)" ' + git -C workbench push --porcelain --atomic --force origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-\EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > + refs/heads/main:refs/heads/main ... (forced update) + > * refs/heads/next:refs/heads/next [new branch] + > Done + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output actual && + cat >expect <<-EOF && + refs/heads/bar + refs/heads/baz + refs/heads/main + refs/heads/next + EOF + test_cmp expect actual + ' } setup_upstream_and_workbench upstream.git From patchwork Mon Feb 3 06:29:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956827 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 2A1CA1D9A5F for ; Mon, 3 Feb 2025 06:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564192; cv=none; b=MM47cKMU/7cE7caOrXbFQg/HUGVdWRtU/LPrGMzPC3Aq15PrXxlpGRQYE3UurXDgeHOt8pRdmnq3hBCzfjtpi1fJeV3+cIGWSGcVt5nMQFE5ESvj2ZcZdNUyS7qLZEZyE0GqUhsp5OZRq4n0iZiloV5TFYjXLaC3DpPWwPkYOA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564192; c=relaxed/simple; bh=NTOmsGM8xmN034R/UPQV0gYJu8kqrbRheaWavpkJevI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E8d+6OBds+bbtlCoz5ITv7nI+2XPfBMTHM2Hts6Lff1FlK0ZP23MR/LFgPvO4hNheUeXtMmLu8/gtGw+zVyDvj73HSQL8zIrRcZOd4XU9o1l92JOYwQBdXgkCkyx02Bnd+P13GPdaee4V0rCZBRotTAyC5QHG5FXO8Ge5CmZDus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=rSp5fKWr; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eFTK4qPp; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="rSp5fKWr"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eFTK4qPp" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 44981114017B; Mon, 3 Feb 2025 01:29:48 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Mon, 03 Feb 2025 01:29:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564188; x=1738650588; bh=FxTLHu39iEYz0gDNNkWfppY6SFkGG4ioxu7UuR1iL0w=; b= rSp5fKWr4WlUAeTRl2NDiRrdS9t8cdvVbxA5CmjWVKdIvcJ4t4qBf94zum8Dyqfd QfUKO87D0A29ruZ/k57JZEzSefz9AuZxcmpIML4L3cSd9rQR5vj1LxmBeNwBbHF8 A7a/s4gIaurEIuoMVAZPGXckppNZ7rrfP1IL9er4HhhRc8sQNhTaKhLfgvvRx3Pi rEHsb1X/zWA5qJRQwMguMg0RTeg7BsRJesimTe77RNB30tkRiCEtEGIJwxdp9MuF 5OWgdHUVgnXCXUgur8Z87zjohAPu/qsA5smsF6t/Ddv+4kjDJy9mVB8QLZ7Egb1j 3sV3nDzSo/bblgYFhPj81g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564188; x= 1738650588; bh=FxTLHu39iEYz0gDNNkWfppY6SFkGG4ioxu7UuR1iL0w=; b=e FTK4qPpSuMR/Bh25wNdLxq9jVNF8xdOFHUjaYsQRk1CzW5K6yqpliNB3E2eFbWc/ ueBXk71XSlhznYYQUg1Oz5KzXOc1uVJhKKhg6cEZ33/TUWRF8ZpxUeWmJX+Rkm9A x40l+OwIVcz5cSglAcGlnMs9zSQwY6lcOBIj/DMAXUjy6iy9qEsnNYNCJ0qf8XGx 98dv0QRoG8FRnXE62ufs1Kg7VY3WpLyIwlM10KC0JjNsXzXaArg0GH8p2O4KPots 9pe7i5s/oJvwLl/guIgYFogVY7Bc/jASnPpEaJvW5/h9eiPGeK9QrNB5zjSXV+gR I4TdGFO1TKbujhBjYbEjA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepvdejteetffehjeevledvffffffevhfffieejffel iefghfevieegffdvhedtkedunecuffhomhgrihhnpehhthhtphgurdhshhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm pdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsuh hnshhhihhnvgesshhunhhshhhinhgvtghordgtohhmpdhrtghpthhtohepiihhihihohhu rdhjgiesrghlihgsrggsrgdqihhntgdrtghomhdprhgtphhtthhopehgihhtshhtvghrse hpohgsohigrdgtohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhr gh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:47 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 393ca998 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:46 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:35 +0100 Subject: [PATCH v5 5/8] t5548: add porcelain push test cases for dry-run mode Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-5-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 From: Jiang Xin New dry-run test cases: - git push --porcelain --dry-run - git push --porcelain --dry-run --force - git push --porcelain --dry-run --atomic - git push --porcelain --dry-run --atomic --force Signed-off-by: Jiang Xin Signed-off-by: Patrick Steinhardt --- t/t5548-push-porcelain.sh | 153 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 5d724145d2..4c19404ebe 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -336,10 +336,159 @@ run_git_push_porcelain_output_test() { ' } +run_git_push_dry_run_porcelain_output_test() { + case $1 in + http) + PROTOCOL="HTTP protocol" + URL_PREFIX="http://.*" + ;; + file) + PROTOCOL="builtin protocol" + URL_PREFIX=".*" + ;; + esac + + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git-push --porcelain --dry-run ($PROTOCOL)" ' + test_must_fail git -C workbench push --porcelain --dry-run origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > * refs/heads/next:refs/heads/next [new branch] + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > Done + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output actual && + cat >expect <<-EOF && + refs/heads/bar + refs/heads/baz + refs/heads/foo + refs/heads/main + EOF + test_cmp expect actual + ' + + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git-push --porcelain --dry-run --force ($PROTOCOL)" ' + git -C workbench push --porcelain --dry-run --force origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > + refs/heads/main:refs/heads/main ... (forced update) + > * refs/heads/next:refs/heads/next [new branch] + > Done + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output actual && + cat >expect <<-EOF && + refs/heads/bar + refs/heads/baz + refs/heads/foo + refs/heads/main + EOF + test_cmp expect actual + ' + + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # git-push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git-push --porcelain --dry-run --atomic ($PROTOCOL)" ' + test_must_fail git -C workbench push --porcelain --dry-run --atomic origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > ! :refs/heads/bar [rejected] (atomic push failed) + > ! (delete):refs/heads/foo [rejected] (atomic push failed) + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > ! refs/heads/next:refs/heads/next [rejected] (atomic push failed) + > Done + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output actual && + cat >expect <<-EOF && + refs/heads/bar + refs/heads/baz + refs/heads/foo + refs/heads/main + EOF + test_cmp expect actual + ' + + # Refs of upstream : main(B) foo(A) bar(A) baz(A) + # Refs of workbench: main(A) baz(A) next(A) + # push : main(A) NULL (B) baz(A) next(A) + test_expect_success ".. git-push --porcelain --dry-run --atomic --force ($PROTOCOL)" ' + git -C workbench push --porcelain --dry-run --atomic --force origin \ + main \ + :refs/heads/foo \ + $B:bar \ + baz \ + next >out && + make_user_friendly_and_stable_output actual && + format_and_save_expect <<-EOF && + > To + > = refs/heads/baz:refs/heads/baz [up to date] + > :refs/heads/bar .. + > - :refs/heads/foo [deleted] + > + refs/heads/main:refs/heads/main ... (forced update) + > * refs/heads/next:refs/heads/next [new branch] + > Done + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output actual && + cat >expect <<-EOF && + refs/heads/bar + refs/heads/baz + refs/heads/foo + refs/heads/main + EOF + test_cmp expect actual + ' +} + setup_upstream_and_workbench upstream.git run_git_push_porcelain_output_test file +setup_upstream_and_workbench upstream.git + +run_git_push_dry_run_porcelain_output_test file + ROOT_PATH="$PWD" . "$TEST_DIRECTORY"/lib-gpg.sh . "$TEST_DIRECTORY"/lib-httpd.sh @@ -351,4 +500,8 @@ setup_upstream_and_workbench "$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" run_git_push_porcelain_output_test http +setup_upstream_and_workbench "$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" + +run_git_push_dry_run_porcelain_output_test http + test_done From patchwork Mon Feb 3 06:29:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956826 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 5967E1DD9D1 for ; Mon, 3 Feb 2025 06:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564192; cv=none; b=UQi3KSDBSDGGSaoCizqQiOSFhGa7TjzpIuEOa8qTnXblq2VWPyhxAz60GpD4OUOnHvvXb+MMy4k9yvtnnGM4v9W+Nw8ICdhIceESrQ2XfMt/6bQUkWnV6cOq4XCGYriRjMzw7mB5yyi+BtJaOCMMH8LPpTPaJzSS3yJxvyD3qAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564192; c=relaxed/simple; bh=mAfvfkaxXwctFztc9Enha3jhagEGMfCWM5hVpe/MOfQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CohM4wMrT2gWFns0fqgyiukGaa0ztZQfXORE77OtX4r3OL1Kmp4/9ccybZqU2BSbls2JQM0otBYSjgMqKrSrRYxuIVMKeDXebuBJdaNXUXdzeYbWCKhfkH5vIDbgks+MvjeU8AvCLCSPmodoQ14gjPMOrOcBjofFxWAerfw6Z2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=KxVReAuo; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QxF+gUo0; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="KxVReAuo"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QxF+gUo0" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6C6581140172; Mon, 3 Feb 2025 01:29:49 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 03 Feb 2025 01:29:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564189; x=1738650589; bh=5E9W1XzpUM6PTz3Satza/4acrK933ru5QwjkJ8LUdgA=; b= KxVReAuoKUo3yHSxU4KW8ydgNSjdzQqDkjllIzX/LzZU6m9We6oQdejwHjcX4jRg LyL7R5CVmsD0dFrJyHMRjmJwr1EpvFEgCCAFhP6OIDC6+IkYgRBCqdv9BciFoWEz vGMRJw36LlEQrN66HXNrHElQnRfnGp9nH8eu1vdCuA3UaMb4XIEnsgB+AHa1dg35 rVKElHI5voN2uA7JyKgfuICWrhlGU9BAhxVTk2l9z/lXD16l+fFE1X98r03dyZA+ vZ6VwP3T5uW5H5ISJ/ozc7894qMjykrtwfVWa3Z2D5/+pJi6pYlWzB7tay695N4x 9eCqftWamoernKRH54uxaQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564189; x= 1738650589; bh=5E9W1XzpUM6PTz3Satza/4acrK933ru5QwjkJ8LUdgA=; b=Q xF+gUo0YHsnwrZU5voJGS6aq+eyFVtqF7Wgk/P2R4XCgOF4SaqG7J0DYqy/sOUAA 1TlwjG78QyL7QGfU7KiSRARDNTNKRfauwzytKbC0U6bk3KThrp0cidxjbGGSmt4Y y78wRB2znY+loKm/GBVD+aDtfYiO0aQxOaq5ic5/z5OfPfeny1/FN0gzErBP0Ur1 Z6mSwvqvs/IzOW1Mgo18+D0J+MsxcgMYmIEKGU/Dgnbowuwvo+ynpkOJvP6hE5eq 5/TFY2hlZrObo07aTjgXhswNglER53dpcEX/lBJLQ2x1O/mucVaGq/JGCU9la2iE r9Pgd9nj7bu+layzV7aeQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepffeuiedujedvkeehuedvkeefffeivdeuleetkedu heejteekgedvudfgtdfgieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrgh dprhgtphhtthhopehsuhhnshhhihhnvgesshhunhhshhhinhgvtghordgtohhmpdhrtghp thhtohepghhithhsthgvrhesphhosghogidrtghomhdprhgtphhtthhopeiihhhihihouh drjhigsegrlhhisggrsggrqdhinhgtrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:48 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 33159b3f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:47 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:36 +0100 Subject: [PATCH v5 6/8] send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS" Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-6-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 From: Jiang Xin The "push_refs" function in the transport_vtable is the handler for git-push operation. All the "push_refs" functions for different transports (protocols) should have the same behavior, but the behavior of "git_transport_push()" function for builtin_smart_vtable in "transport.c" (which calls "send_pack()" in "send-pack.c") differs from the handler of the HTTP protocol. The "push_refs()" function for the HTTP protocol which calls the "push_refs_with_push()" function in "transport-helper.c" will return 0 even when a bad REF_STATUS (such as REF_STATUS_REJECT_NONFASTFORWARD) was found. But "send_pack()" for Git smart protocol will return -1 for a bad REF_STATUS. We cannot ignore bad REF_STATUS directly in the "send_pack()" function, because the function is also used in "builtin/send-pack.c". So we add a new non-zero error code "SEND_PACK_ERROR_REF_STATUS" for "send_pack()". Ignore the specific error code in the "git_transport_push()" function to have the same behavior as "push_refs()" for HTTP protocol. Note that even though we ignore the error here, we'll ultimately still end up detecting that a subset of refs was not pushed in `transport_push()` because we eventually call `push_had_errors()` on the remote refs. Signed-off-by: Jiang Xin Signed-off-by: Patrick Steinhardt --- send-pack.c | 9 ++------- send-pack.h | 13 +++++++++++++ transport.c | 7 +++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/send-pack.c b/send-pack.c index 772c7683a0..4448c081cc 100644 --- a/send-pack.c +++ b/send-pack.c @@ -632,7 +632,7 @@ int send_pack(struct repository *r, reject_atomic_push(remote_refs, args->send_mirror); error("atomic push failed for ref %s. status: %d", ref->name, ref->status); - ret = args->porcelain ? 0 : -1; + ret = ERROR_SEND_PACK_BAD_REF_STATUS; goto out; } /* else fallthrough */ @@ -763,11 +763,6 @@ int send_pack(struct repository *r, if (ret < 0) goto out; - if (args->porcelain) { - ret = 0; - goto out; - } - for (ref = remote_refs; ref; ref = ref->next) { switch (ref->status) { case REF_STATUS_NONE: @@ -775,7 +770,7 @@ int send_pack(struct repository *r, case REF_STATUS_OK: break; default: - ret = -1; + ret = ERROR_SEND_PACK_BAD_REF_STATUS; goto out; } } diff --git a/send-pack.h b/send-pack.h index d256715681..c5ded2d200 100644 --- a/send-pack.h +++ b/send-pack.h @@ -13,6 +13,9 @@ struct repository; #define SEND_PACK_PUSH_CERT_IF_ASKED 1 #define SEND_PACK_PUSH_CERT_ALWAYS 2 +/* At least one reference has been rejected by the remote side. */ +#define ERROR_SEND_PACK_BAD_REF_STATUS 1 + struct send_pack_args { const char *url; unsigned verbose:1, @@ -36,6 +39,16 @@ struct option; int option_parse_push_signed(const struct option *opt, const char *arg, int unset); +/* + * Compute a packfile and write it to a file descriptor. The `fd` array needs + * to contain two file descriptors: `fd[0]` is the file descriptor used as + * input for the packet reader, whereas `fd[1]` is the file descriptor the + * packfile will be written to. + * + * Returns 0 on success, non-zero otherwise. Negative return values indicate a + * generic error, whereas positive return values indicate specific error + * conditions as documented with the `ERROR_SEND_PACK_*` constants. + */ int send_pack(struct repository *r, struct send_pack_args *args, int fd[], struct child_process *conn, struct ref *remote_refs, struct oid_array *extra_have); diff --git a/transport.c b/transport.c index 81ae8243b9..d064aff33e 100644 --- a/transport.c +++ b/transport.c @@ -934,6 +934,13 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re case protocol_v0: ret = send_pack(the_repository, &args, data->fd, data->conn, remote_refs, &data->extra_have); + /* + * Ignore the specific error code to maintain consistent behavior + * with the "push_refs()" function across different transports, + * such as "push_refs_with_push()" for HTTP protocol. + */ + if (ret == ERROR_SEND_PACK_BAD_REF_STATUS) + ret = 0; break; case protocol_unknown_version: BUG("unknown protocol version"); From patchwork Mon Feb 3 06:29:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956829 Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (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 9380F1D63DD for ; Mon, 3 Feb 2025 06:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564193; cv=none; b=baWRadP8hTo3esYCc6q4eMJuZ+sSwkVTYSKHgPkkTcUm5ogTuquPnZPytZtJUdS1Fss3Z53cuo5mp3ClzzvBjkzN4aBZEyDuPdTxhzBC9A6WMxxL45mojBzoDh2JJhwbMT7T+j6MIRLA3eQ2BXNnGxCu16luzvt52Upbkb3ahag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564193; c=relaxed/simple; bh=nFeC6BtcS+hOfHxDK3EtT6qcz0nydlJdwyNZA2ujWho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=APe5KhuXpUm+N4FKsqjs8QvuiQdG03Un67QtWltV0bQHgdI731w8OrpebM/X0i/Y3Iy44EJwdidBrdWfqg7ooXhq/TIU0Mp8AO7wVnZoyN3D2XjPYH7oTXT0sj6N8/vg94XiMWS09g18j8YUDVla4X6f29ojn4o53HerUzRgLD4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=cOpSgiTi; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=D6tMcWuz; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="cOpSgiTi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="D6tMcWuz" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 85CD61140173; Mon, 3 Feb 2025 01:29:49 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 03 Feb 2025 01:29:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564189; x=1738650589; bh=3y8btysFk6GGvvuftdxS6BVIk/hr4qyQagAbM69FupY=; b= cOpSgiTiW9H3hDKm3oAAg9X+ZH1lKh9tqe1ObY6LvvoC4dCBaUgfvCNSte26jF2z UWpUYfBSK2lvDUBkFBlb2estp7AAYLJoN9dH0H+R/ia5T3rRJMaEumvHMbpydlDk T3hvsz/DChVawPldmfciebEkrhReaBAc+87s/Waauq8SfmnWoceR6PsU/D6MX9Np 5r77usA3xLmT8qvNAWrjCZF6G2hQ9Nr3r8LzeTWTcq3vAIuFFWut5b2ZlIQ/63q1 uEerHJPo7K0nkGCxQDBWS4EO0xrNKExWufIJHBcch6/j+7vbbM3FDI5Dm8CkLHXX ANMv4Pjhab1L6eCUGAr4Vg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564189; x= 1738650589; bh=3y8btysFk6GGvvuftdxS6BVIk/hr4qyQagAbM69FupY=; b=D 6tMcWuzmXNAfDXy1oloDS5X2p8k9BMY5cZ/q14MEH19Jjv3CHz+Yy+OMmRkT2b4/ sKi8LwSSFyqbotuY2SSg/eh5t5PfCRaN1k+KmKN9ez51qZNCklo+3Hi41MWh9n9F rvlMM2ZaeJjNuL70i3goktGH7M2MfAfYaACqrj+tKpBVWQT79s/zH2ocjyqLvCie snpSSw48CKgYi9/V3boNgSepDvrzgj1l1+hIcjsBt6iD0t/G12hM9pTFt7Izn79F avOBPOgRoiQ/k03Dd6fpczXU5r6RiyjXlka0HEw2C90GfZNMGAc6Mp2NkAyBc0li 2SLYE6oII1nDHyQW7L2wg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepffeuiedujedvkeehuedvkeefffeivdeuleetkedu heejteekgedvudfgtdfgieelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepshhunhhshhhinhgvsehsuhhnshhhihhnvggtoh drtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghp thhtohepghhithhsthgvrhesphhosghogidrtghomhdprhgtphhtthhopeiihhhihihouh drjhigsegrlhhisggrsggrqdhinhgtrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:48 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 9455b33c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:48 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:37 +0100 Subject: [PATCH v5 7/8] t5543: atomic push reports exit code failure Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-7-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 Add new test cases in t5543 to avoid ignoring the exit code of git-receive-pack(1) during atomic push with "--porcelain" flag. We'd typically notice this case because the refs would have their error message set. But there is an edge case when pushing refs succeeds, but git-receive-pack(1) exits with a non-zero exit code at a later point in time due to another error. An atomic git-push(1) would ignore that error code, and consequently it would return successfully and not print any error message at all. Signed-off-by: Patrick Steinhardt --- t/t5543-atomic-push.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh index 04b47ad84a..32181b9afb 100755 --- a/t/t5543-atomic-push.sh +++ b/t/t5543-atomic-push.sh @@ -280,4 +280,34 @@ test_expect_success 'atomic push reports (reject by non-ff)' ' test_cmp expect actual ' +test_expect_failure 'atomic push reports exit code failure' ' + write_script receive-pack-wrapper <<-\EOF && + git-receive-pack "$@" + exit 1 + EOF + test_must_fail git -C workbench push --atomic \ + --receive-pack="${SQ}$(pwd)${SQ}/receive-pack-wrapper" \ + up HEAD:refs/heads/no-conflict 2>err && + cat >expect <<-EOF && + To ../upstream + * [new branch] HEAD -> no-conflict + error: failed to push some refs to ${SQ}../upstream${SQ} + EOF + test_cmp expect err +' + +test_expect_failure 'atomic push reports exit code failure with porcelain' ' + write_script receive-pack-wrapper <<-\EOF && + git-receive-pack "$@" + exit 1 + EOF + test_must_fail git -C workbench push --atomic --porcelain \ + --receive-pack="${SQ}$(pwd)${SQ}/receive-pack-wrapper" \ + up HEAD:refs/heads/no-conflict-porcelain 2>err && + cat >expect <<-EOF && + error: failed to push some refs to ${SQ}../upstream${SQ} + EOF + test_cmp expect err +' + test_done From patchwork Mon Feb 3 06:29:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13956828 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 8E19C1E766F for ; Mon, 3 Feb 2025 06:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564193; cv=none; b=jlfzPNbqIqlJtnlfO3HCP5eKELOeqy0R5atml+kr52sK98MJINfhf3zTY2NJ+lw+3IBs6ybKCqzvtI/V8544Oj4EbqjT75myV2V9iUckSuqvy3h5dXQU4whg30P/Uz3IkPoQLMSx+vvfi9AKArcbGp1n5vivWsUmo0MKGyl+9Mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738564193; c=relaxed/simple; bh=b3l+aeMB26Rf4LKRbpM1ITGKoS7Gl3p7Itx0BkOXjVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hL4J4iaQtMRrLrHgGtwkH+3rY/P+zVC/ESfZf5yD5E/s5jR3b8hrmncO6+IeSikkvAFIbgh18Mcy7zr9XpfaZaoWse5LL5kTf5qCxuDB+N9oIO6F/8Q3i/IBL4QWpi1d9CaPYLas3FT1Q1tAL7eOJdM0PAatO5ma9i887BbOMEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=V0fCy7uW; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=zSPsFOg0; arc=none smtp.client-ip=103.168.172.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="V0fCy7uW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="zSPsFOg0" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id A70EC1380601; Mon, 3 Feb 2025 01:29:50 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 03 Feb 2025 01:29:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding: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=fm3; t=1738564190; x=1738650590; bh=ayzyA8O2/qVkETBv1W6CvKJa22NeiEdGI04wGbhMUOk=; b= V0fCy7uWGadEisPmiVApZ6wn6m5pKMjQjsGODSUK+DNliJfd6t1NA97kkHVTwCCi 0zcoTl2mZGGVdsbLkIVC7JizFAMVHkgFhevZR24QNKYOVNpPN+tvLLMPbG66kC/9 M87bhWJMwEIQEiUcAsGLFQbZpGxWu+u93UQCgL9Zv0wg2V3vA06q4j5ogMl7i/BB H3p6+dLRTF1P2FdbLcZoT31+4BAO2papyeuz5YhnE9AKW5vKf3n5kK7ZzaPge0gq rLx6tB7OmaBmt21ASILnyhOEP5uNqWgbDRw7/LFViceTYXbfo+9AeakHJlTISIQJ rdPQEe+o7j+14Nprff1LlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738564190; x= 1738650590; bh=ayzyA8O2/qVkETBv1W6CvKJa22NeiEdGI04wGbhMUOk=; b=z SPsFOg0RDiEi+KOo1cLIWf/NU3Yr/Bx1yoRe65ojfMu8eerA34W2SBAMkD65UciQ IsXT4m3T2KukVV1SAJ/OphmkHeA7zjvl7Y2lXlgkl/mEl+jgJmszP0hp1tM/ZTvt 27q1YeYHLvJ0zJXaLcOp2BFfSKWOtUODZnoJseRcwgfkbfa8G0rrzxF+BAdD26Kg 3O95Q3y/2sqqxmqPWh8rwarYcMizi5bY6dIMVPOK8YaTzbcbT5uXc/r0+T0I2tKC HJOhTE9SNNTbEv09gGJ5QH9AWP8SEHH7It505pMV8jK03CViNHH+lqZCdCIoR7UL 2B+OUAqU4+9MrDtGNipcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieekhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrd himheqnecuggftrfgrthhtvghrnhepffeuiedujedvkeehuedvkeefffeivdeuleetkedu heejteekgedvudfgtdfgieelnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpe hmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepgedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqih hntgdrtghomhdprhgtphhtthhopehsuhhnshhhihhnvgesshhunhhshhhinhgvtghordgt ohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtth hopehgihhtshhtvghrsehpohgsohigrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Feb 2025 01:29:49 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id abb6a42f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Feb 2025 06:29:49 +0000 (UTC) From: Patrick Steinhardt Date: Mon, 03 Feb 2025 07:29:38 +0100 Subject: [PATCH v5 8/8] send-pack: gracefully close the connection for atomic push Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-pks-push-atomic-respect-exit-code-v5-8-d66481e36622@pks.im> References: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> In-Reply-To: <20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano , Eric Sunshine X-Mailer: b4 0.14.2 From: Jiang Xin Patrick reported an issue that the exit code of git-receive-pack(1) is ignored during atomic push with "--porcelain" flag, and added new test cases in t5543. This issue originated from commit 7dcbeaa0df (send-pack: fix inconsistent porcelain output, 2020-04-17). At that time, I chose to ignore the exit code of "finish_connect()" without investigating the root cause of the abnormal termination of git-receive-pack. That was an incorrect solution. The root cause is that an atomic push operation terminates early without sending a flush packet to git-receive-pack. As a result, git-receive-pack continues waiting for commands without exiting. By sending a flush packet at the appropriate location in "send_pack()", we ensure that the git-receive-pack process closes properly, avoiding an erroneous exit code for git-push. At the same time, revert the changes to the "transport.c" file made in commit 7dcbeaa0df. Reported-by: Patrick Steinhardt Signed-off-by: Jiang Xin Signed-off-by: Patrick Steinhardt --- send-pack.c | 1 + t/t5543-atomic-push.sh | 4 ++-- transport.c | 10 +--------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/send-pack.c b/send-pack.c index 4448c081cc..856a65d5f5 100644 --- a/send-pack.c +++ b/send-pack.c @@ -633,6 +633,7 @@ int send_pack(struct repository *r, error("atomic push failed for ref %s. status: %d", ref->name, ref->status); ret = ERROR_SEND_PACK_BAD_REF_STATUS; + packet_flush(out); goto out; } /* else fallthrough */ diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh index 32181b9afb..3a700b0676 100755 --- a/t/t5543-atomic-push.sh +++ b/t/t5543-atomic-push.sh @@ -280,7 +280,7 @@ test_expect_success 'atomic push reports (reject by non-ff)' ' test_cmp expect actual ' -test_expect_failure 'atomic push reports exit code failure' ' +test_expect_success 'atomic push reports exit code failure' ' write_script receive-pack-wrapper <<-\EOF && git-receive-pack "$@" exit 1 @@ -296,7 +296,7 @@ test_expect_failure 'atomic push reports exit code failure' ' test_cmp expect err ' -test_expect_failure 'atomic push reports exit code failure with porcelain' ' +test_expect_success 'atomic push reports exit code failure with porcelain' ' write_script receive-pack-wrapper <<-\EOF && git-receive-pack "$@" exit 1 diff --git a/transport.c b/transport.c index d064aff33e..b0c6c339f4 100644 --- a/transport.c +++ b/transport.c @@ -948,15 +948,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re close(data->fd[1]); close(data->fd[0]); - /* - * Atomic push may abort the connection early and close the pipe, - * which may cause an error for `finish_connect()`. Ignore this error - * for atomic git-push. - */ - if (ret || args.atomic) - finish_connect(data->conn); - else - ret = finish_connect(data->conn); + ret |= finish_connect(data->conn); data->conn = NULL; data->finished_handshake = 0;