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

Repository paths are always considered absolute #362

Closed
osklyar opened this issue Apr 26, 2017 · 4 comments
Closed

Repository paths are always considered absolute #362

osklyar opened this issue Apr 26, 2017 · 4 comments
Assignees
Labels

Comments

@osklyar
Copy link

osklyar commented Apr 26, 2017

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.

@smola
Copy link
Collaborator

smola commented Apr 26, 2017

@osklyar Thanks for reporting this issue. We'll look into it.

@smola
Copy link
Collaborator

smola commented Apr 26, 2017

@osklyar As a workaround, you might use ~ to reference home: ssh://git@gitserver/~/repository.git

I'm working on a proper fix though.

@smola smola self-assigned this Apr 26, 2017
@smola smola added the bug label Apr 26, 2017
@osklyar
Copy link
Author

osklyar commented Apr 26, 2017

Thanks Santiago. For the moment I just forked master and changed transport/commons.go to drop the leading slash.

@smola smola closed this as completed in 45bdbcb Apr 27, 2017
smola added a commit that referenced this issue Apr 27, 2017
transport: make Endpoint an interface, fixes #362
@smola
Copy link
Collaborator

smola commented Apr 27, 2017

@osklyar This should be fixed now. Feel free to reopen if it isn't.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants