Repository navigation
feat(git-remote-entire): honour GIT_HTTP_USER_AGENT for the HTTP User-Agent - #2701
Merged
Merged
Conversation
…-Agent Match git's own override for the HTTP User-Agent header: a set value replaces the helper default verbatim and an empty value sends no header, exactly as git 2.55 does. The pkt-line agent= capability keeps the helper's own identifier; http.userAgent config is not read because the helper never runs `git config`. An empty transport.Config.UserAgent now sends no User-Agent header instead of Go's default, so both HTTP surfaces agree. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation consistently covers both HTTP paths and includes focused regression tests.
0 open findings
What changed in this PR
Aligns git-remote-entire HTTP identification with Git’s GIT_HTTP_USER_AGENT behavior.
Changes:
- Resolves HTTP user-agent overrides while preserving the fixed protocol agent.
- Suppresses Go’s default header when the override is empty.
- Adds documentation and coverage for default, overridden, and empty values.
| File | Description |
|---|---|
README.md |
Documents the supported environment variable. |
cmd/git-remote-entire/main.go |
Resolves and applies the HTTP user-agent. |
cmd/git-remote-entire/main_test.go |
Tests resolution and auth-path requests. |
internal/remotehelper/transport/proxy.go |
Always wraps transports to support empty-header suppression. |
internal/remotehelper/transport/proxy_test.go |
Verifies empty values omit the header. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
…re the auth client Validate the override with httpguts.ValidHeaderFieldValue so a CR, LF or NUL fails up front with a message naming GIT_HTTP_USER_AGENT, instead of every request dying later on net/http's anonymous header error. Extract newAuthHTTPClient from run() so the User-Agent test exercises the chain the helper ships rather than a hand-built copy. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…f User-Agent The helper proxies each v2 fetch POST to a replica, so a server-side want-ref lookup could race the ls-refs answer git already relayed. The data plane hides ref-in-want only when the User-Agent starts with git-remote-entire/, which GIT_HTTP_USER_AGENT can now change. Strip the token from the relayed fetch= capability in the helper itself; the server check stays as belt and braces. A fetch line left with no feature becomes the bare key "fetch", which gitprotocol-v2(5) allows (capability = PKT-LINE(key[=value] LF)). Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…sement Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
Soph
approved these changes
Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://entire.io/gh/entireio/cli/trails/1519
Why
Anyone running
git-remote-entirefrom automation (CI runners, Buildkite plugins, scripts) wants their traffic distinguishable in server access logs. Git already has the knob for this; the helper ignored it and always sentgit-remote-entire/<version>.What
git-remote-entirenow honours git's ownGIT_HTTP_USER_AGENTfor the HTTPUser-Agentheader, matching git-config(1),http.userAgent:Behaviour, verified against git 2.55.0 with a header-dumping server:
git-remote-entire/<version>(git:git/2.55.0)User-Agentheader at all (git: same; curl drops the header for an emptyCURLOPT_USERAGENT)transport.Config.UserAgent == ""now sends no header instead of Go'sGo-http-client/1.1, so the auth client and the git-transport client behave the same way.A value net/http would refuse (CR, LF, NUL) fails up front with
fatal: GIT_HTTP_USER_AGENT holds an invalid header character(exit 128) instead of every request dying on an anonymous header error.The helper now strips
ref-in-wantfrom the v2fetch=capability it relays to native git. It proxies each fetch POST to a replica, so a server-sidewant-reflookup could race thels-refsanswer git already saw; the data plane hid the feature only for the defaultgit-remote-entire/User-Agent, which this override can change. Afetchline left with no feature becomes the bare keyfetch, which gitprotocol-v2(5) allows (capability = PKT-LINE(key[=value] LF)).Unchanged and deliberate:
agent=capability still carries the helper's own identifier. It is a single whitespace-free protocol token, so it is never user-controlled.Not done: the
http.userAgentconfig key is not read. The helper never shells out togit config, and git forwards only-coverrides (not.gitconfig) to helpers viaGIT_CONFIG_PARAMETERS, so supporting it would need a new subprocess for a partial result. Git documents the env var as the override that wins anyway.Verification
go test ./cmd/git-remote-entire/... ./internal/remotehelper/...andgo vet: passgolangci-lint runon both packages: 0 issues;gofmt -l -scleanTestResolveHTTPUserAgent(table, parallel, env injected) andTestHTTPUserAgent_ReachesServer(builds the auth client asrun()does against anhttptest.Serverand asserts the received header for default / override / empty)TestProxy_EmptyUserAgentSendsNoHeaderreplaces the old "falls back to Go default" expectationGIT_HTTP_USER_AGENT=""sends no header; env beats-c http.userAgent;-creaches a remote helper only asGIT_CONFIG_PARAMETERS='http.userAgent'='…'🤖 Generated with Claude Code