gitproto: report cancellation and drain the pack trailer

main

Commit

Stefan Haubold1w ago

Reading the advertisement before writing the body changed two failure modes:

  • A cancelled ctx kills ssh, which can look like an empty advertisement. The body was then written into a dead pipe, and sshRPCStream.Close returned the EPIPE without ctx.Err(). PostRPCStreamBody now stops when ctx is done after the advertisement, and Close always joins ctx.Err(). This fixes TestSSHConnPostRPCStreamBodyHonorsContext, which failed every run on macOS, where a new script's first exec takes ~2s.
  • closeJoin now surfaces close errors, so closing before ssh or the remote helper wrote the trailing flush/0002 could fail a fetch that stored every object (the helper dies on SIGPIPE). On success, closeJoin now drains up to 64 KiB before closing.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Entire-Checkpoint: 01M5YA23E1KZE36JHAW9VQQ9Z0