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: transport, replace transport API with new design by aymanbagabas · Pull Request #1972 · go-git/go-git

Conversation

@aymanbagabas

@aymanbagabas aymanbagabas commented Apr 8, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Summary

Replace the alpha plumbing/transport API with a new design and add a plumbing/client package for scheme-based transport resolution. This is a breaking API change — plumbing/transport has never been released as stable.

The migration is structured as a 13-PR stack, each merged into the next. This PR is the aggregation of all stacked PRs merged into transport-migrate/base.

Key API changes

Old New
Connection interface Session interface (Capabilities, GetRemoteRefs, Fetch, Push, Close)
Session interface Transport interface (Handshake)
Endpoint struct *url.URL (standard library)
NewEndpoint(string) ParseURL(string) → *url.URL
Get(scheme) via registry client.New() + client.Handshake(ctx, req)
Auth transport.AuthMethod Transport-specific auth via client.WithSSHAuth(...), client.WithHTTPAuth(...), etc.
ProxyOptions in core Moved to sub-transport config options
backend/git + backend/http Single backend package with Serve, ServeHTTP, RequestFromProto

Stacked PRs

# Description PR
1 Replace plumbing/transport core aymanbagabas#5
2 Replace internal/transport/test suites aymanbagabas#6
3 Replace plumbing/transport/ssh aymanbagabas#7
4 Replace plumbing/transport/http aymanbagabas#8
5 Replace plumbing/transport/git aymanbagabas#9
6 Replace plumbing/transport/file aymanbagabas#10
7 Add plumbing/client aymanbagabas#11
8 Rewire callers to new API aymanbagabas#12
9 Rewire server/backends aymanbagabas#13
10 Update examples aymanbagabas#14
11 Fix build, lint, race, and test errors aymanbagabas#15
12 Unify backend/git and backend/http into single backend package aymanbagabas#16
13 Follow-up comments and feedback aymanbagabas#17

What changed

New packages:

  • plumbing/client — scheme-based transport resolution, replacing plumbing/transport/registry.go
  • backend — unified backend serving Git over any transport (Serve, ServeHTTP, RequestFromProto)

Core (plumbing/transport/):
Replaced the old Endpoint/Connection/Session/Registry design with a cleaner Transport/Session/Conn hierarchy. Endpoints are now standard *url.URL values. The old global transport registry is gone — scheme resolution moved to plumbing/client.

// Old
ep, _ := transport.NewEndpoint("https://github.com/org/repo")
t := transport.Get(ep.Scheme())
conn, _ := t.NewSession(ep, ...)
_ = conn.Handshake(ctx, ...)

// New
u := transport.ParseURL("https://github.com/org/repo")
c := client.New()
sess, _ := c.Handshake(ctx, &transport.Request{URL: u, ...})

New files: doc.go, errors.go, pack_session.go, pack_stream.go, protocol.go, request.go, session_stream.go, url.go. Deleted: registry.go, mocks.go, pack.go.

Sub-transports:
Each sub-transport now implements Transport.Handshake directly, returning a Session with transport-specific capabilities. Dedicated handshake layers separate protocol negotiation from transport I/O. SSH globals (DefaultSSHConfig, DefaultAuthBuilder) were removed in favor of per-instance Options.

// SSH: per-instance options instead of globals
opts := &ssh.Options{UserSettings: mySettings, ClientConfig: myConfig}
t := ssh.NewTransport(opts)

// HTTP: dedicated auth, TLS, and redirect handling
t := http.NewTransport(http.Options{TLS: &tls.Config{InsecureSkipVerify: true}})

Callers:
All option structs (CloneOptions, PullOptions, FetchOptions, PushOptions, etc.) now use a single ClientOptions []client.Option field instead of separate Auth, InsecureSkipTLS, CABundle, and ProxyOptions fields. This lets callers compose transport-specific configuration without the library needing a shared AuthMethod interface.

// Old
opts := &git.CloneOptions{
    URL:  "https://github.com/org/repo",
    Auth: &http.BasicAuth{Username: "user", Password: "pass"},
}

// New
opts := &git.CloneOptions{
    URL: "https://github.com/org/repo",
    ClientOptions: []client.Option{
        client.WithHTTPAuth(&http.BasicAuth{Username: "user", Password: "pass"}),
    },
}

Backends:
Merged backend/git and backend/http into a single backend package. Backend.Serve is the single entrypoint for all transports — callers pass their own reader/writer and decide the wire format. A new unified backend.Request type replaces the scattered packp.GitProtoRequest, HTTP headers, and SSH session command parsing.

b := backend.New(loader)

// TCP/SSH: call Serve directly
_ = b.Serve(ctx, conn, conn, &backend.Request{URL: u, Service: "git-upload-pack"})

// HTTP: use ServeHTTP which implements http.Handler
http.Handle("/", b)

// TCP helper: convert git daemon protocol request
req := backend.RequestFromProto(gitProtoReq)

Examples:
All examples updated to use ClientOptions with transport-specific option helpers.

// SSH auth
opts := &git.CloneOptions{
    ClientOptions: []client.Option{client.WithSSHAuth(publicKeys)},
}

// HTTP auth
opts := &git.CloneOptions{
    ClientOptions: []client.Option{
        client.WithHTTPAuth(&http.BasicAuth{Username: "user", Password: "pass"}),
    },
}

// Custom HTTP client
opts := &git.CloneOptions{
    ClientOptions: []client.Option{client.WithHTTPClient(customClient)},
}

Cleanup (PR 11):

  • Removed NewConn generic wrapper; each transport implements transport.Conn directly
  • Remote stderr surfaces at Push/Fetch, not Close() — errors return at the operation site
  • Fixed SSH data race in sshConn.Close() — removed stdin.Close() that raced with in-flight ctxWriter goroutines
  • Removed SSH globals; all config is per-instance via Options
  • Verified: go build, go vet, go test -race ./..., golangci-lint run all pass

Supersedes

#1962, #1963, #1964, #1965, #1966, #1967, #1968

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 April 8, 2026 22:42
github-advanced-security[bot]
github-advanced-security Bot found potential problems Apr 10, 2026
View reviewed changes
Comment thread backend/backend.go Dismissed

Uh oh!

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

aymanbagabas and others added 28 commits April 11, 2026 19:18
@aymanbagabas
plumbing: transport, replace core package with new transport API
fbf7b8a
Replace the alpha plumbing/transport API with the new x/transport API.
Copy all core files from x/transport/ to plumbing/transport/ with import
path rewrites. Delete old files that have no equivalent in the new API
(registry.go, mocks.go, pack.go).

See rfcs/0002-replace-plumbing-transport.md for design rationale.
@aymanbagabas
plumbing: transport, add URL parsing tests
583a7e4
@aymanbagabas
plumbing: transport: url parsing internal refactor
168ceaa
@aymanbagabas
internal: transport/test, replace test suites with new transport API
7cfb06b
Replace the old upload_pack.go and receive_pack.go test suites in
internal/transport/test/ with the new versions from x/transport/test/.
These new suites test against the new plumbing/transport API.
@aymanbagabas
plumbing: transport/ssh, replace with new SSH transport
373e184
Replace the old plumbing/transport/ssh package with the new version from
x/transport/ssh. This includes the new auth, handshake, knownhosts, and
sshagent implementations.
@aymanbagabas
plumbing: transport/http, replace with new HTTP transport
d17280d
Replace the old plumbing/transport/http package with the new version from
x/transport/http. This includes new auth, handshake, dumb HTTP, TLS,
redirect, and proxy implementations.
@aymanbagabas
plumbing: transport/git, replace with new Git transport
6541fc6
Replace the old plumbing/transport/git package with the new version from
x/transport/git. Includes new handshake implementation.
@aymanbagabas
plumbing: transport/file, replace with new file transport
42f704a
Replace the old plumbing/transport/file package with the new version from
x/transport/file. Includes new handshake implementation.
@aymanbagabas
plumbing: client, add new client package
9a6ef9d
Add plumbing/client from x/client. This package provides scheme-based
transport resolution, replacing the old registry.go functionality.
@aymanbagabas
git: rewire callers to new transport API
76148b9
Replace old transport API usage in remote.go, repository.go, submodule.go,
and options.go with the new plumbing/transport and plumbing/client APIs.

Key changes:
- Replace Auth, InsecureSkipTLS, CABundle, ProxyOptions fields with
  ClientOptions []client.Option on all option structs
- Replace newClient() to use client.New() + transport.ParseURL()
- Collapse Transport.NewSession + Session.Handshake into client.Handshake
- Pass storer to Session.Fetch/Push (new signature)
- Replace transport.NewEndpoint with transport.ParseURL (*url.URL)
@aymanbagabas
internal: server, backend: rewire to new transport API
4a41b94
Update server and backend packages for the new plumbing/transport API:
- Replace transport.Service type with plain string
- Replace transport.NewEndpoint with transport.ParseURL (*url.URL)
- Replace svc.Name()/service.Name() with transport.ServiceName()
- Update Loader.Load signature from *Endpoint to *url.URL
@aymanbagabas
_examples: update for new transport client API
17afd8c
Update all examples that use authentication or custom HTTP clients
to use the new client.Option pattern instead of the old Auth field
and transport.Register.
@aymanbagabas
build: fix compilation, lint, and test errors from transport migration
97881cb
Fix all remaining build, test, and lint errors after the transport API
migration so the full stack compiles, passes go vet, and all tests pass.

Highlights:

- Remove NewConn helper; each transport now implements transport.Conn
  directly (sshConn, gitConn, fileConn)
- Surface remote stderr at Push/Fetch via Stderr() io.Reader interface
  instead of at Close() time — the idiomatic Go pattern for subprocess
  error reporting
- Replace UploadPackOptions/ReceivePackOptions with UploadPackRequest/
  ReceivePackRequest in backend packages
- Fix missing closing paren and stale variable references in remote.go
- Update worktree.go to use ClientOptions instead of old fields
- Consolidate duplicate internal/transport/test imports across all
  sub-transport test files
- Refactor duplicated test code into table-driven tests and shared
  setup helpers (file, git, ssh)
- Fix TestHostKeyCallbackHelper_NilFallback to account for
  /etc/ssh/ssh_known_hosts
- Fix gci import ordering across all modified files

Verified: go build, go vet, go test ./..., and example tests all pass.
@aymanbagabas
git: remote, remove unused plumbing/cache import.
fad57a7
@aymanbagabas
plumbing: transport, fix go-git-fixtures import path from v5 to v6.
345b8c9
The go.mod requires v6 but test files still imported v5.
@aymanbagabas
plumbing: transport, format url.go
0af6fef
@aymanbagabas
backend: unify git and http backends into single package
ce3ff06
Merge backend/git and backend/http into a single backend package with a
unified API:

- Backend.Serve(ctx, r, w, *Request) — core dispatch for all transports
- Backend.ServeConn(ctx, rwc, *Request) — convenience for full-duplex
  connections (TCP, SSH, pipes)
- Backend.ServeHTTP(w, r) — HTTP adapter (smart + dumb protocols)
- RequestFromProto(*packp.GitProtoRequest) — helper for TCP git daemon

The shared logic (loader resolution, service dispatch, UploadPack/
ReceivePack invocation) lives in Serve. HTTP-specific concerns (routing,
gzip, content-type, dumb file serving) stay in ServeHTTP. Error handling
is the caller's responsibility — Serve returns errors instead of writing
them to the wire.

Delete backend/git/ and backend/http/ subpackages. Update
internal/server/http to import backend directly.
@aymanbagabas @pjbgf
backend: simplify regex sha sum handling
3b0294e
Co-authored-by: Paulo Gomes <[email protected]>
Co-authored-by: Ayman Bagabas <[email protected]>
@aymanbagabas
plumbing: transport, add missing trace logs for ssh auth and known_ho…
f0bdaa5
…sts loading
@aymanbagabas
plumbing: transport, use constants for service names in file transport
f9e4022
@aymanbagabas
plumbing: client, add empty and nil checks to WithTransport
0722670
@aymanbagabas
plumbing: client, improve error message when transport does not suppo…
105374d
…rt Connect
@aymanbagabas
plumbing: transport, restore http request and response tracing
ced639e
@aymanbagabas
plumbing: transport, make user settings ssh config dynamic based on r…
c5e6196
…equest
@aymanbagabas
backend: http, handle invalid and unsupported services
3014b9b
@aymanbagabas
backend: http, require non-empty Authorization header for receive-pac…
3674cb1
…k service
@aymanbagabas
plumbing: transport, add http proxy authentication tests
0110949
@aymanbagabas
plumbing: transport, http: formatting and style fixes
f041672
aymanbagabas and others added 4 commits April 11, 2026 19:22
@aymanbagabas
backend: http, remove unnecessary path.Base call
4b3848c
@aymanbagabas
plumbing: transport, rename Connectable interface following go conven…
d971605
…tion
@aymanbagabas
plumbing: transport, add interface compile guards for Connector and S…
093df88
…ession
@aymanbagabas
plumbing: transport, use %q for formatting trace calls
c9bc20c
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@aymanbagabas
aymanbagabas force-pushed the transport-migrate/base branch from 0a68212 to c9bc20c Compare April 11, 2026 23:22
@aymanbagabas
aymanbagabas marked this pull request as ready for review April 11, 2026 23:22
@pjbgf pjbgf added the breaking label Apr 12, 2026
@pjbgf

pjbgf commented Apr 12, 2026

Copy link
Copy Markdown
Member

A summary of the changes needs to be added to #910 or directly pushed into v5-v6 migration guide.

All reactions

Sorry, something went wrong.

Uh oh!

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

pjbgf
pjbgf requested changes Apr 12, 2026
View reviewed changes

@pjbgf pjbgf left a comment

Copy link
Copy Markdown
Member

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.

This adds a regression on http redirection (e.g. cloning without the .git suffix). Let's fix that and add a test to block future regressions. Apart from that we can go ahead and merge this.

Other improvements will be done as follow-up PRs.

Sorry, something went wrong.

Uh oh!

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

aymanbagabas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@aymanbagabas
plumbing: transport, fix redirect URL in http transport handshake
8ef476b
@aymanbagabas
aymanbagabas requested a review from pjbgf April 12, 2026 19:20
@aymanbagabas

aymanbagabas commented Apr 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

This adds a regression on http redirection (e.g. cloning without the .git suffix). Let's fix that and add a test to block future regressions. Apart from that we can go ahead and merge this.

Pushed a fix

A summary of the changes needs to be added to #910 or directly pushed into v5-v6 migration guide.

I opened https://github.com/aymanbagabas/go-git-docs/pull/1 for this 🙂

All reactions

Sorry, something went wrong.

Uh oh!

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

pjbgf
pjbgf approved these changes Apr 12, 2026
View reviewed changes

@pjbgf pjbgf left a comment

Copy link
Copy Markdown
Member

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.

@aymanbagabas thanks for working on this. 🙇

Sorry, something went wrong.

Uh oh!

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

aymanbagabas reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@pjbgf
pjbgf merged commit b503c1d into go-git:transport-refactoring Apr 12, 2026
14 checks passed

Uh oh!

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

@pjbgf pjbgf mentioned this pull request Apr 12, 2026
plumbing/transport API Refactoring #1983
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pjbgf pjbgf pjbgf approved these changes
+1 more reviewer
@github-advanced-security github-advanced-security[bot] github-advanced-security[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

breaking

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.

3 participants

@aymanbagabas @pjbgf @github-advanced-security
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.