From: Jiang Xin <worldhello.net@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Jiang Xin <zhiyou.jx@alibaba-inc.com>,
"Larry D'Anna" <larry@elder-gods.org>
Subject: Re: [PATCH 2/2] transport: don't ignore git-receive-pack(1) exit code on atomic push
Date: Thu, 14 Nov 2024 16:57:55 +0800 [thread overview]
Message-ID: <CANYiYbHGdJsTgdzJj1r4sPdTAcZCf3C-qA538fcXbD1jjB1BUw@mail.gmail.com> (raw)
In-Reply-To: <20241113-pks-push-atomic-respect-exit-code-v1-2-7965f01e7f4e@pks.im>
On Wed, Nov 13, 2024 at 7:25 PM Patrick Steinhardt <ps@pks.im> wrote:
>
> 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". This behaviour was later changed via
> 7dcbeaa0df (send-pack: fix inconsistent porcelain output, 2020-04-17)
> such that the stanza will also be printed when there was an error with
> atomic pushes, which was previously inconsistent with non-atomic pushes.
> The fixup commit has introduced a new issue though. During atomic pushes
> it is expected that git-receive-pack(1) may exit early, and that causes
> us to receive an error on the client-side. We (seemingly) still want to
> print the "Done" stanza, but given that we only do so when the push has
> been successful we started to ignore the error code by the child process
> completely when doing an atomic push.
I introduced the commit 7dcbeaa0df (send-pack: fix inconsistent porcelain
output, 2020-04-17), because the porcelain output for git push over local
file protocol and HTTP protocol are different and was hard to write the
some test cases to work for both protocols. I acknowledge the patch was
not perfect.
I read the commit 77555854be (git-push: make git push --porcelain
print "Done", 2010-02-26) and the code path of git push over two
protocols a second time, and find something:
The code snippet from 77555854be:
> - ret = transport->push_refs(transport, remote_refs, flags);
> + push_ret = transport->push_refs(transport, remote_refs, flags);
> err = push_had_errors(remote_refs);
> -
> - ret |= err;
> + ret = push_ret | err;
>
The return code "push_ret" of push_refs() from different transport
vtable is not consist. For HTTP protocol, "push_ret" is zero if no
connection error or no protocol errors. So we should consider
“push_ret" as a protocol error rather than a reference update error.
If we want to print "Done" in porcelain mode when there are no
errors. (In dry run mode, ref-update-errors should not be
considered as errors, but the opposite should be regarded as errors).
Instead of using the following code,
> + if (porcelain && !push_ret)
> + puts("Done");
We can use like this ("pretend" is the flag for dry-run mode):
+ ret = pretend ? push_ret : (push_ret | err);
+ if (porcelain && !ret)
+ puts("Done");
I will send patches follow this patch series.
--
Jiang Xin
next prev parent reply other threads:[~2024-11-14 8:58 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 11:24 [PATCH 0/2] transport: don't ignore git-receive-pack(1) exit code on atomic push Patrick Steinhardt
2024-11-13 11:24 ` [PATCH 1/2] t5504: modernize test by moving heredocs into test bodies Patrick Steinhardt
2024-11-13 11:24 ` [PATCH 2/2] transport: don't ignore git-receive-pack(1) exit code on atomic push Patrick Steinhardt
2024-11-14 8:57 ` Jiang Xin [this message]
2024-11-14 17:15 ` [PATCH v2 0/6] fix behaviors of git-push --porcelain Jiang Xin
2024-11-14 17:15 ` [PATCH v2 1/6] t5548: new test cases for push --porcelain and --dry-run Jiang Xin
2024-11-25 8:26 ` Patrick Steinhardt
2024-12-03 11:52 ` Jiang Xin
2024-11-14 17:15 ` [PATCH v2 2/6] push: fix the behavior of the Done message for porcelain Jiang Xin
2024-11-25 8:26 ` Patrick Steinhardt
2024-11-14 17:15 ` [PATCH v2 3/6] t5504: modernize test by moving heredocs into test bodies Jiang Xin
2024-11-14 17:15 ` [PATCH v2 4/6] t5543: atomic push reports exit code failure Jiang Xin
2024-11-14 17:15 ` [PATCH v2 5/6] push: only ignore finish_connect() for dry-run mode Jiang Xin
2024-11-25 8:26 ` Patrick Steinhardt
2024-11-14 17:15 ` [PATCH v2 6/6] push: not send push-options to server with --dry-run Jiang Xin
2024-11-25 8:26 ` Patrick Steinhardt
2024-12-10 11:36 ` [PATCH v3 0/8] fix behaviors of git-push --porcelain Jiang Xin
2024-12-10 11:36 ` [PATCH v3 1/8] t5504: modernize test by moving heredocs into test bodies Jiang Xin
2024-12-10 11:36 ` [PATCH v3 2/8] t5548: refactor to reuse setup_upstream() function Jiang Xin
2024-12-10 11:36 ` [PATCH v3 3/8] t5548: refactor test cases by resetting upstream Jiang Xin
2024-12-10 11:36 ` [PATCH v3 4/8] t5548: add new porcelain test cases Jiang Xin
2024-12-10 11:36 ` [PATCH v3 5/8] t5548: add porcelain push test cases for dry-run mode Jiang Xin
2024-12-10 12:19 ` Jiang Xin
2024-12-10 11:36 ` [PATCH v3 6/8] send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS" Jiang Xin
2024-12-16 8:36 ` Patrick Steinhardt
2024-12-10 11:36 ` [PATCH v3 7/8] t5543: atomic push reports exit code failure Jiang Xin
2024-12-10 11:36 ` [PATCH v3 8/8] send-pack: gracefully close the connection for atomic push Jiang Xin
2024-12-16 8:36 ` Patrick Steinhardt
2024-11-14 23:36 ` [PATCH 2/2] transport: don't ignore git-receive-pack(1) exit code on " Junio C Hamano
2024-11-25 8:26 ` Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 0/8] " Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 1/8] t5504: modernize test by moving heredocs into test bodies Patrick Steinhardt
2025-01-31 14:28 ` Eric Sunshine
2025-01-31 16:26 ` Junio C Hamano
2025-02-03 6:04 ` Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 2/8] t5548: refactor to reuse setup_upstream() function Patrick Steinhardt
2025-01-31 14:35 ` Eric Sunshine
2025-01-31 10:53 ` [PATCH v4 3/8] t5548: refactor test cases by resetting upstream Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 4/8] t5548: add new porcelain test cases Patrick Steinhardt
2025-01-31 14:46 ` Eric Sunshine
2025-01-31 10:53 ` [PATCH v4 5/8] t5548: add porcelain push test cases for dry-run mode Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 6/8] send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS" Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 7/8] t5543: atomic push reports exit code failure Patrick Steinhardt
2025-01-31 10:53 ` [PATCH v4 8/8] send-pack: gracefully close the connection for atomic push Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 0/8] transport: don't ignore git-receive-pack(1) exit code on " Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 1/8] t5504: modernize test by moving heredocs into test bodies Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 2/8] t5548: refactor to reuse setup_upstream() function Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 3/8] t5548: refactor test cases by resetting upstream Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 4/8] t5548: add new porcelain test cases Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 5/8] t5548: add porcelain push test cases for dry-run mode Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 6/8] send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS" Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 7/8] t5543: atomic push reports exit code failure Patrick Steinhardt
2025-02-03 6:29 ` [PATCH v5 8/8] send-pack: gracefully close the connection for atomic push Patrick Steinhardt
2025-02-03 23:26 ` [PATCH v5 0/8] transport: don't ignore git-receive-pack(1) exit code on " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANYiYbHGdJsTgdzJj1r4sPdTAcZCf3C-qA538fcXbD1jjB1BUw@mail.gmail.com \
--to=worldhello.net@gmail.com \
--cc=git@vger.kernel.org \
--cc=larry@elder-gods.org \
--cc=ps@pks.im \
--cc=zhiyou.jx@alibaba-inc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).