Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Repository paths are always considered absolute #362

@osklyar

Description

@osklyar

Our company git repository is hosted as a plain collection of git directories in the home dir of the hosting user git. That is when I clone git@gitserver:a/b I am actually cloning from gitserver:/home/git/a/b. The standard git client supports this setup without any further client side configuration.

Trying to clone the same repository with go-git results in a repository not found error. Adding the server-side base path to the repository on the client side, that is cloning git@gitserver:home/git/a/b solves the issue, but this behaviour is different from the standard client!

The error does not occur when a daemon is run with a correct value for base-path (such as in public services like github), but the general problem is that the path passed to the server is absolute, that is, it starts with a slash. Dropping the slash prefix in place where the URL is parsed keeps the support for github and Co, but also enables it for this most basic setup.

Here is what happens step by step:

The transport.NewEndpoint function first converts git@gitserver:a/b into ssh://git@gitserver/a/b, then it calls the url.Parse method, which, in turn, returns the URL structure with the Path already set to /a/b. Then the client is created and it sends this absolute path to the server. Dropping the leading slash between parsing the original URL and returning the endpoint solves the issue, but seems ugly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions