Skip to content

libfetchers: drop leading slash from the git-lfs credential path - #46

Merged
lilyinstarlight merged 1 commit into
mainfrom
gordo-strip-creds-leading-slash
Aug 10, 2026
Merged

libfetchers: drop leading slash from the git-lfs credential path#46
lilyinstarlight merged 1 commit into
mainfrom
gordo-strip-creds-leading-slash

Conversation

@GoodForOneFare

Copy link
Copy Markdown
Member

Motivation

Git's credential protocol takes the path without a leading slash: for https://example.com/repo.git the path attribute is repo.git, and that is what a helper sees when Git composes the request itself. getLfsApi passed url.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 in

    fatal: could not read Username for 'https://github.com//repo.git/info/lfs'

the 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.

@GoodForOneFare
GoodForOneFare force-pushed the gordo-strip-creds-leading-slash branch 2 times, most recently from f7f9ec6 to 67447b6 Compare August 10, 2026 14:13
@GoodForOneFare
GoodForOneFare force-pushed the gordo-strip-creds-leading-slash branch from 67447b6 to a3e2e52 Compare August 10, 2026 14:18
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
lilyinstarlight force-pushed the gordo-strip-creds-leading-slash branch from a3e2e52 to 82123ce Compare August 10, 2026 15:25
@lilyinstarlight
lilyinstarlight merged commit dea9fd6 into main Aug 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants