# HG changeset patch # User Matt Harbison # Date 1523485409 14400 # Node ID 9c7a25ef5b49f3ce2fe698b58246b622ca9fd382 # Parent 31a4ea773369fc4937f9f3effc43f4a5167c8c74 lfs: handle paths that don't end with '/' when inferring the blob store While here, I also checked the lfs.url config directly instead of testing the scheme, as requested by Yuya. diff -r 31a4ea773369 -r 9c7a25ef5b49 hgext/lfs/blobstore.py --- a/hgext/lfs/blobstore.py Sun Apr 08 14:22:12 2018 -0400 +++ b/hgext/lfs/blobstore.py Wed Apr 11 18:23:29 2018 -0400 @@ -539,23 +539,28 @@ https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md """ - url = util.url(repo.ui.config('lfs', 'url') or '') - if url.scheme is None: + lfsurl = repo.ui.config('lfs', 'url') + url = util.url(lfsurl or '') + if lfsurl is None: if remote: - defaulturl = util.url(remote) + path = remote elif util.safehasattr(repo, '_subtoppath'): # The pull command sets this during the optional update phase, which # tells exactly where the pull originated, whether 'paths.default' # or explicit. - defaulturl = util.url(repo._subtoppath) + path = repo._subtoppath else: # TODO: investigate 'paths.remote:lfsurl' style path customization, # and fall back to inferring from 'paths.remote' if unspecified. - defaulturl = util.url(repo.ui.config('paths', 'default') or b'') + path = repo.ui.config('paths', 'default') or '' + + defaulturl = util.url(path) # TODO: support local paths as well. # TODO: consider the ssh -> https transformation that git applies if defaulturl.scheme in (b'http', b'https'): + if defaulturl.path and defaulturl.path[:-1] != b'/': + defaulturl.path += b'/' defaulturl.path = defaulturl.path or b'' + b'.git/info/lfs' url = util.url(bytes(defaulturl))