From patchwork Tue Dec 10 11:36:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901345 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F972080DD for ; Tue, 10 Dec 2024 11:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830597; cv=none; b=MAVyZGfrnDwOmMTJ1n4BYt8Xat25N9xXR+QtGkw/MXZey8H7poMwU3Vcof2Bv03PkjNdeyK/kx/OTLtiMIPXBb3PAyNt2H6NVw/sYfbSZ/me5eNp/LJTlKrznkWwbkiDSw27via3KMBmTZE+GtjAPit/cd/auuCJ/aIaWbHjLQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830597; c=relaxed/simple; bh=OvQ0OR0Y5WXPzWh3oAH8iGHrcbFahFnY/NuRWuIIiX4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FkyyFbwY5JdFf3GnOiuF1+oR07kU9TvrwTbrCdFU9NtZDoZeWYabwww3v2RI4QSYplV+qgPnGDhVs8IyuutLgADL4NmSX9GiEUxSf4nkxhcSr3xEadFxOXmDbDvWIjShawm61GyLcBPcfCGhiqJfQXkuoHF5QalZxANzA0LagEg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J8/B6jqS; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J8/B6jqS" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-725f2f79ed9so1473094b3a.2 for ; Tue, 10 Dec 2024 03:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830595; x=1734435395; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ytE0n8QglSSbvsk4IgL17vDebAiFFYEMEursA2qRDL0=; b=J8/B6jqS6MK9o5S0Ipcb83rtwLtdHaniE9QNNCaX/mlhhxaRVdZfCTVFp+VHRx4FKK fM+WswMxEU+IJlCTIGPyAUH01G/IvWJd+bUUiJX2S0g16ku1t047lA79Ez8KZtGt81Ge XAHBblhe61uW4y4ebs4LKdb9SsdPaAdxJnQ0FwBQZxpUVXBVwpmJnq+kGlmXdUswItXR Yjsk6IznMIJ98BtVuhApqBLe/xeplFK5HPZh/QF7iHhwZBXmGfISAju6jNItjSddyRwY JAtT4/T8hHpu9O2rBO7J2xq1xBR2Yj79po7Xrcu3nCmSTBr25FC5tTOZNJ7QSBcnN4q0 aNjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830595; x=1734435395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ytE0n8QglSSbvsk4IgL17vDebAiFFYEMEursA2qRDL0=; b=DIlotBsTidWKPJ+vf/MkUMX0m9KrGXI6sIvHmhLyeCS5jyvm/pDaiiKA+m0Lc7Kcgs 6y0RsSWA8YnLIZdhMWhKDfTc4Sw4Eb6DDbNQfBGflhDmG+3HRFqYzsU1ykcqVAdsKJcm 5I39ggmrWpmHZ2unsWOc8AjJ33IAIEeWGhl+6r7TaNX/6V2jlC0rKcLV5g3WbrWK/dDl YLMxe9oVRNlgOUGqX7LCjSYpMDwjyjr8XZenMvDos1sZRk5IDrw3Va6wZ6rKMa+In/pl ipuenJuuQQ/EeZ8jHdP7b8lTB4OQNhqOWQMfGCnIPo1r5dqYaePo3BICLqJZ71fLyu6x ugJQ== X-Gm-Message-State: AOJu0YxWkfK3T4dhs1TUpSaLo0FkQhX9QvydYQq6CBNJg2RAMGnxWmXr M9fmkbVQ4/dWa+eVVZoF+PXtU0SPoYYc8y4K5bodhRzN7er+jRj+UWFsFA== X-Gm-Gg: ASbGncslqdjkZi72lIPuSnN2vQrLrLdwVT0863gMSMqGR+6DeVjED3czMquI0UHY/X2 NaOeE/KWF10KvSlZkYG1xFqPMwc/OkUGJo5z24xnNw8mXCWboSrAhkY+fmHgBHoi6tu/d8uF7/C J2wRX+GDFaOhXNW65OP6BoNOMwPCLNpocmbYBw8Oi0M4grlGTCroo7ZqXzxAoK6msTBDh1AfnhG iX9wvdfXD3ihClCFUpwbWm/UOLmMzrQGlA20VPmX6iVlTdxXisD2gk5yVQJGUxf40g9KA8bq1W1 M1RO2mwFKLxZRnlkVNl6Uvq2+M74kWHqfJhO3AUbJ2SLxQ== X-Google-Smtp-Source: AGHT+IGCWYd8hhBvGXRa9AcY+X06zoKWRMNEJCjK7himXHVVYcRKNyMFY9oA52/I2otWwK2qjSLAeQ== X-Received: by 2002:a05:6300:6308:b0:1e1:bdae:e04a with SMTP id adf61e73a8af0-1e1bdaee397mr630111637.39.1733830595117; Tue, 10 Dec 2024 03:36:35 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:34 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Subject: [PATCH v3 1/8] t5504: modernize test by moving heredocs into test bodies Date: Tue, 10 Dec 2024 19:36:21 +0800 Message-Id: <4e509ef20465dc2a818f479b34e11df415e39906.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Patrick Steinhardt 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 53dbc8ce3a..488310c340 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: 13901346 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 357AF2080E9 for ; Tue, 10 Dec 2024 11:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830598; cv=none; b=PovZ93etNa33kjZ7013mBVNzleFu65KgPjBV947nZ6dmrnD6leFA0hK2pcyXzikdAYBE0TWebrOjk/Bp+VwTbemTjceEX2WKjBDMKaQMWFVccqK/w4ajF5FkWnhY6WSDZwgE0x1LCiukf4wel1FgSMLNST4XxX7L3hlZXhRMhiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830598; c=relaxed/simple; bh=4sszxzTwp/3mXbfNKGxhCn68tfoxtI9KDEXOXPdBojo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZTJPHRiRySyHTgAZQ2QDCM8VCg4f65+Rc0l7+8Z/bYT6EufjZL3sDHAaFPycWLKo7wqV+xQi8WBpm0/oyxzJm7+yWuhgTvFkrzMwt7GlmaVB+RW9dl2SBvRWlXB+1P46ivZV4NThvQMxArO3DFnxPmrXC0D4hTynYTwS3GvA+w8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LiRGva8b; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LiRGva8b" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-725aa5c597cso4060059b3a.1 for ; Tue, 10 Dec 2024 03:36:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830596; x=1734435396; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X81mzSILQjyq4OH5bjfAfL/sk0GmWdiBQ0rt5rNZnVM=; b=LiRGva8babghx3m3ENQa0D7tLGQAHh+0t/KXWj5YrUoYoEnNyWGRnU6zS/qAH7PH4+ mBoxjNZESnb5YaDv/v+1VX1ghTPDt8jE2uPRwjTSj1TN2StSfzIEhbosln5X/7k38u8+ pjGcIu2J8mnJ2I3vDniygWeslG40YvwIP7q2W2mUTz1aulttTA+9FYcu5lFIFYXb3nZr RW907YSQkhWteD0MgNeeEmG5MSmgmh6KApEaKpa325SnnYcu4ppZku8hBSvscy7vh1Lw E8GUA28U7h9LbyvDdo03Wyhk0X/qZZBynQAZGfQR3oHN8msm1hX4rtogDBCFC5oap/LE wpkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830596; x=1734435396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X81mzSILQjyq4OH5bjfAfL/sk0GmWdiBQ0rt5rNZnVM=; b=bEqTWF+rxo7n/aWqqCf3QzXqTj54G6QXL9KX7rjjhJZj1qvMwXwLXHFeaWX1pJ1z5h 67IKW221y4dT1fZLi/U0sHP7wUg3mctLU8QMZBvYsar7MVC7NXMQDn3ePJcVjMlJ4HI8 FqeW3ROsEiuYWIApY0dcyyecUA4NCCd0kNLOkiiXU5Ol0s7u0xCyrRPEkfi/RlZucOhH FPWfQMfTZX6kiIVcAO77TizhVECNPjAqRx/YiP/c3Td++ddEGyOgaK0WrL2X0VmFAx46 YA4UUnNWkFsksJ/3G0yOfIbLXNT4uF/ZFwWoo3OehcIwTSroeKhKKx9Bh3arSo2m2H7S DdOw== X-Gm-Message-State: AOJu0Yw/uvO5USytyYRSCFs+xXfLWgz40xFCn3KdA4HCJzjwiaS+bIVV g2cPXq4grXp0+xKmlraYl6WSX4LDw2uwvVC95QPy4cYlJM4PFI7WeDKI8A== X-Gm-Gg: ASbGncvxl3dUtw2h1BuZLJwCDzBeMaODBe7pOAjsqEbp71Yhv1aXvTx1CP7T21s5zMQ qjjePy+g0vrJ3hYBD1Dw/OlK02GEKcztaL+MdJVwggfZwaBWQ9UG653f/s1qlf7RjMO8PuDCGia SZ8+bpLtOV3KFeKNYe11NXd2lKV8b55BnCT9MGT2FUXRdS8w19nKiarwLcmZjQdsOy1iZ7hFOpu xZmTgtPiSSEr/vlB4guzvsice6ctRHhue6Irjd8EvLMMdS09l6r7tU2bCFRtqC6FDFFOD3UGf+V pQ5khnTsIbiPEJNSKBZcBrrgTX91oUKQwyqCulGlDoiEjw== X-Google-Smtp-Source: AGHT+IGJf9SIyCsAUO2BsjPQZssC0np6oA5YVQ6v/SoODASDT6oC3lCdea6wVLEWO3kq3IVEd/rgwg== X-Received: by 2002:a05:6a20:72a1:b0:1db:ebf4:2cb8 with SMTP id adf61e73a8af0-1e1b1b98d5cmr6377173637.38.1733830596083; Tue, 10 Dec 2024 03:36:36 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:35 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 2/8] t5548: refactor to reuse setup_upstream() function Date: Tue, 10 Dec 2024 19:36:22 +0800 Message-Id: <63042f4d97a4a02e143d6f5b5b61d8158ea5f7d6.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 Tue Dec 10 11:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901347 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAAA4210F49 for ; Tue, 10 Dec 2024 11:36:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830599; cv=none; b=TpW1CZw7cM7sirt+ACNLqjdetpH20OOhxEx4zrhFT5RZUkTBesWbwlk5TD7MP+Fp4p2TSNePHfOzh5tTCxdiLRy+6OvgR2XbwBPV/g8j9kJfcu8mX0aD6KkdZfy13hUf+cCjqtOra/whcgM8j07iAHdK0R4gMXECvCiPgAWjFiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830599; c=relaxed/simple; bh=XyI3yJwfhZfLXUs9WUcLU56Qp5uDUYgMK6u6DC5bLdc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IgkX9/ZOlt4nVQM/X8Z6vqsCb2Jlz7OAsuMX9a2rqkolrfiwmv8ZfYyrR9CYF9MPRJDdTOIpyyGGYkTPayaE3wGS+/X1A+f/nhSd/tlIp063GEO7e8sIVLi9t/hwhX9N9JJ1ABZAzd/npWhrFEunVBWMOTnea+qJr06cc0rUgMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UPSuZt+o; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UPSuZt+o" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-725f4623df7so1708579b3a.2 for ; Tue, 10 Dec 2024 03:36:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830597; x=1734435397; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MaQDXOV2INt7XeUbFA1pAr8j1RYrLRtYxcrbUoSUkoI=; b=UPSuZt+oEZsWN7DKAMFi/ia0Ea8tvZ9y52crZm4p5mUqBklH0Rw9wRIV8H4He/ESq2 KOd1n3AVfDJkhKegJuyP+Y+Q0QeT/FmpAE6ArKuA6vIeK53aqUAt1ywU/YdZ3nGfdgWp vBAPHRHT/eQlbBv8IKioQL7g8qMLE8WkyieH9j/YIb/7HNIr219cwn7j+sovrKG7Fcjm nFCZ7H27h1/sRRH2NXZp0/r4bECBvBMC3ny0hsJ1qbEVZSverc6YurIbqBu1qpnwdClP BCb31Rwm+HHzWGQ9pVk3U1imp4ENhesiB98rEZ9NlHKIG17NgdHGAbwjFwapkkIDgqnB IAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830597; x=1734435397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MaQDXOV2INt7XeUbFA1pAr8j1RYrLRtYxcrbUoSUkoI=; b=Z11dP70BU1z5imTzsfxpLeY4yp+9QWaE9Qi/F2XcpftbWb30oipYODG8sOZETgUrxL SIYvVzrMp3p/obYSHwpxpWj19X4FhLhWIcHB6H7uNXojXRKokN6M20kKxRgr735qWpyd rwkWewQilKAEFo00eqlbp4GHCsme4/44ikYo11zcIA1AyUvcOSBmmiyKcmF/D7VtlrYf Pgas18PRzOtXLz0MHL9gygi7sMGI6LmsLG/i5aOF43LrZs3BaWFnqzyF0ZmFxFKv09Jl SnvFejMtYaTzeUTmBWhCly+BuhjyVjc5aVA0ACSF9KRjUBPG5eGbK9c990bGAbjManBS 5ijA== X-Gm-Message-State: AOJu0YzibY6mm2o0ysCDjR+X7xYO9iHFh0EnXRSKqo9lSPrEdQXF9Tb7 691WuV5azsGRHAlGPEBqYwPmPtqRRLRJPHBDZl+FJtQRXSki3BrW0nUFAg== X-Gm-Gg: ASbGncsa3pHxW3Dt3lASeIRRuaKxmS9WhrSbhfKGT9I1teZBpAxfYOgqPxi55L4yHqk AJjS2SFJ1FZO1hDlTrAyBlnLY6u5tZMbh7q8EMEPERsDPFlQgnPDWqGTA1FpPDoq/cFKDZddtbo a3HV86xmkNrIUP/z590juCtV3R03IhdVTjF3vKy3BcVqFNBDlV/XpBR22Cm0xJ9dnggY7flWOS4 MHqY3oaNAozCjWTnKSCbYWH9ny2xxrKRty2sgrP37ykOhQd1W+otetOk+BquZRLim2iLgBGw+dT 9Mtfi0RdWzU15n2Z3S/ty8gD0SN7ZSs4+6OMjyclWK3cLw== X-Google-Smtp-Source: AGHT+IH9omHcRGbqvN1HgSL51trii+iMaisxb1rRYTgmA7Rnce2BCHQw7PLSpUw4EyqlYxaV8HDmlA== X-Received: by 2002:a05:6a00:809:b0:724:e75b:22d1 with SMTP id d2e1a72fcca58-7273cb7290cmr6090167b3a.16.1733830596863; Tue, 10 Dec 2024 03:36:36 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:36 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 3/8] t5548: refactor test cases by resetting upstream Date: Tue, 10 Dec 2024 19:36:23 +0800 Message-Id: X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 Tue Dec 10 11:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901348 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A446E210F7F for ; Tue, 10 Dec 2024 11:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830600; cv=none; b=bG2SASyNdD6Q5dU1t2eBz10O77N8muuCY4FMs7SnH680A7qDj2vM8ptNaoUgRsbc1zRJ95b2U9W/GkJtib0392ajeEaLPeYiRwYoCtp5hURYPVxlmJs5oSYprnZXc4tQdbE03Emcp9tn3Js6jA3PBdGs0EDS2BHb6+yxJ34qu8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830600; c=relaxed/simple; bh=M8bV1CIlGHkSFEO0Am6Mp7hHFijEVzMy+ymwyThmHpk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DEwN+RIh2NqhCmvUVQYADMJp2ANSdR7sbnFAVtin4OcqWr1c1xh9CCQqxv3qpnxjp8bM/YKM/4dYRUlh5S6JW4+VqJG8ILhJcPitacz3tqAVVo0mJrjoKynzMu0UFUXFAfUOJYYtNyKqFMTy5ZH2oaf6BCLUjjSXiFnToBzqGSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RxdzutFJ; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RxdzutFJ" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-725ee6f56b4so1741755b3a.3 for ; Tue, 10 Dec 2024 03:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830598; x=1734435398; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zMz+P7c9fNk1zlAalcvH/pjmfqrBeaOCLQfZlN8gH34=; b=RxdzutFJcMYbDgih+Tnke/ZSnwNixFHOtDRQ0qlhf+qKqNPwgpNvXIoV9pk5B4rpB8 ABGBxXG+WHY8bCp37PKSRbLKMbz7fX94t6r9Tbiihk9GxIAklrnWLTLxXv2PkFLBYhvZ QnwNMm0zjJ5kRlMvZ3sz6lF889RgcRT5GdexWScAmki+ozP2nd7E5FIN/47usYp32gdi Sybaz+Hma7rpG2HMxjMEM/S7Ax1wwsDgAq1PdU+/e2o+zTEMxBdVEUBYJLWNmQHRSlR0 ruoDHQppS3f6nvZZwncRNARhgrkxW9/KprwliZ7QJG7PZ9UCvJgE1Z5vrnExjFUDlWbW eb9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830598; x=1734435398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zMz+P7c9fNk1zlAalcvH/pjmfqrBeaOCLQfZlN8gH34=; b=mSZLZZK7iUuUF9A/pX8L+hh8xFtmZiAYmH3pFXHMr1MyZ6igLty5qSYUjiKUjVthN6 I+xYVbeeQSC/L8Jj4CWs5HowbNxoYBFtgzLD3MH1cJlNHtihd2V9/89KrTeHoJaJkUTW SBoPtEzQQDinpk8LDu5eE1+TTJf1olc8zFe/ARMH78wWn3KK1XkqfHhxzeg5zO+k57QV xg2ZSFVoGkuV68366tkwOdomZ+VEPuEW7eFozJQU8NUXuGW0WleKYaaBBGf1zm4GllaQ Hk5uqtG+58+DR7HjYqwbcUTw5+SDZZY82Gt4z+JAyYaD8xo7De/RXLRELQPvNQ9/y6f/ czPg== X-Gm-Message-State: AOJu0YyV95ORdhSQVfl/SwvZsJR1nCeCKakZaww5i1Lv9NbwyxVwv5xg tZEXeHeRSKtYX5zQ1A3GtXJsBDYh6CPo7KswHhUy1kGhRVRqmb291Xz4xg== X-Gm-Gg: ASbGncu2dxXqFpTBtwdqG0/HVZtRo2SUGa/xGhKLB4pMdWbv6UGGzUtOW2zyDQK9zLz sjjm8MHQs7juzgrOUadYx3B9t+dcTk9NyPx02gbMrNxnqNTwiUZtx3IC+cbgc+pzNSDWn8771Fv MA+c3EUHAOOyEs93lr3xgVN8x9orbtxP6D+djqdZWWDTn7nvq9MznuFp8mfWYI5GNMF4pIDSVGj aG9Om/d54ExTPj9SY2zadvHmeVfcSslSU0syGMmMY3B9gLOGMJE1ngJv+7iI9H3d3Z5Kc86MHJO y4FMjSIFDihijyrdY2T4euFAqBpWXnKOwENQy037hN8p1A== X-Google-Smtp-Source: AGHT+IH21tFgZuP4/eCVPT76AKFRIQicVQSTM50Grr0JBVEa2EQbLoJIwmoQrompHBC4QNa1eHJ2VQ== X-Received: by 2002:a05:6a20:c78c:b0:1e0:d848:9e83 with SMTP id adf61e73a8af0-1e1870cc3c8mr28095204637.25.1733830597756; Tue, 10 Dec 2024 03:36:37 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:37 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 4/8] t5548: add new porcelain test cases Date: Tue, 10 Dec 2024 19:36:24 +0800 Message-Id: <26248735e1b81df8d34cb692ddd9d5fb55e22329.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin Change order of test cases and add new test cases: - git push --porcelain # failed: non-fast-forward - git push --porcelain --force - git push --porcelain --atomic # failed: non-fast-forward - git push --porcelain --atomic --force - git push --porcelain --force # failed: pre-receive declined Signed-off-by: Jiang Xin --- t/t5548-push-porcelain.sh | 90 ++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index ededd8edb9..799f6066a3 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -4,6 +4,9 @@ # test_description='Test git push porcelain output' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Create commits in and assign each commit's oid to shell variables @@ -132,6 +135,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) @@ -203,13 +240,9 @@ 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 ".. 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 - test_must_fail git -C workbench push --porcelain --force origin \ + test_expect_success ".. git push --porcelain --atomic --force ($PROTOCOL)" ' + test_when_finished "setup_upstream \"$upstream\"" && + git -C workbench push --porcelain --atomic --force origin \ main \ :refs/heads/foo \ $B:bar \ @@ -219,10 +252,10 @@ run_git_push_porcelain_output_test() { format_and_save_expect <<-EOF && > 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) - > ! refs/heads/next:refs/heads/next [remote rejected] (pre-receive hook declined) + > :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 && @@ -230,29 +263,37 @@ run_git_push_porcelain_output_test() { 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/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) next(A) - test_expect_success ".. non-fastforward push ($PROTOCOL)" ' - ( - cd workbench && - test_must_fail git push --porcelain origin \ - main \ - next - ) >out && + # 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 + 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 [new branch] - > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > = 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) + > ! refs/heads/next:refs/heads/next [remote rejected] (pre-receive hook declined) > Done EOF test_cmp expect actual && @@ -264,7 +305,6 @@ run_git_push_porcelain_output_test() { refs/heads/baz refs/heads/foo refs/heads/main - refs/heads/next EOF test_cmp expect actual ' From patchwork Tue Dec 10 11:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901349 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3B98212D75 for ; Tue, 10 Dec 2024 11:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830601; cv=none; b=k/eG52SoqK5y4s11vcOKITnustyQYG92D1nvH8tPnFLF5QrfblwngaaulTgxE2qybVbxeO8icrVJIUGwsCEPveSYj0yVPlDdCBQxvfdGKyjY5AnU02ECeJOvz2FLD7r+RcuZnnGzWLq2faHScyXwyJGTNeuP86u4FxVHlJeG4h4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830601; c=relaxed/simple; bh=7d0v/fW2aB00bJFmfvVyS4Q+inPguWQFl7wcOxNzL8M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WdiVlV3JLXJwg3bxhJAJbkeAw6tkGCbYrnIsqho7JLHJqUKUQCJ6aqqzP6T3sK9AzUWzXdJUHJ8WT9gGs1p8kulwtfOBduI3Ycp2BKuyQW0PypittIeg7x4B/e2VEQBbgAOfik6XzgoGJVTn7aRZbg9p96W1dEH+DcQLcEiFu/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bTOXVTo6; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bTOXVTo6" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-728ea1573c0so33775b3a.0 for ; Tue, 10 Dec 2024 03:36:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830599; x=1734435399; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8m0Jv3x4S5mP1SNWqB3cmjfYtz3xeIJv4zIjzXdeCK4=; b=bTOXVTo679629gxMuGjeXmJtAy3AjitOs5+ahfARiwHZg6jpSRxYgzw+0Ynkd52Ho4 PbeorV2IuGwSo4TUkEHEgdTIWilqoCnqyR9oMLU6XPPavFulKRbyHviwSMq9nHRXUTLi TQtJ5iYg/SWr+iTtZHa4be7oqh+WkMMeyp4iOkohI138reu4USoLNnIFgwxe4lt4L4dC BK7OVH2/WADL/72u9pGSDU95iKL9MEFDoU3pmfYovUZtP4yaJf6p3ZSDbEash5DEzMJq rQUCa8iN3bDDKtgzVxgDQStoHV7OApbC8HmVqlbUHGBzFsoMlP6M5kEOQLAvxxHPom2v E/iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830599; x=1734435399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8m0Jv3x4S5mP1SNWqB3cmjfYtz3xeIJv4zIjzXdeCK4=; b=BhoujCsTYXjCQZ4m0sgqqJejn/7eQaaEv2JLTfiuqkdDdq+DCDtl3mXhbxD7pwxwkS tGWaHMyKnomB+ztni2kW/Iy9yDrCe7ONVcdpDOAHKeDzpnG2LnWoH3AxgfchL006cXU8 n9pJf4YUrcXRifw9lILgQxjNe0YZ8GIsogwSeGKWe03RI0ZAotzHev1lng9geZ3mYMwF RVxkdJJecES4WH5r5z7c5P6jMoJJ/jDvwCq/OmV+MqgxGpvmJHFf1Gm1AC2BsP7j/hTG VdZIBYajrIWb6CDI7WGy8rCeKD4FmqoeUR5RM8BpnHDriEI+VeNWTV7+48q+V1hh4wcE uaXA== X-Gm-Message-State: AOJu0YwRQwM19aLD89Aspin5lDkc6rDzNyngz1SI2E07h9d9A8GozcLC Xqwg18MK0nlEFDyonDC/Kq3AGVO5l2ufS8yrD/4m3yjSqChb9tbAKJcaSw== X-Gm-Gg: ASbGncvadHnOiMP+lTy400MO3oUgobPbhCinHxRiKelw8KoEJMJjeOGJ5iROhvRzDHj L+S/kOm6S4tLhvHBQeml5Ijz9oIZRiXvean5FxEWzlyb/lycaKUd7cKsf5vV1tmoTWsHe31QotZ /NIkMNcVJfkwPLym9O06l58ywy1dSHKslW7Pe1RZTe3a0gRnh5KmUX6B6Wtv9Q7je5tx3IOS0Oo X9UDhNxY5nF17Gpt4QfshKhJKUimF0piX8v7ircUMfcRMjpvfyT0OiRB6gBSnkhFkfjLqKTGNrw TdjxrrJ93Ckvl7zKnT8LluNZKjoqFhkNvw9x50uNR6kKzw== X-Google-Smtp-Source: AGHT+IHUB5KXRfVAokENtxzUceSSdLuQE1Pot7OY2yn3A/9+pnOAGpB3uUaJFL90kO0alyjXIaKdpw== X-Received: by 2002:a05:6a00:3c8b:b0:725:e057:c3de with SMTP id d2e1a72fcca58-725e057cd56mr14175635b3a.23.1733830598639; Tue, 10 Dec 2024 03:36:38 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:38 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 5/8] t5548: add porcelain push test cases for dry-run mode Date: Tue, 10 Dec 2024 19:36:25 +0800 Message-Id: <93123988ae00d865d0251ca0667c4f4584772021.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 799f6066a3..ba68808459 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -310,10 +310,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 @@ -325,4 +474,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 Tue Dec 10 11:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901350 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 933BB210F6E for ; Tue, 10 Dec 2024 11:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830602; cv=none; b=rsIAzJDNcxv4vI+6N5d0lP+5RbECnbdqb2kUbn7NNxa9frAE0SViMFRgkxKo53zuQX936+4gI+axWWxpXASm8yM62GC1rTj/4WHGOamzuaWsOYwgFNlorfzOLFdq5z/3DTmq2Bd6gFtIBoMAx1Jp0zfxTdfaOHdTBqT4FR0+vbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830602; c=relaxed/simple; bh=6UZ6NPaB93dwITRwaQEC9l1HrfmGkEvslrvsJQs4cSc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M7xvOYJraOjc28ePUkFTns+UMbRHipe87e3Kj0Zu3GcxlkXEoFjhio27B4z8U+6gbS3F/hLtnhca+y3n3mmF74RycmsSnZF8gBM+63UY+wIv8wCo3kpz9Ak+7uwn81FOVnTDTUItkQFfAIlIACrvMZij53BtXL1sxdL7DBxpu9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DNho3vD5; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DNho3vD5" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-725abf74334so4440817b3a.3 for ; Tue, 10 Dec 2024 03:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830599; x=1734435399; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q4NGtyNaxxvQ0Fi51uChUd3uXGsfuST/Ggr61mmi7oA=; b=DNho3vD5OF4dyXz9iwTAl4gNesuiqknRgukH821xenL9IRmf7VB1/ogn82yYgIW5Ug W/eHJbMwbg3fK7bdHnddI1SdO8ZuUYgWY2f8UCI9ual0t4wVo3UEODg93rXHFOxb6dwo 6BX7i3lrblrUg2iGCw0KppF4FLE72LVWtFy+jhWWYUCCM0z0phEfI8ky4PJefUE5sl29 ArynUAk3nGlJP4ddq/Nf6E0LV70Pa7QZ6khdOJYIVmal9aHIc1F7boWMRmBtjZmwT5aX fkpnUjGRJrISxnFWvcvhPqzgJ0oYArbu+G6Pja6dgwzSE1YoOoOzAcqwtq3BPrXDyvre waew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830599; x=1734435399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q4NGtyNaxxvQ0Fi51uChUd3uXGsfuST/Ggr61mmi7oA=; b=rPPafmyUkV7yeg05jTPp1sOwTITU966dBfelcSr5fT+rjQTd4spcmz5HVXX1YxiT14 DH9T3++CKfxEeyFUPZH92t30eoLo4FRdinYkdY31G0LsmVIr8S8iNY9ozVP1N0Scaz/i epTORSeFRO/1Igyp8SVghGTyRKXPCbSQwwF5uG9gIBkN9XnMHz4Z5IkUWc4lzywPKU9V gSZ5K5DtdsOdLSbRzKXuf5x5Y1JM+bH1NEEy5nJAagSssiuOuOeJyYwWvMCKvoKCJuQE /qnLoLDUwpsNwMe/k7gqpj26ZOJK71FF64dDehb0w2Rt9dgo7ZpjpLG2pooA74aDTLfE 6Feg== X-Gm-Message-State: AOJu0YxGVZk4EFKR+HVmO3MLveRoqkEMlqWI6101LaVd+UTrpk23SaDU zBKXGELgY2vvFyvwv8Usr6Dzrtv2FYYTZPQkTKOuHm6opdQriIohxH1prA== X-Gm-Gg: ASbGncvrumhVKt+VdJZcT0h/PE8ZDDU7FqQWoqS3i94ZaKkAU3eczd0DmJCmn2ObwOC boXiFyoNXiiWLAm9wa+o70xJlAtTvuM9UDZiemhlHIg6VWXbYLyogcCKJtkMoSklqIpIKhhZkwR ts1SOMG5+7mQ7CiDSRP7GS6EkTxixgzAu6nrFZyxihCXfQmeCF/mM9oFjyahG/3LAGEKI5z/iLC yShe4BsIkV5XkwMzaZsg/aOH43IPVSQtdMGhHMaqpu/C6MDNxBrqU5Yop+Z9TvF3oT2N3kWZeut TQ0LQEhwe3Mb08+x+rWjDPjfvP8XpnSMxQXuHqZ9zaE17A== X-Google-Smtp-Source: AGHT+IFQtdp+NeT4B/jP+VO41ToWdpB30XFHcpyGyQT6sK9eZHxyfse8AJb/dwkDE8ujjM8W3T52tw== X-Received: by 2002:a05:6a00:178e:b0:728:e196:b5b5 with SMTP id d2e1a72fcca58-728e196b7c2mr3321764b3a.20.1733830599589; Tue, 10 Dec 2024 03:36:39 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:39 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 6/8] send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS" Date: Tue, 10 Dec 2024 19:36:26 +0800 Message-Id: <77f5e128fc1b66a9c8b0df3ce274a98921800685.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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()". We can choose to ignore the specific error code in the "git_transport_push()" function to have the same behavior as "push_refs()" for HTTP protocol. Signed-off-by: Jiang Xin --- send-pack.c | 9 ++------- send-pack.h | 3 +++ transport.c | 7 +++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/send-pack.c b/send-pack.c index 6677c44e8a..f1556dd53c 100644 --- a/send-pack.c +++ b/send-pack.c @@ -630,7 +630,7 @@ int send_pack(struct send_pack_args *args, 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 */ @@ -761,11 +761,6 @@ int send_pack(struct send_pack_args *args, 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: @@ -773,7 +768,7 @@ int send_pack(struct send_pack_args *args, 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 7edb80596c..ee88f9fe9f 100644 --- a/send-pack.h +++ b/send-pack.h @@ -12,6 +12,9 @@ struct ref; #define SEND_PACK_PUSH_CERT_IF_ASKED 1 #define SEND_PACK_PUSH_CERT_ALWAYS 2 +/* Custom exit code from send_pack. */ +#define ERROR_SEND_PACK_BAD_REF_STATUS 1 + struct send_pack_args { const char *url; unsigned verbose:1, diff --git a/transport.c b/transport.c index 47fda6a773..454d7f21a9 100644 --- a/transport.c +++ b/transport.c @@ -914,6 +914,13 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re case protocol_v0: ret = send_pack(&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 Tue Dec 10 11:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901351 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6349F2153D7 for ; Tue, 10 Dec 2024 11:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830602; cv=none; b=EhpylAv8Q70EnyOaa4qTeiVOWKfRzuIPJCvXvDx7fgURQzj3Hyzk7/qUCETa28o6HvvBMy/002DsKOq7en1Qh4/4ZYKsqvB1kn8jvwcRpvQWjkMbuJvO8D04nz7GC0JPF3qB3W2Me9x3f8amfBy3e/tv1E5JINYWqp8zgTaFPeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830602; c=relaxed/simple; bh=12HyVJEPaZU7CJGSRJ+apTWgDxiijhUVgWTbYvHa/aE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SnvmyjzANk0ZonG46IIGiZ0rsc/BfSmjMF5Fze8c3dFRXN4pQkzAZrx7aLvgmIeQ0iMb3CN7phwXD6BC4IpBSoGk52nengsGfepMcozNRN49LesRmsbujkRrvj/l12ePrQG/eINY7vZ2oU7PrWaYjiuJ53o94HdpkV48/83LRgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gieHqF2w; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gieHqF2w" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-725dbdf380aso2136449b3a.3 for ; Tue, 10 Dec 2024 03:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830600; x=1734435400; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fXa6+0s6oflD6keUk9vHi1w4s5eMXdsBz3MNKHzZCJI=; b=gieHqF2wQmBNV/osd20ufPnHGF98y+dH++jTo/ieBtAjl51nmgl3gzuNXyrDYl/qHu X+WrCxdHYQI2TauL2xXxgAqE28DIWtLUiikW6KnsFnAXFOuqoVm1qNHlvpxOIWtD89qk YmI/Vb3cB0aWgI/EU5bv6B8YdY6diYx9gt9iUPCQrFbb35Tow4Hl3lBO9evIcaw81t3K PTUUSBO/qHV4apYQNAcucjTO2mFIjr4NlpYHWG0LB9S+P4UzrRU+FgllvXaLG+Znpy0i Kyg7vOUs29ESs0+9XLMoEyxLdCa8+qQESEfea7wTDV12KOrTCYQPLiPIeSBcLKIn4d2E Qi8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830600; x=1734435400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fXa6+0s6oflD6keUk9vHi1w4s5eMXdsBz3MNKHzZCJI=; b=Vk47qe9PERraOvXbQGBOe/+g6TBvl+sBtXNnBYZRs4SQ0BsHM4kFWC88+hIoncaIUv 6vW8DYTPmjec513z7VDATdSkQcE4qWZmqeSieG+96C7booJBUG5rH/Lle8QRUFB5hPjW EQw49vCGg4JBuYhQgAUJNEDuq0rTQfJRkaAv2u7ZaWy33oWh/aRov1+ghTej8gLr92b4 to5tMK37apP/+1XE9/hNAhIoXyOpebaZEmrpEem+ji1sGDsR3CsDtkI462G3wH6kUcyk x0XJiJVArxTL25npWJbDq7ZAUW59OeJAc1i/cjAibiBbi+tfqJOJ9LhFw4nbxHETMLj3 PP6A== X-Gm-Message-State: AOJu0YxG7psSC0LRB2Ia0MHdEx/4GV0Pqzo/dFcFPsAeldpJIjN+x929 8SuSy9tPPVdxV9DCPINJZ7nbBuUPUQ5WV0OCIY5QiXRuwncpUDxLVNCkYA== X-Gm-Gg: ASbGncsprV+0UpLCPImfKzLWCRzSV6ayDZTbNK+IqlLwHUt93kGYDpOW/xpLHklPQzB b6nSsGsBPHxc0SyDw9XAOLpXOI9eQ3KqO7Hl9CsddUskqM54f5EYrDYm4fyguwlRTcWzbQmVI0M WysXmxH/Tn8paN/8juRwiwvM3u25rBgwYg1GAE+gV1EIwfINPauZhlqXV50KNEAysRQaxny8lmQ jv1QtJKbKCyXSgTC3uARQHXkmusKpO36rZ+vAgA/2CamrSzX/sLQ3k2WJU/H0mHYnmT6PJsVod/ L0JYMzX/7VIVSKh/sgWIevcrMcET9yHzFo1xPUgesrSOLA== X-Google-Smtp-Source: AGHT+IGzGmGIqyzaewz1sFT1w6BEts2zpLTw1O+ubEgeloPJ+N3FiKg4fbBVcS++3iTcZ5gLPWsmog== X-Received: by 2002:a05:6a21:6da5:b0:1e0:dc06:4f4d with SMTP id adf61e73a8af0-1e1b1b09c09mr5999301637.19.1733830600393; Tue, 10 Dec 2024 03:36:40 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:40 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Subject: [PATCH v3 7/8] t5543: atomic push reports exit code failure Date: Tue, 10 Dec 2024 19:36:27 +0800 Message-Id: <7c78dbeffb24fc84e5e6d5e01e77c58324bf60c9.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Patrick Steinhardt 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 Tue Dec 10 11:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13901352 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CA812153E0 for ; Tue, 10 Dec 2024 11:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830603; cv=none; b=X0+3r1VTi9yWICS7xiZo/zfXq09M8yNsQ6RGs7IllWfXolsuBiHtcZFu357d4nb/Oz6sXELSqdjSOTHdt9iMAm3BLTTQBnjR4m4RyZhpaDZEvi/MzfwzWm9WmvEvLeWy6nKDdmJCOW++OdLMse5O/Jy7ymbKvP6EOKdJx0xLzOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733830603; c=relaxed/simple; bh=4AJjp5NEYD57d6mXZJ3ghfxSl83DBakKzl/Ap9JPveg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o4obctEQ+9SNBG2n/tOySlpMt8Pb03w6YOrfbrDexXWYkaRojkGhdmseBmQ8hzm3i33CrXgOeELkjPfs8KoHzs/GGd6vdyj7ZyyhxwMB/ELUI9pOFRgy77vDLUdqMAFFsYy0FJsaLccU3F1oMSQMLT6odlWXSM99goCajdHD8QE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IujrVA09; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IujrVA09" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-725c0dd1fbcso4078203b3a.0 for ; Tue, 10 Dec 2024 03:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733830601; x=1734435401; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pe7ZyQBCVv0j0c8ENPnGXLTKP0BIlSrKVTnOl5E3xN8=; b=IujrVA09+/zrxv/dQ8GcKaCPDrbYLRbVfgHQuA1Ck5lZlapqZgYXFBK2TJhYPFdRL2 1AzPDE7Yx7MsjdbnvnphHqVEVJVBVRqcpp2tcIMyXEmUiJUAAIMiVhlNaSTLUOimBHcN Qjw9hVNSIk/0PgrD10w1IQNtkUai4gaF913UthEI321qUh67Q3szVbNq0XjMEy1eb0wX NTCHzBPogIphxLydzCkovWionGIwvFKQ9tWwrFqv09LQTKNJIwmETKgZmEG2Bafmrp9i NO6Ctqr2kpSWhl3bdC0Jsv/J8RbhzjKxKdE1CRQhutuko+u8MQw0qmISd/m1d2snZ1op i9XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733830601; x=1734435401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pe7ZyQBCVv0j0c8ENPnGXLTKP0BIlSrKVTnOl5E3xN8=; b=YOExP3DYFKtuM6EWrVMT4bmYNUNdKWwoyRiSuaz2i7Qlik3EkF0XnChAFSOnmhKaWI OL9n6ZCIiocPeZkyAWYeIsTJvWJ9v/S2zHuHCP4pZ6uMeUkfG1gs0EhEgaRxDTlSlXBn 2rqOuxcH5J+7Th4P33SFvmrUzCy5E1Y0qg5MnnKAWWxaEAWWNfrReEKj9tOGRPBfNWl3 8y5HoUrEBiDY2Wvkv9CK7clS7YyV0o9PnuAhrUM334WKIqtMYh3KHRnyc8WoBlHhIrJe PhUBJSjZDfhdA+p/HVVI2Y9RjKAtZUXNrgO84O3K4xRRdecbCHXFxqEFpNRagSS4dNy3 UohQ== X-Gm-Message-State: AOJu0Yw9S3qcVrY9hcn8PhzM/FO9hGyA0T3g5G99ya28h7NkDEcpTBah +iC+/YShcPQscpseJU+DS3wm1gCG6d81o4h/4hYj667MA8/fX6s7WQ4jDQ== X-Gm-Gg: ASbGncs0geVZBPkwZNeU/XUx7UHdZKocqF/c1NN7Ckdtbwx7bdJwMXxVtRyr1kJRyPA wRtxZ8QMNbfCn+74YMr3Pv5Q0a5oxvfYRwf+QsfphOGWmo0OtDN9oSFETEUsbAmNTQnaw5pGMEB cVWivwTXNRgUo6y08GqNfonULwa/ST3XguU1TQXsdcWyXH9sqmHZOnwkSFb5u7nUhvFS3UWLgIT SWkLBTlXdgeMbkuNHsQMsLycfX8b2Y4brSt6y2EfQU5l1xXqCqygA2vHj1ZEO/ryhqJCLHQAIvD kN/QrChtSK65CDoKC8yJyv0OWW/WGkztA5qP5B0wtQ1X/w== X-Google-Smtp-Source: AGHT+IFPKA5MckoIbPqpNPmTRuYHxMRm7WTw31DBZAcX4C6QYzpG8VBCkB0zzUOjINzOz/R7/CMOsQ== X-Received: by 2002:a05:6a20:a11e:b0:1e1:aba4:209c with SMTP id adf61e73a8af0-1e1b00953d3mr7572731637.29.1733830601248; Tue, 10 Dec 2024 03:36:41 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd54aa2399sm2554532a12.39.2024.12.10.03.36.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2024 03:36:40 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt , Junio C Hamano Cc: Jiang Xin Subject: [PATCH v3 8/8] send-pack: gracefully close the connection for atomic push Date: Tue, 10 Dec 2024 19:36:28 +0800 Message-Id: <9f49278ef108f08d512ee13128ed8277e12c002d.1733830410.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 f1556dd53c..439b249c79 100644 --- a/send-pack.c +++ b/send-pack.c @@ -631,6 +631,7 @@ int send_pack(struct send_pack_args *args, 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 454d7f21a9..afcbca293b 100644 --- a/transport.c +++ b/transport.c @@ -928,15 +928,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;