Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Git wire protocol #4002

Closed
transtone opened this issue May 21, 2018 · 13 comments · Fixed by #5520
Closed

support Git wire protocol #4002

transtone opened this issue May 21, 2018 · 13 comments · Fixed by #5520
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@transtone
Copy link

transtone commented May 21, 2018

https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html

中文翻译:https://www.techug.com/post/git-v2-git-wire-protocol.html

@lunny lunny added type/proposal The new feature has not been accepted yet but needs to be discussed first. type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels May 21, 2018
@lunny lunny added this to the 1.x.x milestone May 21, 2018
@jonasfranz
Copy link
Member

Could you please add a link in English, because I am not able to read Chinese?

@lunny
Copy link
Member

lunny commented May 21, 2018

@probwebdev
Copy link

Useful information about testing v2 protocol:
https://docs.gitlab.com/ee/administration/git_protocol.html
For ssh you should allow env variable in sshd conf as mentioned above. It works, tried with docker container.
Https downgrades to v1 protocol on server side. Something with the headers i suppose

@probwebdev
Copy link

Hi once again. There's a branch for support git protocol v2 for gitlab:
https://gitlab.com/gitlab-org/gitaly/merge_requests/844/diffs
So basic idea for http support as it seems is:

  1. Receive header from client
  2. Put it into a variable
  3. Pass it to git
  4. ?

I'm not a GO developer but out of curiosity I've checked gitea sources and it seems to me that such behaviour could be implemented in routers/repo/http.go
Anyway gitlab is very helpful. Thanks to them.

@ttc0419
Copy link

ttc0419 commented May 16, 2019

So, does current version support git v2 protocal?

@NLZ
Copy link

NLZ commented Dec 16, 2019

Could we list the lack of Git Wire Protocol, Version 2 support in the comparison page (https://docs.gitea.io/en-us/comparison/)?

@lunny
Copy link
Member

lunny commented Dec 17, 2019

@NLZ please send a PR

@techknowlogick
Copy link
Member

We already support git wire protocol version 2. Closing this as complete.

@lafriks lafriks removed this from the 1.x.x milestone Dec 18, 2019
@festum
Copy link

festum commented May 4, 2020

Another reason to choose gitea rather than gogs gogs/gogs#5269

@billiegoose
Copy link
Contributor

billiegoose commented Jul 6, 2020

Sorry to raise this issue back from the dead, but cloning Gitea repositories using Git Wire Protocol Version 2 (via HTTP) still doesn't appear to work. I think this is because Gitea isn't passing the Git-Protocol header to git via the GIT_PROTOCOL environment variable like it needs to.

I think we'd need to add something like this:

	if protocol := h.r.Header.Get("Git-Protocol"); protocol != "" {
		h.environ = append(h.environ, "GIT_PROTOCOL="+protocol)
	}

to http.go probably somewhere around here.

(Source code based on the implementation in sourcegraph here)

@zeripath
Copy link
Contributor

zeripath commented Jul 6, 2020

@wmhilton That looks like it would work. Fancy making a quick PR for this? I'd recommend just double checking that nothing horrible could happen by allowing the user to arbitrarily set the value of environment variables - it might just be easier to do some verification at the cost of having to update the code at a later point.

@billiegoose
Copy link
Contributor

@zeripath Yes, I'll try making a build with that change and see if it works for me. And yes, the arbitraryness of the env var worries me too a bit... the git docs say it can consist of multiple key=value pairs separated by : but the only defined pair is version=2 so I'm tempted to only match against that... maybe I'll match against /version=\d/ or /[a-z0-9=:]+/i. I wonder how much mischief you can get into with just colons and equals signs in bash.

@billiegoose
Copy link
Contributor

It's not quite as trivial as I thought, because it requires modification of the getInfoRefs function too. But I think I'll get there.

Also, the really interesting feature of Protocol Version 2 (partial clone) requires that the repos have git config uploadpack.allowfilter 1 set on the Gitea side. And short of running it directly in ~/gitea-repositories/foo/bar I'm not sure how one could enable that. It might be nice to have a graphical checkbox in the repo settings page to enable partial clone. (Or maybe partial clone is not mainstream enough to worry about yet.)

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.