Pergunta

I hope someone will have answered the details difference between server side and client side of GIT smart HTTP protocol.

Best way is provide some references book & code for advance.


Some people said,

libgit2 already exposes a packbuilder. However, you'll have to implement the server-side protocol by yourself.

reference to this link

Can we implement the server side with libgit2sharp(or libgit2) with small code?


Following the question above. We can dealing with pack with git.exe receive-pack and git.exe upload-pack command with --stateless-rpc argument. The implemented code are here and here.

Can we compile above codes as native code into .Net assembly? Even though we can connect ASP.NET stream and git.exe by pipeline, but it is not a good way.

Foi útil?

Solução

If you are just looking for a .NET library for interacting with GIT try GitSharp or nGit . The source code for GitSharp may also be useful since you appear to be a c# developer and GitSharp is not an automated port. Otherwise:

(as the comments above show), there isn't a whole lot of easy to find documentation on this protocol. Fortunately, Git makes reverse engineering the protocol easy and shouldn't be too difficult.

The newer Smart-Git protocol now adds another parameter to the GET http request that Older servers will ignore (older than 1.6.6) and will cause newer servers to switch to a multi post mode. The newer server at this point build a custom packfile for the client containing only the files the client needs.

In order to reverse engineer exactly what happens during the protocol portion you can use the environment variable:

SET GIT_CURL_VERBOSE=1

With this enabled, Git will output the HTTP requests and headers for each call that it makes, and will also output the HTTP status code and response headers for each response. You can also use a tool like Fiddler to see all of the http traffic that is occurring. In order to do this you will have to use a second Git environment variable to force GIT to go through the http proxy:

SET HTTP_PROXY=http://localhost:8888

At this point you basically start issuing Git commands and monitoring the http traffic.

For instance executing "git push -u origin master"

returns:

GET http://localhost:8000/gitserver/git/info/refs?service=git-receive-pack

This blog entry has a decent example of the described methodology above.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top