GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — plumbing: format/pktline, fold sideband into pktline and drop the sideband package by aymanbagabas · Pull Request #2130 · go-git/go-git

Conversation

@aymanbagabas

@aymanbagabas aymanbagabas commented May 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

TL;DR

Sideband framing now lives where the rest of the pkt-line code already lives: in pktline. One buffered reader, one writer, one place to reason about band selection. The old plumbing/protocol/packp/sideband package (Demuxer / Muxer) is gone, presentation moved into a dedicated ProgressWriter, and a couple of long-standing wire bugs went out with it.

The shape of it

Reading a sideband stream (demux):

// before
demuxer := sideband.NewDemuxer(sideband.Sideband64k, conn)
demuxer.Progress = os.Stderr
io.Copy(store, demuxer)

// after
rd := pktline.NewSidebandReader(conn, os.Stderr, pktline.MaxSize)
io.Copy(store, rd)

Writing one (mux):

// before
m := sideband.NewMuxer(sideband.Sideband64k, conn)
m.Write(packData)

// after
w := pktline.NewSidebandWriter(conn, pktline.MaxSize)
w.Write(packData)                                   // band 1 (pack data)
w.WriteProgress([]byte("Counting objects: 100%\r")) // band 2 (progress)

Want a packet-oriented view instead of an io.Reader? pktline.NewSidebandScanner hands you band-1 payloads through Bytes() and surfaces band-3 as a *SidebandError from Err(). Just one band to emit? pktline.WriteSideband(w, band, payload, max).

Progress that looks like git

The wire codec stays pure: band-2 bytes are forwarded raw, in wire order. Want the familiar remote: output back? Wrap your writer:

pw := pktline.NewProgressWriter(os.Stderr, nil) // "remote: " prefix + TTY auto-detect
rd := pktline.NewSidebandReader(conn, pw, pktline.MaxSize)

ProgressWriter line-buffers, prefixes, and handles carriage returns the way git does. On a TTY it erases to end of line before each line and keeps the \r so updates overwrite in place (matching git/git sideband.c, whose terminal prefix is \x1b[K + remote: ). Off a TTY it rewrites \r to \n so logs keep every step instead of collapsing to one line. Fetch, Push, Clone, and Pull wrap progress automatically, so end users get git-style output with no extra wiring.

Wire bugs this kills

  • Oversized legacy pkt-lines. Legacy side-band caps lines at 1000 bytes. The old muxer chunked at 999 bytes of payload, prepended the band byte, then added the 4-byte header, and shipped 1004-byte lines on a stream negotiated at 1000. The new writer counts both the band byte and the header, so it never crosses the cap (measured, not assumed).
  • 64k data loss on large writes. A single Write over 65519 bytes pushed band+payload past MaxPayloadSize, so pktline.Write returned "payload is too long" and that chunk silently never reached the wire. The new writer chunks correctly at any size.
  • Silent empty sideband packets. A zero-length data packet carries no band byte. Upstream demultiplex_sideband calls that protocol error: missing sideband designator; the new Scanner now does too.

Breaking changes

  • The Progress field on the public option and request structs (CloneOptions, PullOptions, FetchOptions, PushOptions, ArchiveOptions, FetchRequest, PushRequest, ArchiveRequest) is now io.Writer instead of sideband.Progress. Identical method set, so existing assignments keep compiling.
  • plumbing/protocol/packp/sideband is removed. Move NewDemuxer to pktline.NewSidebandReader / NewSidebandScanner, and NewMuxer to pktline.NewSidebandWriter / WriteSideband.

Tests

Table-driven coverage for the scanner, reader, writer, and progress writer (including the missing-band-byte case and TTY / non-TTY rendering), plus three fuzz targets: FuzzSidebandScanner, FuzzSidebandReader, FuzzSidebandRoundTrip. ./plumbing/... and the fetch/push/clone/pull suites are green. The local TestCommitTreeSort and HTTP end-to-end failures are environmental (a git configured with safe.bareRepository=explicit, shelled out to by the test) and reproduce without this PR.

AI assistance

Prepared with AI assistance (Copilot) per AI_POLICY.md. Every commit carries an Assisted-by: trailer.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aymanbagabas
aymanbagabas requested a review from pjbgf May 16, 2026 03:55
@aymanbagabas
aymanbagabas force-pushed the pktline-sideband branch 4 times, most recently from 2888c5b to 6164123 Compare May 16, 2026 04:52
aymanbagabas added 5 commits June 24, 2026 15:30
@aymanbagabas
plumbing: format/pktline, add sideband Scanner mode
a2504ba
Extend Scanner with sideband demultiplexing. NewSidebandScanner returns
a Scanner that routes band-1 payloads to Bytes (with the band byte
stripped), line-buffers band-2 progress to a caller-supplied writer with
a "remote: " prefix matching git(1)'s user-facing output, and surfaces
band-3 fatal errors as *SidebandError via Err.

Add size constants DefaultSize / DefaultPayloadSize for legacy
side-band alongside the existing MaxSize / MaxPayloadSize for
sideband-64k, and band constants BandData / BandProgress / BandError.
Pkt-lines whose on-wire length exceeds the caller-provided max return
ErrMaxPacketExceeded, preserving the bound check previously done by
sideband.Demuxer.

Includes table-driven tests and a fuzz target.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: format/pktline, add Reader
d832c05
Add a Reader that bridges packet-oriented Scanner output to the
io.Reader interface. NewReader returns a plain pkt-line byte stream;
NewSidebandReader returns a sideband-demultiplexed byte stream that
routes BandProgress and BandError through the underlying Scanner.

Flush, delim, and response-end terminate the byte stream with io.EOF.
Callers that need to distinguish those markers should use Scanner
directly. Empty data packets are skipped to avoid the (0, nil) footgun
for bufio-style consumers.

Includes table-driven tests and a fuzz target.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: format/pktline, add Writer and WriteSideband
d5821d8
Add a Writer that wraps an io.Writer and emits pkt-lines. In plain
mode, large Write payloads are split across multiple pkt-lines. In
sideband mode (NewSidebandWriter), Write emits BandData pkt-lines and
WriteProgress emits BandProgress pkt-lines, each bounded by the
caller-supplied max total on-wire size. The only difference between
plain and sideband write paths is the band byte prefix.

Add the low-level WriteSideband helper for one-off band writes without
constructing a Writer; both Writer.Write and WriteSideband enforce the
on-wire bound, so legacy side-band pkt-lines are strictly <= 1000
bytes (the existing sideband.Muxer emitted 1005-byte pkt-lines on
legacy streams).

Includes table-driven tests and a sideband round-trip fuzz target.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: transport, migrate sideband demuxer consumers
322a9d9
Replace sideband.NewDemuxer with pktline.NewSidebandReader in FetchPack,
SendPack, and Archive. Each call site selects pktline.DefaultSize or
pktline.MaxSize based on the negotiated sideband variant.

Behavior preserved: FetchPack and SendPack still only wrap the reader
when req.Progress is non-nil. Push respects the Quiet capability by
passing a nil progress writer to the sideband Reader. Archive always
demuxes (sideband-64k is the only variant the protocol supports).

Progress output now arrives line-buffered with a "remote: " prefix,
matching git(1)'s user-facing output.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: transport, migrate sideband muxer consumers
7c8b735
Replace sideband.NewMuxer with pktline.NewSidebandWriter in UploadPack
and ReceivePack. Each call site selects pktline.DefaultSize or
pktline.MaxSize based on the negotiated sideband variant.

UploadArchive now writes band-3 errors via pktline.WriteSideband. The
existing muxer encoded an oversize pkt-line on legacy side-band streams
(payload chunked at MaxPackedSize - 1, then a 4-byte header prepended,
yielding a 1005-byte pkt-line on a stream negotiated at 1000 bytes).
The new Writer enforces the on-wire bound strictly.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
aymanbagabas force-pushed the pktline-sideband branch from 6164123 to 1bc6b5b Compare June 24, 2026 19:50
aymanbagabas and others added 4 commits June 24, 2026 16:00
@aymanbagabas
plumbing: format/pktline, add ProgressWriter and pure raw Scanner band-2
c46fde9
Strip line buffering, the "remote: " prefix, and EOF flushing from the
sideband Scanner: band-2 payloads are now written to the configured
progress writer as raw byte chunks in the order they arrive on the wire.
This keeps the Scanner a pure wire codec and lets callers compose
presentation logic without re-implementing sideband demux.

Add ProgressWriter, a small decorator that wraps an io.Writer and turns
a raw band-2 byte stream into human-facing output:

  - Per-line buffering on \r and \n boundaries.
  - Configurable line prefix (default "remote: " via nil opts).
  - TTY-aware carriage-return handling: append the ANSI erase-to-end-of
    line sequence (\x1b[K) after \r-terminated lines on a terminal, or
    rewrite \r to \n for non-terminal sinks so logs see full history.
  - Close() flushes any pending partial line.

Nil ProgressOptions yields sane defaults: the "remote: " prefix and
TTY auto-detection from the destination writer (when w exposes Fd()).
Passing a non-nil *ProgressOptions disables all auto-defaulting; the
caller is in full control.

The plumbing/transport layer still passes its caller's progress writer
verbatim to NewSidebandReader. Wrapping with NewProgressWriter is a
porcelain-layer concern and will be wired in a follow-up.

Assisted-by: Copilot <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
git: Render fetch/push progress through pktline.ProgressWriter.
6b34a1f
Wrap the caller-supplied progress writer in fetch() and push() with
pktline.NewProgressWriter so raw band-2 sideband bytes are rendered as
git(1)-style "remote: " prefixed, terminal-aware progress. The transport
layer continues to forward progress verbatim; presentation lives in the
porcelain layer.

The writer is only installed when the caller passes a non-nil Progress,
so sideband negotiation stays disabled otherwise and the request's
Progress field is never set to a typed-nil interface value. Close() is
called after the fetch/push completes to flush any trailing partial
progress line.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: transport, Use io.Writer for progress option fields.
1409a78
Change the Progress fields on the public option and request structs
(CloneOptions, FetchOptions, PullOptions, PushOptions, ArchiveOptions,
FetchRequest, PushRequest, ArchiveRequest) from sideband.Progress to
io.Writer. sideband.Progress was defined as interface{ io.Writer }, so the
two types have identical method sets and the change is source compatible:
any io.Writer assigned to or read from these fields keeps working.

This removes the last references to the plumbing/protocol/packp/sideband
package from go-git's public API and non-test code.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: protocol/packp/sideband, Remove the Demuxer and Muxer.
ca68859
The sideband Demuxer and Muxer have been superseded by pktline's
sideband-aware Scanner, Reader, and Writer, and no code in the tree
references the package any longer, so remove it.

Callers that used sideband.NewDemuxer should migrate to
pktline.NewSidebandReader (for an io.Reader) or pktline.NewSidebandScanner
(for a packet-oriented scanner). Callers that used sideband.NewMuxer
should migrate to pktline.NewSidebandWriter, or pktline.WriteSideband for
one-off band writes.

Assisted-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
@aymanbagabas
aymanbagabas force-pushed the pktline-sideband branch from 1bc6b5b to ca68859 Compare June 24, 2026 20:03
@aymanbagabas
aymanbagabas marked this pull request as ready for review June 24, 2026 20:03
Copilot AI review requested due to automatic review settings June 24, 2026 20:03
@aymanbagabas aymanbagabas changed the title plumbing: format/pktline, converge sideband mux/demux into pktline plumbing: format/pktline, fold sideband into pktline and drop the sideband package Jun 24, 2026
Copilot started reviewing on behalf of aymanbagabas June 24, 2026 20:08
View session
Copilot AI reviewed Jun 24, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR relocates Git sideband framing support from plumbing/protocol/packp/sideband into plumbing/format/pktline, consolidating pkt-line and sideband behavior in a single package while updating transport and top-level options to use the new APIs.

Changes:

  • Replace the legacy packp/sideband mux/demux package with sideband-aware pktline Reader/Scanner/Writer helpers.
  • Introduce pktline.ProgressWriter to render raw band-2 bytes as Git-style progress output, and wire it into fetch/push flows.
  • Update public Progress fields across options/requests from sideband.Progress to io.Writer, and add targeted unit tests + fuzzers for the new sideband implementation.
Show a summary per file
File Description
repository.go Switch ArchiveOptions.Progress to io.Writer and remove legacy sideband import.
remote.go Wrap progress output with pktline.ProgressWriter and avoid enabling progress unless requested.
options.go Change CloneOptions/PullOptions/FetchOptions/PushOptions Progress types to io.Writer.
plumbing/transport/common.go Change FetchRequest/PushRequest Progress types to io.Writer.
plumbing/transport/fetch.go Use pktline.NewSidebandReader to demux sideband when progress is enabled.
plumbing/transport/push.go Use pktline.NewSidebandReader to demux sideband progress/status responses.
plumbing/transport/archive.go Replace legacy demuxer with pktline.NewSidebandReader for upload-archive streams.
plumbing/transport/upload_pack.go Replace sideband muxer with pktline.NewSidebandWriter for server responses.
plumbing/transport/receive_pack.go Replace sideband muxer with pktline.NewSidebandWriter for server responses.
plumbing/transport/upload_archive.go Replace sideband muxer with pktline.NewSidebandWriter and write band-3 errors via pktline helpers.
plumbing/transport/upload_pack_test.go Update tests to use the new pktline sideband reader.
plumbing/protocol/packp/sideband/common.go Remove legacy sideband package (types/constants).
plumbing/protocol/packp/sideband/demux.go Remove legacy sideband demuxer implementation.
plumbing/protocol/packp/sideband/demux_test.go Remove legacy demuxer tests.
plumbing/protocol/packp/sideband/muxer.go Remove legacy sideband muxer implementation.
plumbing/protocol/packp/sideband/muxer_test.go Remove legacy muxer tests.
plumbing/protocol/packp/sideband/doc.go Remove legacy sideband package documentation.
plumbing/format/pktline/common.go Add legacy sideband sizing constants and band identifiers to pktline.
plumbing/format/pktline/sideband.go Add sideband-specific errors/types (ErrMaxPacketExceeded, SidebandError).
plumbing/format/pktline/scanner.go Extend pktline scanner with sideband demux mode (bands 1/2/3 behavior).
plumbing/format/pktline/scanner_sideband_test.go Add sideband scanner unit tests (including edge cases).
plumbing/format/pktline/reader.go Add pktline reader abstraction, including sideband reader mode.
plumbing/format/pktline/reader_test.go Add reader tests for plain and sideband modes.
plumbing/format/pktline/writer.go Add pktline writer abstraction plus WriteSideband chunking.
plumbing/format/pktline/writer_test.go Add writer tests including max-size wire bounds regressions.
plumbing/format/pktline/progress.go Add ProgressWriter for Git-like progress rendering / TTY handling.
plumbing/format/pktline/progress_test.go Add ProgressWriter unit tests including CR/TTY behavior.
plumbing/format/pktline/pktline_fuzz_test.go Add sideband fuzz targets for scanner/reader/round-trip behavior.
go.mod Add golang.org/x/term for TTY detection in progress rendering.

Copilot's findings

  • Files reviewed: 29/29 changed files
  • Comments generated: 3

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread plumbing/format/pktline/progress.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread plumbing/format/pktline/progress.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread plumbing/format/pktline/scanner.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@pjbgf pjbgf Awaiting requested review from pjbgf

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@aymanbagabas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.