libfetchers: drop leading slash from the git-lfs credential path - #46
Merged
Conversation
lilyinstarlight
approved these changes
Aug 10, 2026
GoodForOneFare
force-pushed
the
gordo-strip-creds-leading-slash
branch
2 times, most recently
from
August 10, 2026 14:13
f7f9ec6 to
67447b6
Compare
lilyinstarlight
enabled auto-merge
August 10, 2026 14:15
GoodForOneFare
force-pushed
the
gordo-strip-creds-leading-slash
branch
from
August 10, 2026 14:18
67447b6 to
a3e2e52
Compare
Git's credential protocol has a specific shape for the path attribute, and getLfsApi did not produce it. When git composes a credential request itself it strips the leading slash and percent-decodes what remains (credential.c), so for https://example.com/my%20repo.git a helper is handed `path=my repo.git`. getLfsApi passed url.renderPath(true), which keeps the slash and re-encodes every segment, so a helper matching on the path looked up a key git never writes and returned nothing. The request then falls through to a prompt, which on a non-interactive machine ends in fatal: could not read Username for 'https://github.com//repo.git/info/lfs' the doubled slash being the same leading character rendered back. Build the attribute the way git does instead. ParsedURL::path already holds decoded segments, so renderPath() without the encode flag joins them exactly as git writes them, and the leading slash is stripped before the request is composed. That also settles an asymmetry: the ssh branch a few lines up already renders the path unencoded, which left the credential branch as the only encoding caller in the tree. Report the stripped value in the two failure messages as well, so they match what was actually asked.
lilyinstarlight
force-pushed
the
gordo-strip-creds-leading-slash
branch
from
August 10, 2026 15:25
a3e2e52 to
82123ce
Compare
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.
Motivation
Git's credential protocol takes the path without a leading slash: for
https://example.com/repo.gitthe path attribute isrepo.git, and that is what a helper sees when Git composes the request itself.getLfsApipassedurl.renderPath(true), which keeps the slash, so a helper that matches on the path looked up a key Git never writes and returned nothing. The request then falls through to a prompt, which on a non-interactive machine ends inthe doubled slash being the same leading character rendered back.
Strip it before composing the request, and report the stripped value in the two failure messages so they match what was actually asked.