Expand description
Resolve the LFS server endpoint for a repo.
Implements the priority chain documented in
docs/api/server-discovery.md, plus the SSH/git URL → HTTPS rewriting
upstream does so a git@github.com:foo/bar.git remote yields the
expected https://github.com/foo/bar.git/info/lfs endpoint.
§Priority order
GIT_LFS_URLenvironment variable (matches upstream’s escape hatch).lfs.urlfrom git config — local → global → system →.lfsconfig.remote.<name>.lfsurl(same scopes as above).remote.<name>.urlrewritten viaderive_lfs_url.
<name> defaults to origin when the caller hasn’t passed a remote.
§SSH-style URLs
git lfs itself only speaks HTTP(S); for SSH remotes the protocol is
still HTTPS, just inferred from the remote’s host/path. Upstream also
supports the git-lfs-authenticate SSH command for handing back a
token; that’s deferred (see NOTES.md).
Structs§
- Endpoint
Info - LFS endpoint resolution result with the optional SSH metadata
upstream’s
git lfs envdisplays alongside the HTTPS-equivalent endpoint URL. - SshInfo
- SSH-shaped remote/endpoint URL parsed into the components
git lfs envechoes back asSSH=<user_and_host>:<path>.
Enums§
Functions§
- derive_
lfs_ url - Convert a clone URL into the matching LFS endpoint URL.
- endpoint_
for_ remote - Resolve the LFS endpoint URL for
cwd+remote. PassNonefor the default (origin, with a “single remote” fallback when origin doesn’t exist and exactly one other remote does). - looks_
like_ url - Quick syntactic check: does
slook like one of the URL formsderive_lfs_urlrecognizes? Used to decide whether to treat a “remote name” argument as a literal URL. - parse_
ssh_ url - Extract the SSH metadata from a remote URL — the
<user_and_host>and<path>piecesgit lfs envechoes back asSSH=<user_and_host>:<path>. ReturnsNonefor URLs that don’t look SSH-shaped (HTTP(S), git://, file://, plain paths). - resolve_
endpoint - Like
endpoint_for_remote, but also returns the SSH metadata when the underlying URL was SSH-shaped. Used bygit lfs envto render theSSH=<user_and_host>:<path>line alongside the HTTPS-equivalent endpoint.