git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v5 0/8] transport: don't ignore git-receive-pack(1) exit code on atomic push

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 3, 2025, 06:29 UTC
Message-ID
<20250203-pks-push-atomic-respect-exit-code-v5-0-d66481e36622@pks.im>
In-Reply-To
<20241113-pks-push-atomic-respect-exit-code-v1-0-7965f01e7f4e@pks.im>
Hi,

we've hit an edge case at GitLab where an atomic push will not notice an error when git-receive-pack(1) updates the refs, but otherwise fails with a non-zero exit code. The push would be successful and no error would be printed even though some things have gone wrong on the remote side.

As promised last week, I've now adopted the patch series from Jiang Xin to make some progress on the issue. The series is now based on the latest master branch at 3b0d05c4a7 (The fifth batch, 2025-01-29).

Changes in v4:
  - Rewrite the commit that adds two new tests for `--porcelain`.
    Previously, the commit both reordered existing tests and added new
    ones, which made it hard to see what actually changed. The reorder
    wasn't necessary though, so I've adapted it to only add new tests
    now.
  - Fix the URL prefix in t5548 to also work on Windows.
  - Document why it's fine to start ignoring the return value of
    `git_transport_push()`.
  - Improve comments to document behaviour better.
  - Link to v3: https://lore.kernel.org/r/cover.1733830410.git.zhiyou.jx@alibaba-inc.com
Changes in v5:
  - Escape heredocs where possible.
  - Link to v4: https://lore.kernel.org/r/20250131-pks-push-atomic-respect-exit-code-v4-0-a8b41f01a676@pks.im
Thanks!
Patrick
---
Jiang Xin (5):
      t5548: refactor to reuse setup_upstream() function
      t5548: refactor test cases by resetting upstream
      t5548: add porcelain push test cases for dry-run mode
      send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"
      send-pack: gracefully close the connection for atomic push
Patrick Steinhardt (3):
      t5504: modernize test by moving heredocs into test bodies
      t5548: add new porcelain test cases
      t5543: atomic push reports exit code failure
 send-pack.c                     |  10 +-
 send-pack.h                     |  13 ++
 t/t5504-fetch-receive-strict.sh |  35 ++--
 t/t5543-atomic-push.sh          |  30 +++
 t/t5548-push-porcelain.sh       | 443 ++++++++++++++++++++++++++++++----------
 transport.c                     |  17 +-
 6 files changed, 406 insertions(+), 142 deletions(-)
Range-diff versus v4:
1:  ef3732a280 ! 1:  2d04ec6ca3 t5504: modernize test by moving heredocs into test bodies
    @@ t/t5504-fetch-receive-strict.sh: test_expect_success 'push without strict' '
      		git config fetch.fsckobjects false &&
      		git config transfer.fsckobjects false
      	) &&
    -+	cat >exp <<-EOF &&
    ++	cat >exp <<-\EOF &&
     +	To dst
     +	!	refs/heads/main:refs/heads/test	[remote rejected] (missing necessary objects)
     +	Done
    @@ t/t5504-fetch-receive-strict.sh: test_expect_success 'push with receive.fsckobje
      		git config receive.fsckobjects true &&
      		git config transfer.fsckobjects false
      	) &&
    -+	cat >exp <<-EOF &&
    ++	cat >exp <<-\EOF &&
     +	To dst
     +	!	refs/heads/main:refs/heads/test	[remote rejected] (unpacker error)
     +	EOF
2:  c4a57bf457 ! 2:  31c8b10e7d t5548: refactor to reuse setup_upstream() function
    @@ t/t5548-push-porcelain.sh: format_and_save_expect () {
     +	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.
    ++	fi
     +	upstream="$1"
     +
      	# Upstream  after setup : main(B)  foo(A)  bar(A)  baz(A)
3:  67928693cc ! 3:  a8de197677 t5548: refactor test cases by resetting upstream
    @@ Commit message
     
      ## t/t5548-push-porcelain.sh ##
     @@ t/t5548-push-porcelain.sh: setup_upstream_and_workbench () {
    - 	# we will use it in the subsequent test cases.
    + 	fi
      	upstream="$1"
      
     -	# Upstream  after setup : main(B)  foo(A)  bar(A)  baz(A)
4:  6e0f0f791f ! 4:  9e4f3be9e0 t5548: add new porcelain test cases
    @@ t/t5548-push-porcelain.sh: run_git_push_porcelain_output_test() {
     +			baz \
     +			next >out &&
     +		make_user_friendly_and_stable_output <out >actual &&
    -+		format_and_save_expect <<-EOF &&
    ++		format_and_save_expect <<-\EOF &&
     +		> To <URL/of/upstream.git>
     +		> =	refs/heads/baz:refs/heads/baz	[up to date]
     +		>  	<COMMIT-B>:refs/heads/bar	<COMMIT-A>..<COMMIT-B>
    @@ t/t5548-push-porcelain.sh: run_git_push_porcelain_output_test() {
     +			baz \
     +			next >out &&
     +		make_user_friendly_and_stable_output <out >actual &&
    -+		format_and_save_expect <<-EOF &&
    ++		format_and_save_expect <<-\EOF &&
     +		> To <URL/of/upstream.git>
     +		> =	refs/heads/baz:refs/heads/baz	[up to date]
     +		>  	<COMMIT-B>:refs/heads/bar	<COMMIT-A>..<COMMIT-B>
5:  cb985baec9 = 5:  093b50d785 t5548: add porcelain push test cases for dry-run mode
6:  68ae698e4b = 6:  9a1851f06e send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"
7:  525cefd4f2 = 7:  e789913922 t5543: atomic push reports exit code failure
8:  19cdbf991f = 8:  52101a1f14 send-pack: gracefully close the connection for atomic push

--- base-commit: 3b0d05c4a79d0e441283680a864529b02dca5f08 change-id: 20241113-pks-push-atomic-respect-exit-code-436c443a657d

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 45 of 54 in “transport: don't ignore git-receive-pack(1) exit code on atomic push”
  1. 0/2 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Nov 13, 2024
  2. 1/2 t5504: modernize test by moving heredocs into test bodiesPatrick Steinhardt, Nov 13, 2024
  3. 2/2 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Nov 13, 2024
  4. Jiang XinNov 14, 2024
  5. 0/6 fix behaviors of git-push --porcelainJiang Xin, Nov 14, 2024
  6. 1/6 t5548: new test cases for push --porcelain and --dry-runJiang Xin, Nov 14, 2024
  7. Patrick SteinhardtNov 25, 2024
  8. Jiang XinDec 3, 2024
  9. 2/6 push: fix the behavior of the Done message for porcelainJiang Xin, Nov 14, 2024
  10. Patrick SteinhardtNov 25, 2024
  11. 3/6 t5504: modernize test by moving heredocs into test bodiesJiang Xin, Nov 14, 2024
  12. 4/6 t5543: atomic push reports exit code failureJiang Xin, Nov 14, 2024
  13. 5/6 push: only ignore finish_connect() for dry-run modeJiang Xin, Nov 14, 2024
  14. Patrick SteinhardtNov 25, 2024
  15. 6/6 push: not send push-options to server with --dry-runJiang Xin, Nov 14, 2024
  16. Patrick SteinhardtNov 25, 2024
  17. 0/8 fix behaviors of git-push --porcelainJiang Xin, Dec 10, 2024
  18. 1/8 t5504: modernize test by moving heredocs into test bodiesJiang Xin, Dec 10, 2024
  19. 2/8 t5548: refactor to reuse setup_upstream() functionJiang Xin, Dec 10, 2024
  20. 3/8 t5548: refactor test cases by resetting upstreamJiang Xin, Dec 10, 2024
  21. 4/8 t5548: add new porcelain test casesJiang Xin, Dec 10, 2024
  22. 5/8 t5548: add porcelain push test cases for dry-run modeJiang Xin, Dec 10, 2024
  23. Jiang XinDec 10, 2024
  24. 6/8 send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"Jiang Xin, Dec 10, 2024
  25. Patrick SteinhardtDec 16, 2024
  26. 7/8 t5543: atomic push reports exit code failureJiang Xin, Dec 10, 2024
  27. 8/8 send-pack: gracefully close the connection for atomic pushJiang Xin, Dec 10, 2024
  28. Patrick SteinhardtDec 16, 2024
  29. Junio C HamanoNov 14, 2024
  30. Patrick SteinhardtNov 25, 2024
  31. 0/8 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Jan 31, 2025
  32. 1/8 t5504: modernize test by moving heredocs into test bodiesPatrick Steinhardt, Jan 31, 2025
  33. Eric SunshineJan 31, 2025
  34. Junio C HamanoJan 31, 2025
  35. Patrick SteinhardtFeb 3, 2025
  36. 2/8 t5548: refactor to reuse setup_upstream() functionPatrick Steinhardt, Jan 31, 2025
  37. Eric SunshineJan 31, 2025
  38. 4/8 t5548: add new porcelain test casesPatrick Steinhardt, Jan 31, 2025
  39. Eric SunshineJan 31, 2025
  40. 5/8 t5548: add porcelain push test cases for dry-run modePatrick Steinhardt, Jan 31, 2025
  41. 3/8 t5548: refactor test cases by resetting upstreamPatrick Steinhardt, Jan 31, 2025
  42. 7/8 t5543: atomic push reports exit code failurePatrick Steinhardt, Jan 31, 2025
  43. 6/8 send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"Patrick Steinhardt, Jan 31, 2025
  44. 8/8 send-pack: gracefully close the connection for atomic pushPatrick Steinhardt, Jan 31, 2025
  45. 0/8 transport: don't ignore git-receive-pack(1) exit code on atomic pushPatrick Steinhardt, Feb 3, 2025
  46. 1/8 t5504: modernize test by moving heredocs into test bodiesPatrick Steinhardt, Feb 3, 2025
  47. 2/8 t5548: refactor to reuse setup_upstream() functionPatrick Steinhardt, Feb 3, 2025
  48. 3/8 t5548: refactor test cases by resetting upstreamPatrick Steinhardt, Feb 3, 2025
  49. 4/8 t5548: add new porcelain test casesPatrick Steinhardt, Feb 3, 2025
  50. 5/8 t5548: add porcelain push test cases for dry-run modePatrick Steinhardt, Feb 3, 2025
  51. 6/8 send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"Patrick Steinhardt, Feb 3, 2025
  52. 7/8 t5543: atomic push reports exit code failurePatrick Steinhardt, Feb 3, 2025
  53. 8/8 send-pack: gracefully close the connection for atomic pushPatrick Steinhardt, Feb 3, 2025
  54. Junio C HamanoFeb 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.