[PATCH v2 5/6] push: only ignore finish_connect() for dry-run mode
- From
Jiang Xin <worldhello.net@gmail.com>
- Date
- Nov 14, 2024, 17:15 UTC
- Message-ID
- <1ad61a02955fca35c4d1763adfbac3fd36482e09.1731603991.git.zhiyou.jx@alibaba-inc.com>
- In-Reply-To
- <cover.1731603991.git.zhiyou.jx@alibaba-inc.com>
From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
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 <zhiyou.jx@alibaba-inc.com> --- 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);
-- 2.47.0.rc1.21.g81e7bd6151