From patchwork Thu Nov 14 17:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13875513 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 BB64217F505 for ; Thu, 14 Nov 2024 17:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604547; cv=none; b=tSCSyyQ6gPXlcvGaEaf0FH02VDd/aiJ2Xk5MxnLYE6glqEKJydqEjM5V4dgjdyCnr6CwJowBRpVjKQQsnTxRQKc/u8d12kogww4bUd0MQ5K++3eRQ4chRao384xH1OdfiKh0u1tDTHj1r77jnfRaH1ZlFBy9VyBXtWeoPHY5AZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604547; c=relaxed/simple; bh=paJveZDcbGVBMLV8JJYuuHTuj+aVEzGKQBavLGN9REM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ba6JaqFtL8s3bsmsetX0tev5PS/CRH95G32p1gw5o43CmH4aBIHS1ifdUJsgpbc2oaDcyoAH8HyDqs2zX7+aYot2tVz6SwR61ykAzRy9jCF3q1OH0ePX4haMX9DFKgSSW8hPki+9vFjQD4mJKVparKvWb7FmUX90rskguHyrKPk= 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=NtwajdNC; arc=none smtp.client-ip=209.85.210.171 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="NtwajdNC" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-720c2db824eso821152b3a.0 for ; Thu, 14 Nov 2024 09:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731604545; x=1732209345; 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=QIJp1pTxifD91vkvjwLE9iVleWuMfYTuhc6kABmzr/Q=; b=NtwajdNCZ7Og8MDK0gpyT8rxL3xSoCCtx/mRlUIu35y1eHClEpeH2yE1tWODLlVlNu nNsY4PkT/hglBBppknZj7GrVtvvCdY21HzBFN0wNxJmS3GMUJ0N44L9kgZGdZl+uvHW2 M6SUh0GG+HkdWz1PNSho1KToimDef9lZjybls5wQFWYfAxnhbAwi7JCh3mlHrYjMMH6z u8gAu7dxMy9aq1GRawWZ/E1OPxtb9jhs1Tson4xyH5q+FaUuwuYfy3Ky1/HT9oBQIToN KnT7MJ4rpFmP3uBADJYdRXSkvlwFxdNigF3fTXn6pdiMfqybKTpBqZFIe7/DrxKowBi7 g0+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604545; x=1732209345; 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=QIJp1pTxifD91vkvjwLE9iVleWuMfYTuhc6kABmzr/Q=; b=EWOEu6iwN0pU2Cc27WriwWfrARxkPT2uNMC6+jQpg5DpnNnxsZA+m4mBsv61mymKPO 9K0XGJ+XJkBHTh6jaC4YuefdKpjNVXcMnmxQhBwGg6LbWD+PZgC2xH6UqZ1f4lIvt60i aP+iHjyuC9nXrchpzp2901v1oYwToJhWhCevF8/jdu5z12vdl7/zYn56i4Bem3AdSC3D bv54deuR/8z3kPjy52bOu6DlvNhSIMaHENA1fg+PlrZFQVcCHbRb2h6r/e/PUWzr9LSi cC27rOu/sbXeQwT+lBlkNH/slVsHLf7v122wJLs/pQFdmuA+Lq0wYMQG6f5uQti9eU3s ZuPw== X-Gm-Message-State: AOJu0YyHvim2IcHirpdnszYUu/7BU8MasKhpMl09BzS02Iq5k4e40jQ4 VVC3y+26P9l34JfxC3KVWOQtbc3zakWCzMLwQZy8wQo8GhtT6xO5KbwDIw== X-Google-Smtp-Source: AGHT+IE2322An+GKLhrcaTQ+Xl8Rm7kjoQnb3ZwH33LF/FcSK9JvR+y1doMYrcirnAaoSBb2o8DOvw== X-Received: by 2002:a05:6a00:80c:b0:71e:68ae:aaed with SMTP id d2e1a72fcca58-7241325f63fmr31228153b3a.1.1731604544568; Thu, 14 Nov 2024 09:15:44 -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 d2e1a72fcca58-7246a9bab91sm1539883b3a.149.2024.11.14.09.15.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2024 09:15:44 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt Cc: Jiang Xin , Larry D'Anna Subject: [PATCH v2 1/6] t5548: new test cases for push --porcelain and --dry-run Date: Fri, 15 Nov 2024 01:15:32 +0800 Message-Id: <7cedfd718c4f2d6fed7420a3341e82c9287d2085.1731603991.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 t5548 and add new test cases for git-push with both --porcelain and --dry-run flags in order to cover the issues reported by Patrick. When executing git-push(1) with the "--porcelain" flag, then we will print updated references in a machine-readable format that looks like this: To destination = refs/heads/noop:refs/heads/noop [up to date] ! refs/heads/rejected:refs/heads/rejected [rejected] (atomic push failed) ! refs/heads/noff:refs/heads/(off (non-fast-forward) Done The final "Done" stanza was introduced via 77555854be (git-push: make git push --porcelain print "Done", 2010-02-26), where it was printed "unless any errors have occurred". For the purpose of the "Done" line, knowing a ref will be rejected in a --dry-run does not count as an error. Actual rejections in non --dry-run pushes do count as errors. The new test cases will be used in the next commit to protect the above behaviors of porcelain output of git push. Reported-by: Patrick Steinhardt Signed-off-by: Jiang Xin --- t/t5548-push-porcelain.sh | 338 ++++++++++++++++++++++++++++---------- 1 file changed, 250 insertions(+), 88 deletions(-) diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index ecb3877aa4..ca5cf684bc 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_PASSES_SANITIZE_LEAK=true . ./test-lib.sh @@ -56,10 +59,10 @@ format_and_save_expect () { } setup_upstream_and_workbench () { - # 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" ' - rm -rf upstream.git workbench && + rm -rf upstream.git upstream-backup.git workbench && git init --bare upstream.git && git init workbench && create_commits_in workbench A B && @@ -68,19 +71,29 @@ setup_upstream_and_workbench () { # 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 update-ref refs/heads/baz $A && + git update-ref refs/heads/next $A && + git remote add origin ../upstream.git && git push origin \ $B:refs/heads/main \ $A:refs/heads/foo \ $A:refs/heads/bar \ $A:refs/heads/baz ) && + git clone --mirror upstream.git upstream-backup.git && git -C "workbench" config advice.pushUpdateRejected false && upstream=upstream.git ' } +restore_upstream () { + test -n "$upstream" && + rm -rf "$upstream" && + git clone --mirror upstream-backup.git "$upstream" && + git -C "$upstream" config http.receivepack true +} + run_git_push_porcelain_output_test() { case $1 in http) @@ -96,19 +109,46 @@ 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 --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 @@ -121,39 +161,137 @@ run_git_push_porcelain_output_test() { 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 + ' + + # 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 restore_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/main refs/heads/next EOF 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 --force ($PROTOCOL)" ' + test_when_finished restore_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 - > = 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 .. + > - :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 && @@ -168,34 +306,60 @@ run_git_push_porcelain_output_test() { 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 "git push --porcelain --atomic ($PROTOCOL)" ' + test_when_finished restore_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/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(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 && + # 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)" ' + test_when_finished restore_upstream && + 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/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) - > ! refs/heads/main:refs/heads/main [remote rejected] (pre-receive hook declined) - Done + > 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 && @@ -210,39 +374,39 @@ run_git_push_porcelain_output_test() { 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)" ' - ( - cd workbench && - test_must_fail git push --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 "pre-receive hook declined ($PROTOCOL)" ' + test_when_finished restore_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 [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/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 && 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 test_cmp expect actual ' @@ -264,10 +428,8 @@ start_httpd 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" && - + restore_upstream && git -C workbench remote set-url origin $HTTPD_URL/smart/upstream.git ' From patchwork Thu Nov 14 17:15:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13875515 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 F265818A6AD for ; Thu, 14 Nov 2024 17:15:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604549; cv=none; b=AC+jCA3u4GK4kiTFprj+2LRbSgtxlqX3Ae/wkrCjOMfj+iWsJJkRk/OOgsntcoYsVoF0uPAehoyMDKFd3THLAsvZMiePEr6MzfPp/5s0G5v44VTurCvN7ZPcBTKTu8R+Lk35UBLbHmqX5qwfrksRS58HgLIjNWjgeRyI03nUSbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604549; c=relaxed/simple; bh=9+IhYtjCrh3yLDjOwzciHeVQHjS5kV8KhSvvSq+zkoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MLn/SrPINpqIHh2XTe0qBCjfkeffeDOhp6x7PUjVlb2S+YCqzqb7FLuJueb4wUTmnIGujuZiEQEeU2reDjqGmV9dK+D599OplnLL7x2Ryy+jo+i/xEcVXakG+PPY2NGoc0mV19eP8IqBY9O0w0kc+SDPpa9TJBjxFlGSL/1dK88= 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=K8+uCWeg; arc=none smtp.client-ip=209.85.210.182 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="K8+uCWeg" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-72061bfec2dso650742b3a.2 for ; Thu, 14 Nov 2024 09:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731604546; x=1732209346; 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=wNJBxIWkBL/An0Wg6ijAitMSxTHjCH24xATqohL3GKk=; b=K8+uCWegEWR252OqY6oPAJAf0hY5Ipor2A4h1B8I02DGHWYrYHtSVpa9f1couvc6h4 xo2LCe/PIvo1NbKE7FBQHuYEhFrTtBZnbxRze0I0iFszujtWjYyJiOGMS9gqj42bi1Lg WWmWnN/brIwYx77EgIs2mbYqGO99/d1agg7nHa1DWBXulLXWlFYfA5B3PZDxhVJ2P/Op v0a1sAPRNDmxAJfeIkXY2nW8UvsY3kFZOeokpKiH70pxh4FdI8IiBJNM8O3S5hCbT+4T 6e5tgTpybMguX4eVoFy3BTowxWkUTkVmxj6oBJLBTRxfC/abJQsXQ2Aqyk+hMJGlh3BR MNvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604546; x=1732209346; 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=wNJBxIWkBL/An0Wg6ijAitMSxTHjCH24xATqohL3GKk=; b=vK9s39QT44YkxF/62h3Xdwg1/FP8sHttFTaEvg5GfS76DYfE9JYWsyGHBvdyFAdphj YH7qYApUZW9iBVW4Rdxi/0TEMqQ7fl7N38LCwMdWNljjaTJdhjE6hhuaFAXk7BU16EPs IlBuhfgrI5HXGelmw5bKoV2VT7ZB6QG+zFw7PAK45MziHmKuInCOdBoiRfb7PWT8egAj KKjeKTFNodr9hUbFIZislG6Bq/UhgtaQ+VQc0XTdkqC9GRkhYOA1AYG/jVfJV7LbsONZ 7u/urROSMio+7/9dNBtHzWirgjymD1u91GC3A11nthxajntmuszRA56zIdVscS0KEBNH suKg== X-Gm-Message-State: AOJu0YwyP4NZh9LghfmIrhVf1UgSNyiYDqE9DPNbYbl8BrAt+66xTHjj yUZb8jT3G5S02NPnac208O/J0xrMUWjYABc+6HQtaMflC1DqxUUwVTYjzA== X-Google-Smtp-Source: AGHT+IHIszBYW6viqQPqVMk+sVxpRBGnxXqCngjKe+RbuhPyPguK6eq4s0vsIivfET6YHNCmnlU91A== X-Received: by 2002:a05:6a00:8cf:b0:724:63f1:a520 with SMTP id d2e1a72fcca58-72469df055amr3337748b3a.18.1731604545697; Thu, 14 Nov 2024 09:15:45 -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 d2e1a72fcca58-7246a9bab91sm1539883b3a.149.2024.11.14.09.15.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2024 09:15:45 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt Cc: Jiang Xin , Larry D'Anna Subject: [PATCH v2 2/6] push: fix the behavior of the Done message for porcelain Date: Fri, 15 Nov 2024 01:15:33 +0800 Message-Id: <9dfea9953c2a671600beebbaa0692a1e68afea34.1731603991.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 When executing git-push(1) with the "--porcelain" flag, then we will print updated references in a machine-readable format that looks like this: To destination = refs/heads/noop:refs/heads/noop [up to date] ! refs/heads/rejected:refs/heads/rejected [rejected] (atomic push failed) ! refs/heads/noff:refs/heads/(off (non-fast-forward) Done The final "Done" stanza was introduced via 77555854be (git-push: make git push --porcelain print "Done", 2010-02-26), with the following behaviors: - Show a "Done" porcelain message if there are no errors. - Fail to update a ref in a --dry-run does not count as an error. - Actual rejections in non --dry-run pushes do count as errors. - Return a non-zero exit code if there are errors. However, the behavior of the "Done" message is not consistent when pushing with different protocols. This is because the return values of transport->vtable->hush_refs() across different protocols are inconsistent. For the HTTP protocol, the return value is zero when there are no connection errors or protocol errors. We should reference the return code of push_had_errors() to check for failures in updating references. Since failing to update a reference in a --dry-run does not count as an error, we should ignore the result of push_had_errors() when both --porcelain and --dry-run options are set. Reported-by: Patrick Steinhardt Signed-off-by: Jiang Xin --- send-pack.c | 11 ++++++----- t/t5411/test-0001-standard-git-push--porcelain.sh | 1 - .../test-0003-pre-receive-declined--porcelain.sh | 1 - t/t5411/test-0012-no-hook-error--porcelain.sh | 2 -- t/t5411/test-0014-bad-protocol--porcelain.sh | 9 --------- t/t5411/test-0021-report-ng--porcelain.sh | 2 -- .../test-0023-report-unexpect-ref--porcelain.sh | 1 - .../test-0025-report-unknown-ref--porcelain.sh | 1 - .../test-0033-report-with-options--porcelain.sh | 1 - t/t5411/test-0039-report-mixed-refs--porcelain.sh | 1 - t/t5504-fetch-receive-strict.sh | 1 - t/t5516-fetch-push.sh | 3 +-- t/t5534-push-signed.sh | 1 - t/t5541-http-push-smart.sh | 1 - t/t5548-push-porcelain.sh | 7 ++----- transport.c | 15 +++++++++++++-- 16 files changed, 22 insertions(+), 36 deletions(-) diff --git a/send-pack.c b/send-pack.c index 6677c44e8a..4845f63737 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 = (args->porcelain && args->dry_run) ? 0 : -1; goto out; } /* else fallthrough */ @@ -760,11 +760,12 @@ int send_pack(struct send_pack_args *args, if (ret < 0) goto out; - - if (args->porcelain) { - ret = 0; + else if (args->porcelain && args->dry_run) + /* + * Knowing a ref will be rejected in a --dry-run does not + * count as an error. + */ goto out; - } for (ref = remote_refs; ref; ref = ref->next) { switch (ref->status) { diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh index 373ec3d865..5ff901454a 100644 --- a/t/t5411/test-0001-standard-git-push--porcelain.sh +++ b/t/t5411/test-0001-standard-git-push--porcelain.sh @@ -73,7 +73,6 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' > To > :refs/heads/next .. > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) - > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0003-pre-receive-declined--porcelain.sh b/t/t5411/test-0003-pre-receive-declined--porcelain.sh index 67ca6dc4f8..f4cdf9db42 100644 --- a/t/t5411/test-0003-pre-receive-declined--porcelain.sh +++ b/t/t5411/test-0003-pre-receive-declined--porcelain.sh @@ -18,7 +18,6 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" ' > To > ! :refs/heads/main [remote rejected] (pre-receive hook declined) > ! HEAD:refs/heads/next [remote rejected] (pre-receive hook declined) - Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0012-no-hook-error--porcelain.sh b/t/t5411/test-0012-no-hook-error--porcelain.sh index 04468b5018..563de67859 100644 --- a/t/t5411/test-0012-no-hook-error--porcelain.sh +++ b/t/t5411/test-0012-no-hook-error--porcelain.sh @@ -17,7 +17,6 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/ > To > * HEAD:refs/heads/next [new branch] > ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual && @@ -52,7 +51,6 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO > ! :refs/heads/main [remote rejected] (fail to run proc-receive hook) > ! HEAD:refs/heads/next [remote rejected] (fail to run proc-receive hook) > ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0014-bad-protocol--porcelain.sh b/t/t5411/test-0014-bad-protocol--porcelain.sh index 298a3d1fec..096f13a832 100644 --- a/t/t5411/test-0014-bad-protocol--porcelain.sh +++ b/t/t5411/test-0014-bad-protocol--porcelain.sh @@ -21,7 +21,6 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc cat >expect <<-EOF && To ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual-report && @@ -59,7 +58,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO cat >expect <<-EOF && To ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual && grep "remote: fatal: die with the --die-read-version option" out-$test_count && @@ -90,7 +88,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT cat >expect <<-EOF && To ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual && grep "remote: fatal: die with the --die-write-version option" out-$test_count && @@ -121,7 +118,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT cat >expect <<-EOF && To ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual && grep "remote: fatal: die with the --die-read-commands option" out-$test_count && @@ -153,7 +149,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $ cat >expect <<-EOF && To ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual && grep "remote: fatal: die with the --die-read-push-options option" out-$test_count && @@ -183,7 +178,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO cat >expect <<-EOF && To ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) - Done EOF test_cmp expect actual && grep "remote: fatal: die with the --die-write-report option" out-$test_count && @@ -219,7 +213,6 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain) > To > * HEAD:refs/heads/next [new branch] > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual && @@ -260,7 +253,6 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" ' > remote: error: proc-receive reported incomplete status line: "ok" Z > To > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual && @@ -294,7 +286,6 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce > remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" Z > To > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0021-report-ng--porcelain.sh b/t/t5411/test-0021-report-ng--porcelain.sh index 502b34fe3d..c4b1d25562 100644 --- a/t/t5411/test-0021-report-ng--porcelain.sh +++ b/t/t5411/test-0021-report-ng--porcelain.sh @@ -22,7 +22,6 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/por > remote: proc-receive> ng refs/for/main/topic Z > To > ! HEAD:refs/for/main/topic [remote rejected] (failed) - > Done EOF test_cmp expect actual && @@ -55,7 +54,6 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/p > remote: proc-receive> ng refs/for/main/topic error msg Z > To > ! HEAD:refs/for/main/topic [remote rejected] (error msg) - > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh index 6d116ef692..d224e2400e 100644 --- a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh +++ b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh @@ -28,7 +28,6 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)" > To > :refs/heads/main .. > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0025-report-unknown-ref--porcelain.sh b/t/t5411/test-0025-report-unknown-ref--porcelain.sh index 8b3f5d05a3..278fc597eb 100644 --- a/t/t5411/test-0025-report-unknown-ref--porcelain.sh +++ b/t/t5411/test-0025-report-unknown-ref--porcelain.sh @@ -23,7 +23,6 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain > remote: error: proc-receive reported status on unknown ref: refs/for/main/topic Z > To > ! HEAD:refs/for/a/b/c/my/topic [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh index 2e1831b104..2c1117457f 100644 --- a/t/t5411/test-0033-report-with-options--porcelain.sh +++ b/t/t5411/test-0033-report-with-options--porcelain.sh @@ -25,7 +25,6 @@ test_expect_success "proc-receive: report option without matching ok ($PROTOCOL/ > remote: error: proc-receive reported "option" without a matching "ok/ng" directive Z > To > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual ' diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh index 40f4c5b1af..e1b64edea9 100644 --- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh +++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh @@ -63,7 +63,6 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel > HEAD:refs/for/main/topic .. > ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API) > ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status) - > Done EOF test_cmp expect actual && diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 138e6778a4..bf33cc69d0 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -68,7 +68,6 @@ test_expect_success 'fetch with transfer.fsckobjects' ' cat >exp <.git/foo "To testrepo" && echo >>.git/foo "! refs/heads/main:refs/heads/main [remote rejected] (branch is currently checked out)" && - echo >>.git/foo "Done" && test_must_fail git push >.git/bar --porcelain testrepo refs/heads/main:refs/heads/main && test_cmp .git/foo .git/bar @@ -1207,7 +1206,7 @@ test_expect_success 'push --porcelain --dry-run rejected' ' echo >>.git/foo "! refs/heads/main^:refs/heads/main [rejected] (non-fast-forward)" && echo >>.git/foo "Done" && - test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/main^:refs/heads/main && + git push >.git/bar --porcelain --dry-run testrepo refs/heads/main^:refs/heads/main && test_cmp .git/foo .git/bar ' diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh index d43aee0c32..2e40bad53d 100755 --- a/t/t5534-push-signed.sh +++ b/t/t5534-push-signed.sh @@ -385,7 +385,6 @@ test_expect_success GPG 'failed atomic push does not execute GPG' ' = refs/heads/noop:refs/heads/noop [up to date] ! refs/heads/ff:refs/heads/ff [rejected] (atomic push failed) ! refs/heads/noff:refs/heads/noff [rejected] (non-fast-forward) - Done EOF test_cmp expect out ' diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 3ad514bbd4..b543c10314 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -499,7 +499,6 @@ test_expect_success 'report error server does not provide ref status' ' cat >expect <<-EOF && To $HTTPD_URL/smart/no_report ! HEAD:refs/tags/will-fail [remote failure] (remote failed to report status) - Done EOF test_cmp expect actual ' diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh index ca5cf684bc..424391eadd 100755 --- a/t/t5548-push-porcelain.sh +++ b/t/t5548-push-porcelain.sh @@ -110,7 +110,7 @@ run_git_push_porcelain_output_test() { # 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 \ + git -C workbench push --porcelain --dry-run origin \ main \ :refs/heads/foo \ $B:bar \ @@ -176,7 +176,7 @@ run_git_push_porcelain_output_test() { # 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 \ + git -C workbench push --porcelain --dry-run --atomic origin \ main \ :refs/heads/foo \ $B:bar \ @@ -257,7 +257,6 @@ run_git_push_porcelain_output_test() { > - :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 && @@ -325,7 +324,6 @@ run_git_push_porcelain_output_test() { > ! (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 && @@ -396,7 +394,6 @@ run_git_push_porcelain_output_test() { > ! :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 && diff --git a/transport.c b/transport.c index 47fda6a773..9e03a7148c 100644 --- a/transport.c +++ b/transport.c @@ -1486,7 +1486,18 @@ int transport_push(struct repository *r, } else push_ret = 0; err = push_had_errors(remote_refs); - ret = push_ret | err; + /* + * The return values of transport->vtable->hush_refs() across + * different protocols are inconsistent. For the HTTP protocol, + * the return value is zero when there are no connection errors + * or protocol errors. We should reference the return code of + * push_had_errors() to check for failures in updating references. + * Since failing to update a reference in a --dry-run does not + * count as an error, we could ignore the result of + * push_had_errors() when both --porcelain and --dry-run options + * are set. + */ + ret = (porcelain && pretend) ? push_ret : (push_ret | err); if (!quiet || err) transport_print_push_status(transport->url, remote_refs, @@ -1503,7 +1514,7 @@ int transport_push(struct repository *r, transport_update_tracking_ref(transport->remote, ref, verbose); } - if (porcelain && !push_ret) + if (porcelain && !ret) puts("Done"); else if (!quiet && !ret && !transport_refs_pushed(remote_refs)) /* stable plumbing output; do not modify or localize */ From patchwork Thu Nov 14 17:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13875514 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 6EAF618B478 for ; Thu, 14 Nov 2024 17:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604548; cv=none; b=MZa/A0Svda2ngc3LraIKdU3A9hkPDv7HxzrsB7zBlT1HIBoPEDOlJZP4l7mjz5l2men3gxlitz+a5frnzekzKmOKmAOsGAGEGAc+D0RuUhO+AP9mCNNpJQUWVniYSTp7EeuO4I5OCOm224ep0BFZtb8QWRodGXtMPSSJ+V2OvcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604548; c=relaxed/simple; bh=Ya+dOM+CJrEShfDttPbWappCCz/fwz32CUq2vK1Hiuk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dxzFlich2//rO2ptNvd1KNMkSwN8OndT8P98jKntHQtWHZ8O2r163vt+EnKhXMtr3NE+kNsBr6Bd7lutg7oBHopNxeTz3O+RoCAosp+nf+1EryJV8N9CgBVJfayE0i2vyz6/6KLcoQjxsdhIz8n0ChMn5RWUMa168kt/F8+qXlU= 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=BGI8PI8k; arc=none smtp.client-ip=209.85.210.172 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="BGI8PI8k" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71e4244fdc6so693267b3a.0 for ; Thu, 14 Nov 2024 09:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731604546; x=1732209346; 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=Qq/5ti56TzX4P470KKNev74QgwdqJOxArvI37ZIUNPg=; b=BGI8PI8kNYH3qsxzS+BA4nyLcPzw6WEDKmTG4VWwHvSALBf2Rov8tTrTJOwzDmS+h4 2EHwWHGO3axxGMloxhyx2YxDh6Rz17EhfbvYHAZyt9P9uEttBwB9AiEjRvBpLkJlRhqU d7CauFo8lkSBX9vy6gbo7nHjlFU/myTFvx2VmTfE2wi1RFbc2YED49pyH1nsJuEje9jT evzO2ldKNv9aRS6pZKkJ8z++P6HHEbv8QF2mdQCeXdp+98ppevQ8/MaSGEN6BBD08+LL /+cSHoiW3VcnnmlORvqC+2Xj3w4HQuiNpdOddSx7X2bDoF1x7jmETYBDXkVPCgNmXm7q rMLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604546; x=1732209346; 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=Qq/5ti56TzX4P470KKNev74QgwdqJOxArvI37ZIUNPg=; b=HI0PfbYjIAyzYbLDbR6NNx36+fAw/mzmF5uSG5N9+E9emTH4sqpUceTSwSheh+thAA GMMazecW/Tl18y7yS+nTJaxII9tnuDhfkbevQ2fkKl0Y06KG2UslM5lMMbgey7xjdpww FQiZqLvBxMuCVVUWFC8fyw76SEJMV3FB4+Tkm/Jk8ED+o62hQDYk5caHe2mcfkBunq7b +7At4/b3fr4VQ7mtkTO75W4fgPtgTf/ccqtsRIAmicrB8yB9DG3rkM8k2OVlxXHheBG2 RJU6QZ3SbuT5AognZjCJ3Eo1/+TaRV4kTMy5cw3eIHjDgA9XCkwo2vnDZb5wy0YMDJUN Rzlw== X-Gm-Message-State: AOJu0YxpODFSpodJwKR1ubPAFXR0B/IHevmlgLEPJL+C2ua3DASuneOs sF2buV+bk6l6HvSjWeCcjxpvTafM8ehjn+cIp71QEgd+x1gqISGfkvQytg== X-Google-Smtp-Source: AGHT+IEUggk101CjKoGI+LWlqt01oca4Ukd6tB+tnCgHRopTT8DZMClVTdsSWkpTPzuRJpcotaaq/Q== X-Received: by 2002:aa7:88c8:0:b0:71e:1b6d:5a94 with SMTP id d2e1a72fcca58-72469c5df89mr3722624b3a.5.1731604546467; Thu, 14 Nov 2024 09:15:46 -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 d2e1a72fcca58-7246a9bab91sm1539883b3a.149.2024.11.14.09.15.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2024 09:15:46 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt Cc: Larry D'Anna Subject: [PATCH v2 3/6] t5504: modernize test by moving heredocs into test bodies Date: Fri, 15 Nov 2024 01:15:34 +0800 Message-Id: <1ab87d3b30399200e0fb440378b63e634bdbee2d.1731603991.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 | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index bf33cc69d0..56b31cf557 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -65,11 +65,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) + 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: 13875516 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 452FE18BBAA for ; Thu, 14 Nov 2024 17:15:48 +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=1731604549; cv=none; b=YHZgMdGDc2K0ogAmRbIqQpwQKkJVFNsI+NUXDK1RW9apuQgfXicT7JidDH8/OeZjGw46S8DpGklddmKuN9tmD3SbAzpYb2zGYdG+y4eH+cuPj8pPVm5qk1ZRADksynA3UEJXGJLNjE+BwBWzXU1c+s0S6SVJbA3BxMUf2u4G/Sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604549; c=relaxed/simple; bh=FZjwDu08zm+9CKRB9Dc8mPew6bZVs7ulVMC9QOIwS5U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lkQzcZy7s3CWUr4nly143MR2BJgs6j+TArTEEzFFAfUtK++Ziubxy3xZGeNZQO2mdZn7abd+H+G+wwdwHrGtGMef8eNsskNXr7zuYImbTQKB5emtTmAP4t3wPZxmIflBxXf5gj/Hs2Ld2qhDCzilk+tfxqjjqnAyMmhRbRaTbws= 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=A0e1OsOn; 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="A0e1OsOn" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7240fa50694so730020b3a.1 for ; Thu, 14 Nov 2024 09:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731604547; x=1732209347; 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=1aNzWd1AvmTLQYY5qCoq+lfm76BLl9JNWmsfPgACtCM=; b=A0e1OsOnmEkpbCC5/eq4ie5zxcbzDbXCYoJrYsfoqPBUF1/FZUN2f0zzLvTX3B3JVX dY/4iv47+fuaTnKMZMtsRo0jspiuDp0aQ1+wJaTiRSBPoD3SR3/ok72tpeFBzN/OIyOd H3gyHlxQhAgHRzt1PiiYncl3m8ymLra7MK6sH8SOz66PqVOKMi4Lf5YJYjTGV8VcvcqO lfukM9E6VTPVVelgeo5aty65iVQ1diGCJcVRe2qW40SPCBzGLelbPpZtuiW28FfmjvhC yAHH0jRkbnN9hDIx6OvFC4k/A5LLCGXqOg8JQfjQPcj0eZOthSyZwOU/snFUYmpaW9h0 Vm8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604547; x=1732209347; 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=1aNzWd1AvmTLQYY5qCoq+lfm76BLl9JNWmsfPgACtCM=; b=csdrKQj4090UmwgAIMgGex2h4hyiPGnglG8rFmPYMSjRKGm81NPRLm6Bc20QmG5g7e Zer9q2ghyO6UE7h/yYYzEs+ZrOo0XSUb1/rW1VmlV6eNEW4gmzlONsID6e5BTnKBbVIF WuU2j7bbLm4g/GDcRRo3wQ5SmC2BI0usc8AfYPm7Oc3GOvENVxiY8QzAEf3SyPr1c2ll D/N9ZbGPQXlzM1lnACc7YbqurPGi2UQbSNFAxLOXnWYVejFwjYsLfWh7XsQ2vWE7PAD+ NVZoNqOH2QaewsoQYZNQ6MZlfAre734/k4ytViNVyzeldXk4f9zOpdC5d1qWl83s6G21 TGJQ== X-Gm-Message-State: AOJu0YyafMsVVIeu/y35GHeOaLJyp+AWsCWYVpaYX3pUx6OjBrG0BxPc cQirjArUbJKfYocJMpEcXFlVU31K1PXYUBM47wEyKDI97F7gt2vHUa5AUA== X-Google-Smtp-Source: AGHT+IEVWPc14pEPPF6kHgZO7ZtXgWdSKHJi/2/jy67c+Du3kj5IUutWQAKjTcKXUC7DS7qRikR5LQ== X-Received: by 2002:a05:6a00:ac1:b0:71e:795f:92f0 with SMTP id d2e1a72fcca58-72457972cefmr10102966b3a.3.1731604547223; Thu, 14 Nov 2024 09:15:47 -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 d2e1a72fcca58-7246a9bab91sm1539883b3a.149.2024.11.14.09.15.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2024 09:15:46 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt Cc: Larry D'Anna Subject: [PATCH v2 4/6] t5543: atomic push reports exit code failure Date: Fri, 15 Nov 2024 01:15:35 +0800 Message-Id: <8094a3a2cdca3d3b01c8c82d83054207d9101fe0.1731603991.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 479d103469..a40afb949b 100755 --- a/t/t5543-atomic-push.sh +++ b/t/t5543-atomic-push.sh @@ -281,4 +281,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 Thu Nov 14 17:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13875517 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 4B79417F505 for ; Thu, 14 Nov 2024 17:15:48 +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=1731604550; cv=none; b=fpgqCeDVAMdA5JsXWOLpaOye4VIiY/Q+Ycxgfyaz5oGVFKD0rBKq4bF464HhaT5tsIg4iYcJUd4svLKoAXlJLhD8gSbnfHOaIazT7kU/BR4ZIkOj7ZW+UyTrsfHjrFvkt2aQkNsOTS9n1LUAUOB4yakCOBxnXU7yGNOpCfhE+WM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604550; c=relaxed/simple; bh=cUJllRLMwHFHVWMuPlYlSqYSjSGFOLbt1FR4FbLzWDM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B+fp6f8fQ+qp1B7nmLutSubiI1/NFt9SGtsxk+Khg46YRIERMiyb24RHff8JcMJXa7Qql7xEhsLtjPvOYp07XnkOha19BnVzNLJ8WdoIYZ38uSUO9wGhmkIchRdKGdF7UkHv+Fx3SSb9nN+QDLelox153dCwVi4u6hjkP31OADQ= 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=Whj6Fmfj; 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="Whj6Fmfj" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-720c286bcd6so796534b3a.3 for ; Thu, 14 Nov 2024 09:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731604548; x=1732209348; 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=MFYdTQMJGtClUpRHksIKjLpyt7oa5T5HU93QtmOYM2s=; b=Whj6FmfjLi6zVvOctLmweVvNLMvB6eb8chGzG/1QUXBTY49dCr/K1NJmyQbDECjZJG T2f46AtWyQfqQIsnFzehHF9CBLbyrOqVGd1pn62PMd2As0e+Md6DzFpa9Ccwmq0sUXTX xd7DK5Vwzr3UUFPrVDpGl/u8JwDcowAhPLA1gbLdAjzajs6NvGAgwRbbSFhU8NrgfWi2 PJ3e5FNSS0CGpOol+onkiVkTKjo0aEqebeD9b5tHjCE8eOI3zbQzjuEGI5/p1sMQIe7e TM23pHx4kzP1O/3hbfDQKO8qMjY8H+cuQZycMLM9ldHXo3wxB9nD88YJ40FiQ9jHIYKe 7uuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604548; x=1732209348; 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=MFYdTQMJGtClUpRHksIKjLpyt7oa5T5HU93QtmOYM2s=; b=bt54mQzMXGuuyuPLGDrFmtwzsvP/pVkkmPni5FJ7Tah6Bqyq+Tn7dkNf7ADLODWpPy 92iLaCz0drMNLzG5FsTbzCCexnB5kHyn5Iy7KP5HlencTgVoD2GPV1U4ZjH/rirkcrBg Br4OZMWxeqk9lfOLclZ1sjkR3JBoubhDllW4zqYxKsqWx+27JJr0fmiuk1XmTMyH6E9D hC4xgOXqtjAdQjnkDvwNOZJVBqNGjDUb9MFgAyN7N6RBDrooljGgS2QvI+UQYwy90Md4 nW5q7cW9Qfgngupx9BFzSMfYXltmW6lkvoXWraS0x+eDxmkIbYIQvZf/Vyfv/T91ihMQ kiFA== X-Gm-Message-State: AOJu0YzR3/FOdIwXkSftoN7h4ftgxXzsea0sejLnICMTofIQ3yXtLCRx pb98DBAjuMtiOo/rfE4f8k68od9akmulBM7lI/J6RmLFZMBLjOOC5qo9og== X-Google-Smtp-Source: AGHT+IF3VVyNHGy2kXfLgdU1YFUz3+hgVTZagE+srA/kPM/xI70fa02HYBpgcnmsPbK/xmEbvji4jQ== X-Received: by 2002:a05:6a00:1150:b0:71e:7d52:fa6d with SMTP id d2e1a72fcca58-7241338a798mr33083572b3a.21.1731604548072; Thu, 14 Nov 2024 09:15:48 -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 d2e1a72fcca58-7246a9bab91sm1539883b3a.149.2024.11.14.09.15.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2024 09:15:47 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt Cc: Jiang Xin , Larry D'Anna Subject: [PATCH v2 5/6] push: only ignore finish_connect() for dry-run mode Date: Fri, 15 Nov 2024 01:15:36 +0800 Message-Id: <1ad61a02955fca35c4d1763adfbac3fd36482e09.1731603991.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. Atomic push may abort the connection early and close the pipe, which may cause an error for `finish_connect()`. Arbitrarily ignoring this error will lead to issues. Modify it to only ignore the finish_connect() error when both the --atomic and --dry-run flags are set. Signed-off-by: Jiang Xin --- t/t5543-atomic-push.sh | 4 ++-- transport.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh index a40afb949b..1d8f088a00 100755 --- a/t/t5543-atomic-push.sh +++ b/t/t5543-atomic-push.sh @@ -281,7 +281,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 @@ -297,7 +297,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 9e03a7148c..186d58e907 100644 --- a/transport.c +++ b/transport.c @@ -923,10 +923,10 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re 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. + * which may cause an error for `finish_connect()`. We can ignore + * this error when both `--atomic` and `--dry-run` flags provided. */ - if (ret || args.atomic) + if (ret || (args.atomic && args.dry_run)) finish_connect(data->conn); else ret = finish_connect(data->conn); From patchwork Thu Nov 14 17:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13875518 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 30B5818E04E for ; Thu, 14 Nov 2024 17:15:49 +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=1731604551; cv=none; b=jEWJPiAoEGWOJd+QqWVq2aJ5ceRZcUJ+DecJpHRj0b+YhToj7r9SMQ3EBty5db4uzJ2JpuTA7fdvSwXg/nkEkiHu58XE9q9CVqVa6xY1IJXfR/1WiHZukao59kkSsrq7SNSJngRK6+cOpzEL5JQzRiPyBEMB79vPsgqjK7UFpZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731604551; c=relaxed/simple; bh=tXsWlvhdZZPSSIeFvzoAMP3/5d9b+YLz3IQ0HtzSMZY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KgYcYd1k5rMGIhqVsFWxLf4ihoix6WHDLWrOCTCMCBM3Mnf7jyuhK40RaKr5V2Z3OpUr/c8Pfr2oJjR8LBexW2JnYLWUI7AQT/uRPEi69XZ4DNUtoaV5qWHClpQit6rfm97oLhh753aNrGQHM2n9XJJkERKoqJJMAyY4BKuXVtk= 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=PPOM1A9t; 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="PPOM1A9t" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-71e681bc315so652185b3a.0 for ; Thu, 14 Nov 2024 09:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731604549; x=1732209349; 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=qR/8ePUe8qW0iV55zsMKND5tDGia91PDVvkk0/2pRYU=; b=PPOM1A9tjrobORpD2qTcz+U3b4LtS7wJV4+cSuihCA5Us151vVTd7uB3yuMAjs0M0o uOeGMRc4jVa4Qkr0T8l59tcNf57ndmhUlfG6zc+NTZumhnfMOVImuvFJhEyXaK4TUqRF 3l+euERjXtEgzJb/30mm4UohpUIoDhtEkUEUPbGE08DY+c6TIT2PHSgQ7PXNzzF0B9v/ GlXMmvlk5++WZ9lxHr0e7xo8N0e03TfOcR9Lbopo24YnEOGObE8rfwxUHtsiUFZX7Ei+ Ijji4m1tF4tWgbbg70w08UV+le003HWlpyDrBdUuKU3+x2HpXW41rPA24hdVDw9sk9K3 fZUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604549; x=1732209349; 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=qR/8ePUe8qW0iV55zsMKND5tDGia91PDVvkk0/2pRYU=; b=G5jj/LCX722ny17/FiFv5ZQqlIEaqtMSiGOMktPgseTkZWkZAhhCmxXlNWTBLbOgUu dLGZbLzma6aoEdWPMnVNMEiYD3k7fMTXGEzUXcbBxXKwzRVa23fm1bpUuWLHNUMWKqQl 8n5BOvahZVcaaiHW9WJWZWmfEukmwhaZqMZeRtV1BZHGH1xi7Xl4KPC4GXRevmiFATNE yYi1LYHrXaM/iB+vOtQGSx8LYw81B0GdlkI/aAclwyTGmL5pxixmgCOiz2KookHgm7/8 m8/6ZzgTO9Vbt4DvpOAMG8wAQYRj0cOa6otD28r7Kww0wDfCw/R9woNPgzLO75GCY8Qx ASqQ== X-Gm-Message-State: AOJu0Yz0TnUgLa8RLIRF3cTedEwQSUIfFbnx+Bg5Q5LaVufABcuQJtII 4ruNvpbPSBNihUZJdPEOfCwObvoGQ5JeXkwxihvHP3yWVeqQNiaZW69hZw== X-Google-Smtp-Source: AGHT+IGuIrGL7J6a2iUjrC7aOD8xboNEshPg4kSF/53Lfs9iKUg2cZj8mzZ2xTYlHWHIXpn6ngOAew== X-Received: by 2002:a05:6a00:3bf4:b0:724:6804:d663 with SMTP id d2e1a72fcca58-7246804d6ddmr4866002b3a.1.1731604549017; Thu, 14 Nov 2024 09:15:49 -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 d2e1a72fcca58-7246a9bab91sm1539883b3a.149.2024.11.14.09.15.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2024 09:15:48 -0800 (PST) From: Jiang Xin To: git@vger.kernel.org, Patrick Steinhardt Cc: Jiang Xin , Larry D'Anna Subject: [PATCH v2 6/6] push: not send push-options to server with --dry-run Date: Fri, 15 Nov 2024 01:15:37 +0800 Message-Id: <9d11105d0d0ef5717c6c691a3648a1c1bd1aa988.1731603991.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 Signed-off-by: Jiang Xin --- send-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send-pack.c b/send-pack.c index 4845f63737..89a2d47928 100644 --- a/send-pack.c +++ b/send-pack.c @@ -678,7 +678,7 @@ int send_pack(struct send_pack_args *args, } } - if (use_push_options) { + if (use_push_options && !args->dry_run) { struct string_list_item *item; packet_buf_flush(&req_buf);