Git fails to clone repo from ownCloud's webdav interface

不打扰是莪最后的温柔 提交于 2019-12-06 05:05:15

问题


I am having some personal git repos on my ownCloud. I can clone it from 2 ubuntu machines and a Windows PC by accessing ownClouds webdav url: http://myserver.a/remote.php/webdav/repos/repo.git

Recently I installed Arch Linux with git version 1.8.1.5 and it fails with this error message: fatal: http://myserver.a/remote.php/webdav/repos/repo.git/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?

I did add the post-update hook, eventually it works on my other machines. The servers error.log says 404 when git asks for ...info/refs?service...

The ubuntu git 1.7 requests the same url from the server. But after receiving an error code 404 it requests for .../info/refs HTTP/1.1 and succeeds with code 200.

So why does the newer git fail and how can I fix it?


回答1:


The whole ?service=... thing is for git's smart HTTP support introduced in 1.6.6. It's much more efficient than the traditional HTTP support but requires a special CGI binary to be run on the web server and does not work with WebDAV.

IMO, in any non-broken WebDAV implementation, it should be ignored, but apparently ownCloud thinks it's part of the filename or something, and so produces an error. It might make sense to talk to the ownCloud developers about this.

In older versions, git fell back to a URL without that suffix, but that had its own problems. So, the second request was removed in 1.8.0 and a new option was introduced that you can use to turn off smart HTTP and use the old URL directly (this should fix the problem). It works like this, for instance:

GIT_SMART_HTTP=0 git fetch

If you never want to use smart HTTP (but be aware that it does work on Github and every other sane hosting site, and push won't work without it there), you can export that environment variable in your shell profile.

Details about the change at https://git.kernel.org/cgit/git/git.git/commit/?id=02572c2e3afcc200936260f48863447726212a7c.




回答2:


I came across the same problem with pushing my Git repository to next cloud recently. I checked the contents of the repository and found that there was no such file info/refs there.

Researching that led me to this thread: can't clone git repos via http; info/refs not found

Executing the proposed command git update-server-info in the repository base directory created the missing file, and I did not get the 404 error anymore. So the query-string is not the problem here.

Unfortunately I get another error ("error: no DAV locking support on ..."), which is documented here https://help.nextcloud.com/t/webdav-lock-on-file-doesnt-work/21451 (with a link to a github-issue for the Nextcloud project).

Sadly, no Git repositories over WebDAV on Nextcloud yet.



来源:https://stackoverflow.com/questions/15236135/git-fails-to-clone-repo-from-ownclouds-webdav-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!