From patchwork Fri Jan 31 10:53:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13955223 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 EBA1F1B6D14 for ; Fri, 31 Jan 2025 10:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; cv=none; b=TYxrumOuyU93RA9WDD2YSPSZkqK2CD75Qks3X7PlHod2pW2prlrru6LN3Pg0ANj0zRmDnnwrGeiRjGjej6tAIfjJ0xJ+jTsvh9QG1bNGi8+LLHcSsOoTG3/aYw9GAg+qsEf97YNKor7t+qSxB4/LE45h1Po63Xqjbbb6d2wwcBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; c=relaxed/simple; bh=HsbzcnVr2EotYJr4vC0edAZ/b9T/cJQISlKpapwIhCo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uh8uLfP5R91VV2SlfvQu1B7vmgjWmdz2U35iWRbg5uIwSoclAJqnC9JCWu+bKD/83Ie1uzN51kY9enFQenGK3gJdMsgWYimju+xQmTMISb9MPrufK5wdxTwnGFRdB+oj6cuVOsRtccFf2chsGDvhCR1cqbWpoe0epd715nx8HgI= 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=Flla+B89; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=kNjWkiwE; arc=none smtp.client-ip=103.168.172.154 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="Flla+B89"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="kNjWkiwE" Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 2559111400FE; Fri, 31 Jan 2025 05:53:33 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 31 Jan 2025 05:53:33 -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=1738320813; x=1738407213; bh=mUetU9aMVjFZsrehrCVeL7icGo49NoSwcHPwAYFsyAg=; b= Flla+B890ofeskCfb62QMQeLhmue3sr5zkthkChG0Z9l8v0WuP2929oO3cxwPCUG 4FNBO8AQ5GFXdqciC0HjFoqJxzW52te9ofHziUPCCe/eWeyoP5920O47oTfshKcx jxqM0W50BmaiHz4Eaj55h0Lk3MwiIQ1m9up6AfguEV0D5pxtNX0v6U3MtIyegnya mk9+APZk03ljgYS5CMb3+ntcFadgpdGLOu4mMnCPpgEi9rw2hQ1p7kLcD2twGTyA k+hRGSS+il54AVXD8evp6rSJMEpx0MXrp2LItLfXmD0kQrGsBkSi/Pp3xzE+YHTl zxS0q2kVdCo8fYZXFLS1cw== 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=1738320813; x= 1738407213; bh=mUetU9aMVjFZsrehrCVeL7icGo49NoSwcHPwAYFsyAg=; b=k NjWkiwEAWSbuBlXgs5LFrJsIM02BDEHtaJTH/T1ffbGKv25N/xgwpL5qkX9YF5QT BUNgu0Tr8LzetrEr7CL2ZvdmU+RC+S/TUbM1cy+b3OPQBdHfLQpBn5VibOXTSgHH Z2Pj2TJwlXoZNRg47CnRWlgxrl9lpTkP1FFUKAVLpBjQDF+B9S7qA0G8d3/cqAZr kwXag2W1EwTOOrBTAf82PXqPJOJyBHv29ydz6RXMN9IiDX6OqnWa38rDq+f/j3hC zm9F04DyHAi+7EuG8Gl9eb9qJqY1UpSnEq8bQZviy0DSkr5DqZ9kh9xUs71eztWz E/O8tJ+GHuzV/i8uhucOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepffeuieduje dvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithhs thgvrhesphhosghogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdr tghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:31 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id cd705b60 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:27 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:25 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-1-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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..29f18841c3 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: 13955224 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 EB9961B6D11 for ; Fri, 31 Jan 2025 10:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; cv=none; b=D02WRbB7Ys26CXaOeXSUQ/64OXM0D77rMx3/Pareh0pvjZCkJ4nVaForUEn5QdIXRZOZcW0XQC/klGPw3IPZgrlhEtWfbMdDyZwrYwEEke1Kp/DsRa/9z6n9p10p7GA4xN7CEoOJ2r2T5cQuNoOsuvXLbun8yRx9kILEXSWtlao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; c=relaxed/simple; bh=lZt4zNErN9sBh5DqGSH2drxCdpuvoFzSEnWqe8v7Vow=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HRkNgqQT1R7jdEhPosDR2F5TKqygMHVuzFuEs83jwuCgdqbnVWI9mWrkBDg0/FjZx46KsriEx3PLuseAFG0A1jaNTzMiXcx3Chhrd2HqSgZa3C9lXfFWD0eRZ+heRjuUQv67DA2527MVd9S9j67aT9P5ZGuZJY1BcadNpCayCRA= 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=YkJqYr63; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=0rP68ard; arc=none smtp.client-ip=103.168.172.154 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="YkJqYr63"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="0rP68ard" Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id C6B391140101; Fri, 31 Jan 2025 05:53:33 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 31 Jan 2025 05:53:33 -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=1738320813; x=1738407213; bh=PtLA/sjC39g2c0AYQeONFutL1BNWP5QHQyI0WKY2YYk=; b= YkJqYr63Kio7+w8w7zQBssgfTnRjGXgxtNcvOcZzfQWzauRN486e+Ua9d9Pt+qOz 78obh4UjLlbvlG7pstlGt1ewetw32QYH80IpH3rI1HRPwEc2RnhMyPBduuqyhNKm VTcHYzO19LFadC6UZ3FW4ajUXkXDW4iXNWLbrFmKGY6GlFcyRFBD6xLadE9uur+c dD0JDxOwKvt+Pgpfi0oubsFpF6Guii1lySLP0P0916ym0UvW9gc1k6b5ryCZNmiR bc7NTFOjGHpcKE1U/xVI4bvJSwAv+FYTkuqiaEmjAMnoPlRRuaXTgmYqh8NbSepa jBvaC2a40ElP/8sTj999UA== 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=1738320813; x= 1738407213; bh=PtLA/sjC39g2c0AYQeONFutL1BNWP5QHQyI0WKY2YYk=; b=0 rP68ardXuwWIHZRigBsWFPb+fCmVG8ef6dvdgFJdSWDwvyA9iKZbsEQhZ8fJ5uBj UTfmPr6jH+DR2Mt+Flizm5+miYmLfb9pU8J5sJKmU5WBGdWoWOU5/i7D7uKwRjXH DIqMS1KC29CkuNEXrW61bTkqpLSeukrzAzsRhPjh7bamzT8utwCh2iDo7ctT9sNw 6b+Q2kjGs3WAN9/ZMhOl8CoC9P/CB0uYcTHHViQZ55U94YRvRYuZ+sr+C5Sx2rcn NbIHOE5jXl9k+YGQYIyjSsj7mp/49iYneNEoTNF70XPQKJFLTZvfajekZpjl3pjp DpscsN0m1koat8OSirxTQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepvdejteetff ehjeevledvffffffevhfffieejffeliefghfevieegffdvhedtkedunecuffhomhgrihhn pehhthhtphgurdhshhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtg hpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdrtghomhdprhgtphht thhopehgihhtshhtvghrsehpohgsohigrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:32 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6310c25e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:28 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:26 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-2-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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 | 85 ++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 30 deletions(-) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index 6282728eaf..a3defd5b75 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -54,29 +54,67 @@ 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 && + # Assign the first argument to the variable upstream; + # we will use it in the subsequent test cases. + 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 +126,7 @@ run_git_push_porcelain_output_test() { ;; file) PROTOCOL="builtin protocol" - URL_PREFIX="\.\." + URL_PREFIX=".*" ;; esac @@ -247,10 +285,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 +294,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 Fri Jan 31 10:53:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13955227 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.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 720D01B6D15 for ; Fri, 31 Jan 2025 10:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320818; cv=none; b=n1Za7gM3wYYsJILeA99ZEKy4pDvMM/VsTOSi6O81VCAu4lo+MT1CFNPzzTOuvsGuzEB7xKhk3+P2kJyCrii4sj95NS5d86U+R6VqNSPq6CionA6AIUS45Ijs/rzAvt+tjDQQwuUTT8Ecf21V3NdE//Kw8NuNsTh4Ho/y1ngnFBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320818; c=relaxed/simple; bh=NZAEqcda03KMD4751hwnIPd2IvMxgJJbkqyfr7cCcbA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kfKDXSNksfLeHz8a/xcrxxw3/t5WE6+Rw3tbBny+zCp4Hbasnw0Kf7hlxHO0rvFaNKJxjcLGGqr1D5N5KAAhj1cCMM5gV2pjEC86udZupFt3oabDTdHGyb6ynVDChO5owKa+K5UJcZEgtrVx1Yeu4wz/fPH+LYgfPTleFqx5kRc= 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=eIZEoo9d; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=xjFwprKR; arc=none smtp.client-ip=103.168.172.151 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="eIZEoo9d"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="xjFwprKR" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 4CD5E13801AD; Fri, 31 Jan 2025 05:53:34 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Fri, 31 Jan 2025 05:53:34 -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=1738320814; x=1738407214; bh=NL/aSjUGctRTgM/tGKGtfUnBT0kPLUTyWnUFrJ0otio=; b= eIZEoo9dttOZ4wqU3ibNSifAk7JSYK/s08qv+GmCBYJPWM4cspGn8fAnZFe9DuaR dimhMdMVXiZ2mklRDb7B2EXG6i/w6eiAaNp0+XGQKrP+iJlz4TO42WjkFhHkxOsG fhDJPzD/51TH6p0txWwhFHUtInr0hxfUfWZxWHf4v2f79HvKeM+q6LKu34bVs5Pv qvlGwcU0kYo5lmQsj7qNwVB9H0T9S6Jq4JEGi/zNqkNuFLIQ07kqn/WVdbWzUlEV SI/+16wbpheHTktmeCyaIPjBKBEz8UThgsbUcC6+f72HyxnstMms8LuRbenZdF/H 30RYDZGu0XcSPa+FFbSptA== 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=1738320814; x= 1738407214; bh=NL/aSjUGctRTgM/tGKGtfUnBT0kPLUTyWnUFrJ0otio=; b=x jFwprKRwT2e2DU2zEPsVL1RU1CkZ5jqihIkGtDolnxSTYLEW9I4v1areVjClov+u srH1jGJcRI6nXFiCR9xgkRxy7thuIDRnc0d37tz0kU1DSlk41rjnyeKvSEevJOmR JvWGBPtyyRPSUlxHgraIksSeZBSEF+45oB+M+g2uWlv2nrSLIDcR21RAyVS0V8vL lwJN728dKMcUvmn5XH9bz8SaJIWA4IuodL7ILKKRxHGHbhFTnr+An8ozJdOra7I4 pChIfe/4jwNMQDghUCzx+up5e2vtHw6V/18kV18hx8bq5LqFBfGCo29EqnF54yMO yplYRR1fEt+OKmGD/bANg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepffeuieduje dvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithhs thgvrhesphhosghogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdr tghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:33 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 9de03c54 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:29 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:27 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-3-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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 a3defd5b75..ededd8edb9 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -96,8 +96,8 @@ setup_upstream_and_workbench () { # we will use it in the subsequent test cases. 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 && @@ -105,6 +105,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 && @@ -133,19 +135,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 @@ -169,115 +166,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 Fri Jan 31 10:53:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13955225 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.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 8340C1B6D1B for ; Fri, 31 Jan 2025 10:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; cv=none; b=aWNWTzpEhEqg+5mbOdq8HR/fN+G3c9S4PFYrwE4gHWIN8nmJ727JdC4TjjmrqcOIB3jmmXbAs8SaoSeIprCED7MXx0ctg3fZRpG6GA6P2ltGK/2Jlz4NSHXo9rYF1hGngLYPr+hM8dx7/E03re3O78tQ7HMZiTL7RNLR47pK9TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; c=relaxed/simple; bh=u3f+6I6r2DTl81Wnq/zztSHiuFm3592QvyK2t/HrwE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sZgT2dIdITh0Tu2nGJIyeq+/NLaluU1FsVs/K+rlMopPE6TSq71QfebCGGyucJ7YsmtEKJ4WVK0DNVL4rWg1SZnPpUZI9xPi18KJ1U14MAI7UNrMnZvI6md11c0Hv/0pX7q7lqVKa+hfAlV1jwmptC4rcAWn5qnjyExlSYJnjag= 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=Laos1QxO; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VnQ6u+2W; arc=none smtp.client-ip=103.168.172.151 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="Laos1QxO"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VnQ6u+2W" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 8CA3613801B7; Fri, 31 Jan 2025 05:53:34 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 31 Jan 2025 05:53:34 -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=1738320814; x=1738407214; bh=uruxXdZwC0GLLPwQWwThl4IPR9cIs7hrndedBKpmKdQ=; b= Laos1QxOWdmIzS3pMWwYcU5wjzKvtfEVRUB5qWKlgac/eIeH6DZX+Qu2lTdEfMik mIi89HMAFeEEV0lLYpMBgwvsWkAK0Vqt+5+JtFThNQIWz3zus1DOSpUpNyvnrwA6 CdBL7AO4oJobCcNW5Dy7VBPK0Lzqr9NUXkbzJ4W7ZumEg6BURU59EKYxf9xWtgZt OzOcpTCGVjhSwUSxze3fj5Ny5JB+w/14iSw8L8DxH0WUg5MTexiFdPzvI8xgyMun 4wG4t2EVFfZJruMF44CSNKfz2dJuv8cajltW50YltcPVsYqU9Rl7UzFJAl9JTOKj 4EKkq7glc+YdiI1BJsNedA== 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=1738320814; x= 1738407214; bh=uruxXdZwC0GLLPwQWwThl4IPR9cIs7hrndedBKpmKdQ=; b=V nQ6u+2WtTtSK3cc0Buvt9LiB/ozA/o5FAyHJp84UPtHocfSwAVpMfwg7/U/UFVDN VVq3mbL1vOFwInTTsBbPIGoH9QXrYVNceEWVjffu5kDLxNhtESuHiMM66bc5xmiF xucAbRVB9RuDMz3IClyo/Itwnnr81Gb+U/LR/g/L0706R/nzqdAZN7MdMeU45zoU XD6e4ql8rLbxvqZVZLAm8CXqo1eNVQKeQV/SSyJ5T/hjIFgUOC0SE0A1bY1QPhU6 KQAtbQktwoMvnvJME/riCoRt/w9sdiqOPLWP6fSnemen58vsKe4tG7bqBbfkrg6N NYQD7kHJQCNP4GAsQ8Idw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepffeuieduje dvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithhs thgvrhesphhosghogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdr tghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:33 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id a6177aaf (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:30 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:28 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-4-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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 ededd8edb9..b510a2e6bb 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -132,6 +132,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) @@ -242,6 +276,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 \ @@ -268,6 +303,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 Fri Jan 31 10:53:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13955226 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 002621B6D1F for ; Fri, 31 Jan 2025 10:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; cv=none; b=LitX7RQ7XQmgd1FlA8uiTA/9ErOTjUIzIv631IFo+v4m8RAMlxZ7vrVxJgk/VJRK+7bzKZrImF1bkmT6ZRNEm6Dfq64y3YPfJKCbouF9ktBSy498bPVhueM47wgNgm35NzIsv5osk6YHCDLyAUv1EdNOk2ED+HfPjpLvPaV9ksw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320817; c=relaxed/simple; bh=BxaGaNwMPyqbN2YVWW94P7YOFwIHStEaIPI/RRWhDPE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BmNOMXYVSjGTAas/FLDPW8Qcb2U2F217lM2ZgorvdaJA0u/xCWC+/Uk6LV8DYfNelCWVMP4EHPBjB4ejwrA/PJFv7N81Eqq5OsC1ihCaaz1b8PoJj6FhkSnL2SPCwF10VIPVI6GILMNR/XeuoNyM3FFArsVB3HGV3AgWX5KCvSs= 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=RTi6NUh7; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=zSoQBNT0; arc=none smtp.client-ip=103.168.172.154 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="RTi6NUh7"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="zSoQBNT0" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 030E71140107; Fri, 31 Jan 2025 05:53:35 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 31 Jan 2025 05:53:35 -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=1738320814; x=1738407214; bh=dWeYN1qxvt6KYhDtZdynsaIVCK26iXI8noqfCnSrcvw=; b= RTi6NUh7Khru6Rfz8Qx0P6V7064tAcDNL8eIcd8aYweJTJ7RFYB2XdMySd41YbK6 U7BTxTfDEakyH/ImZs2qRwa8hPr8wE5XUzi1/orohahYC4GzIk/ygEhEgZeU5yrG MxY7Mdwj1EufX9TMWOWPbubOY45OYNg1z18l9zKfYGPJ2XIhXHUFwdzJYE5zgHX/ xifaG6tbMO7yfRQz5a7M9jdA3OFpkY1RZDqN5eP6gMm3OtTehPAR4BrIwdK9UE6W 9migk/DRiF5rehKr5poZd5FlTcTuUbS/6cmpQCYboyL0+AK8AipEuTTeam6LqnQ2 797H6gQo3gk9YmEYOEDeOA== 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=1738320814; x= 1738407214; bh=dWeYN1qxvt6KYhDtZdynsaIVCK26iXI8noqfCnSrcvw=; b=z SoQBNT0cSUjzDt2QbpyxswT87FCdQwmOUA6pr3aRlBOeDYHzdMzHUjm/BQJmRIEA NsOMrAeyKZ+0Wd8ytk6yzGJ/na+kbUDFkUE930U74vYlHWpEcNesocj0LlWWTMN8 d7M45JYQEssoXZ3rdIPtfOJ3eROFFfKu0GQi2t8mLoN8Aoyou+8NXCY2HaguUc6a 2qns6J6lIt27vExNJnhQAHEvXOmwpDpCyBDsci1iC0Q/6vGUvGTmWa6+TMBI8Ek7 ol30FabrxUl6A3XwAem8Dv56xISHSMdbDfcWAUyMIOzgoqHmWr3pdofgaNa263fN b/CR3jL/yDFrV1WRcAC5w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepvdejteetff ehjeevledvffffffevhfffieejffeliefghfevieegffdvhedtkedunecuffhomhgrihhn pehhthhtphgurdhshhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtg hpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdrtghomhdprhgtphht thhopehgihhtshhtvghrsehpohgsohigrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:33 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 3437fe41 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:31 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:29 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-5-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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 b510a2e6bb..c20e4ddc01 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -338,10 +338,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 @@ -353,4 +502,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 Fri Jan 31 10:53:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13955229 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.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 01D7F1B85D3 for ; Fri, 31 Jan 2025 10:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320818; cv=none; b=intzAPBPr7AI+EyxqK8Ezww6Iva9fm3Nb+yhIS8d4jnoxgrgIkhI8wbf0LJOkfq2Iljy8ZVXc5RcD/oZkS5U8mqEniGRZMNbaSWONMz/B3aQW8MkqBkyyeStaJOPmEFOLsBU9y2XN9F/skcc2HTpjujz7DtwSJl9MVdARBYu04E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320818; c=relaxed/simple; bh=mAfvfkaxXwctFztc9Enha3jhagEGMfCWM5hVpe/MOfQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GoxNw4JTOafFPxI5Ke7IQ/WkPhNws6P63AOmg3fbNwP8oXT/vK63KW1JtS70Pmmap+juSsMlteelon+DM4VuozndicOnnTdwp4Qncqk/TANzM1Zotm6Ryt8IIdOkHpnMe16bBxEdWoziXlrtGhWODhE4K9XCIRjEv64GcnoX3g4= 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=Ke0KSlO8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fBVnZX+u; arc=none smtp.client-ip=103.168.172.151 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="Ke0KSlO8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fBVnZX+u" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id CE69113801B3; Fri, 31 Jan 2025 05:53:35 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Fri, 31 Jan 2025 05:53:35 -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=1738320815; x=1738407215; bh=5E9W1XzpUM6PTz3Satza/4acrK933ru5QwjkJ8LUdgA=; b= Ke0KSlO8BrE44dbBqR2Ax4yucMze37XkdVVX1BlJZHWtDAMhPrHssSWizUDAM5B1 jsSyIqRxAMjHMQfrvgccgSaGlG+HUBSbvikYIqA7bi6tMCPcKQmrgVfkL/vC4mad RH+Kpy5DUaq6ellgd61ihF2zk39kfc/4Q6bZI+iDz0RXqXDvn+CYr6apnCY7UBT+ 0dASOaeAu2m0V2Ipq2x57su/OdONAjST/ylQyOiOmMozRkVStEdvtLZM6+zxEfba EQVt7+tNxHqg/kK5DMLvXn6wPPv+4zdIyI1zlKUjBY0kHdQ9W6CPzXdMJ8goJnfK IdE/sckyK0NjuhqBPSOO0Q== 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=1738320815; x= 1738407215; bh=5E9W1XzpUM6PTz3Satza/4acrK933ru5QwjkJ8LUdgA=; b=f BVnZX+uCNfq0ccBlqmsKS3S61wjjjJfLPAwDuLGafuOtgeQBu89kpoY2nqXn/kgi LLpYpxHUJTgvgBzUmRdq3XLhvTd41luj3+OgYmSmZmxpOj1VuQ6r0hs484Zeja9/ Glnb5xQ1JcVwavpwEgv2zts405udVkjDcR3LeUV/aWDjrFgA58wk2RHnoooQpcBb j7TcBEInuVO4ZopkaAMcyy+pwN8GJlmmFDadW/q2E29I2Ho2FSUEJ3KwqTlQjPen cOCq7d4i1euxJxjRodVVmpW4pjYZC/LkTEzY/ySKDPOcjr6nM0QJg7P2mNaHNcsw c2ChgJXADHWLz1VaaZbQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepffeuieduje dvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithes vhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehgihhtshhtvghrsehpohgsoh igrdgtohhmpdhrtghpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdr tghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:34 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6727a65c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:32 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:30 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-6-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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 Fri Jan 31 10:53: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: 13955228 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 E56C11B85D0 for ; Fri, 31 Jan 2025 10:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320818; cv=none; b=IRAGN3+a28RuKe2PnJ4XC66DBLFT5s/7gJ+d9ZbRI6xwGFTq3Q7iWkqpc4UIETLBcDlHZfJs2aj+P2Xdr8Ryn45sLviKeAoriQfQgCNBNHoYXAzIsTYg6RvdIEPfFIUZzA7n5qrxV42IeAl1vPeI+B5SIQ6Z24h+e/c0bc2SY9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320818; c=relaxed/simple; bh=nFeC6BtcS+hOfHxDK3EtT6qcz0nydlJdwyNZA2ujWho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gArVz9Z/DnL+iC0bX3vpO4DKFJatGJ+BaOdGN9ybZTtwJaBvGZuQJsxI08dyky1jkBrK5RUpqV+ijrDRSuco5ywIaArgbr+0UaRyJGX0I98W85PsUdaDpX6IEBZMISAQndNZdSMS4MKCtviqMVdCccoLPPFnQZ4s5Y5U9ruhl24= 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=Y7mICj5N; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bbOWl2/h; arc=none smtp.client-ip=103.168.172.154 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="Y7mICj5N"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bbOWl2/h" Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id CF9591140109; Fri, 31 Jan 2025 05:53:35 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 31 Jan 2025 05:53:35 -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=1738320815; x=1738407215; bh=3y8btysFk6GGvvuftdxS6BVIk/hr4qyQagAbM69FupY=; b= Y7mICj5NCzdhaOZ4IPNrGzqH/bP+xNK1c6D4CH6DgxYtxAdHSXLzvqmxvuzxZ6pM TrSJxsXzDgrAhW6zSNAobA4S4/AcW6x67gDBBNLFIWqXsadfxrGgbj6hlxV01tYH TAuTzJ5d6+6k2EUK6meh703TwKRFLFTeXxk6fui4Cy64aYFJ4qJvE1oMxugoRrWM T74ZpTJAEp49Ah4YEzTl7aWwRzCFlSvigHyeUQ/1SOQCdPUFBnEfmr77ZGUCf59a fu/ekaq3kwzEzhkdrEeop9m84K/vxijletHKjgCXZgvR/9z9DEPi5N684Q9QPanL 3R1PUSs2sW8TAvIQ6Nthvw== 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=1738320815; x= 1738407215; bh=3y8btysFk6GGvvuftdxS6BVIk/hr4qyQagAbM69FupY=; b=b bOWl2/hnCioYMdzFH5C8QyFliK6NyX4hwlOW+ySovhWGrsq2T72X68iD7WOlkj2F 9S2u/mvqLfjIt83bRaq5uCp3o7Yer2x/lcFx/y8jtvyGApyjojy0D/EmEsWxbFqM YeJdAAA+Sif4ItXaiR5V3hk0pTJ1mW2BSIynK/NlgkAAJ1zp7puwUZqrDmS2KG4G VZncYI1KimwDf61TznQJDTZpsX7Ctx5WTmkQyhQ4G7UbrYtKUT7wAQEpPYCbscT7 cItzTNPjvma9IuiCifV/i4l1tklD6ZKpuKWU27nL1Es9AALvk4Y3AtzApe406m3t aveIE1aE3UPicKIS3gSIQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepffeuieduje dvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepiihhihih ohhurdhjgiesrghlihgsrggsrgdqihhntgdrtghomhdprhgtphhtthhopehgihhtsehvgh gvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepghhithhsthgvrhesphhosghogidr tghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:34 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id ccf7192c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:33 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:31 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-7-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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 Fri Jan 31 10:53:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13955230 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 8BF101B87FE for ; Fri, 31 Jan 2025 10:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320819; cv=none; b=O/XhjS5EuqIAimn2S8wcg3rDfckyVZ45mC1BEhwtlut8AJt1Yx+t1Dwow2sUXSVHE87MHsvKeA4PN1APldHgKNM4FedkuKDyXZTl8cBxkLDv+Y1YWfYxnpz4qMtFR4Ip4Cq6ZK7qJ7atJRlY//seOqDM3m7fXltZDpfzSEsJEIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320819; c=relaxed/simple; bh=b3l+aeMB26Rf4LKRbpM1ITGKoS7Gl3p7Itx0BkOXjVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LVs+navHfq8SlPnRtryije9G+q7Hj+alk8L4JNoGIfUcMW0sPB/aYBKadNynnnddn1XSKZPPOTVN7ZmzYpr5VkrkoCHfAASmuAk4h4Hxpi3ff0Xdt2dVmDFE7HOcNPJlWgjpq+6oaNsrsvhCsuI+XNae3kaTtHNzhVRumRSgJxU= 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=pB3QIHjL; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=rfRrPq5d; arc=none smtp.client-ip=103.168.172.154 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="pB3QIHjL"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rfRrPq5d" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 13D5A1140110; Fri, 31 Jan 2025 05:53:36 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 31 Jan 2025 05:53:36 -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=1738320816; x=1738407216; bh=ayzyA8O2/qVkETBv1W6CvKJa22NeiEdGI04wGbhMUOk=; b= pB3QIHjLT4BNr4F0JlbXimWGNxHs8ZpWnKLykcf+SOSPor4jP2lWF2mlyMp/StjX d4ngfmeqxfYTzegLLB2VzNHF159y9eA5PdpL50swuXj+GQgwRGtAQ7KPlWlPpO+a Ray68y8UstIRNdy3a4cMVVv0zJtyDWGgcVQMTBN6e/oAwtWHiTo7jutTpKPU6/gZ RdRavyn8j4yOrdZQO0GtoU9FMLcgDJ+hr9vPFWpoDKPqisIR5NX87e5yHgF6LI10 If5q4HjIeoZYJJKJN/oclX8hNBtzwPCdi+fSAuMSx5kpM70qfU93gsD5znuIW1Sy B/Pmo+BSthxWdnUFeXkTOw== 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=1738320816; x= 1738407216; bh=ayzyA8O2/qVkETBv1W6CvKJa22NeiEdGI04wGbhMUOk=; b=r fRrPq5dOo29bVV5Aiam0HbmkFdaysq1a3z+14rfG2tXSbrG0Re68VEroUpUh9Xze 34c/foF3Kabz+SyBBhQ0VLeOvDfDpgxzhvI8hhCY1/2TcUkkzc6sfuFh1yiLrSMP VwWoyR6gfO9aUm/wkL3Jlc2MjFnLLf/31kaQpLrui0mub3Q9CZkWpQ9WntmVXUkk +JAZMeHOx/TasxWQ7dlBwwtX2zKIIFByTZ8JEeszbWHQdPyyKr4oNS1OPHN2M6tx qaBxo3LixhbhKJnyU9QfaLTIpYdzYWp2ybQobNtVUdHL2XF0N5hcHJaGATcFVoPp 5QbQWJCLkFb3bpDUDd3Pg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffugg gtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheprfgrthhrihgtkhcuufhtvghi nhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepffeuieduje dvkeehuedvkeefffeivdeuleetkeduheejteekgedvudfgtdfgieelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithhs thgvrhesphhosghogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtohepiihhihihohhurdhjgiesrghlihgsrggsrgdqihhntgdr tghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 31 Jan 2025 05:53:35 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 2164f7e8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 31 Jan 2025 10:53:34 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 31 Jan 2025 11:53:32 +0100 Subject: [PATCH v4 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: <20250131-pks-push-atomic-respect-exit-code-v4-8-a8b41f01a676@pks.im> References: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> In-Reply-To: <20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im> To: git@vger.kernel.org Cc: Jiang Xin , Junio C Hamano 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;