Include the port in the git-credential host field#82
Merged
Conversation
credentialInput emitted host=<hostname>, dropping any non-default port. gitcredentials(7) defines host as "host[:port]", so on a non-default-port remote the fill query never matched the stored entry and approve/reject wrote to the default-port entry instead. Emit ep.Host (which keeps the port); the empty-host guard still uses Hostname(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: a384992be26e
pjbgf
approved these changes
Jun 17, 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.
Problem
credentialInput(internal/auth/auth.go) built the git-credential request withhost=<hostname>, usingep.Hostname()which drops the port. gitcredentials(7) defineshostashost[:port], so on a non-default-port remote:git credential fillquery never matched the stored entry (credentials silently not found), andapprove/rejectwrote to the default-port entry, polluting the wrong key.Fix
Emit
ep.Host, which keeps any non-default port. The empty-host guard still usesHostname(). This matchesentiredb.go, which already keys onep.Host(port-aware) —credentialInputwas the lone outlier. All three credential operations (fill/approve/reject) funnel through this function, so they stay consistent.Tests
TestCredentialInput_IncludesPortassertshost=example.com:8443for a non-default-port endpoint. Existing port-less cases are unchanged.🤖 Generated with Claude Code
Note
Low Risk
Small, targeted auth helper fix with a new unit test; no API or security-model changes beyond correct credential lookup keys.
Overview
Fixes git credential helper keying for remotes on non-default ports by writing
host=host:portincredentialInputinstead of hostname-only.credentialInputnow emitsep.Host(per gitcredentials(7)) for fill/approve/reject, matching how Entire DB credential lookup already keys hosts. Default-port URLs are unchanged.Adds
TestCredentialInput_IncludesPortforexample.com:8443.Reviewed by Cursor Bugbot for commit 8bccb56. Configure here.