Git push problem

Issue #368 resolved
codingtony created an issue

I've tried to push to the demo using 2 different application. TortoiseGit and Egit (an Eclipse plugin for Git). It work well with Tortoise, but not with Egit. I was suspecting a problem with Egit, but after a wireshark dump I've noticed that the behavior of rhodecode is somewhat strange.

Is it possible that rhodecode is oversensitive with the http headers? since the same request returns 404 for one of the two.

== here's the wireshark payload after push with tortoise : == //after the authentication...//

GET /testcoding/info/refs?service=git-receive-pack HTTP/1.1

Authorization: Basic ZGVtbzpkZW1vMTI=

User-Agent: git/1.7.3.1.msysgit.0

Host: demo.rhodecode.org

Accept: /

Pragma: no-cache

**HTTP/1.1 200 OK Server: nginx

Date: Mon, 27 Feb 2012 05:55:38 GMT

Content-Type: application/x-git-receive-pack-advertisement

Transfer-Encoding: chunked

We see the 200 OK.

== However with Egit here's what we got : ==

GET /testcoding/info/refs?service=git-receive-pack HTTP/1.1

Accept-Encoding: gzip

Pragma: no-cache

User-Agent: JGit/1.3.0.201202151440-r

Accept: application/x-git-receive-pack-advertisement, /

Cache-Control: no-cache

Host: demo.rhodecode.org

Connection: keep-alive

HTTP/1.1 404 Not Found Server: nginx [...]

Comments (7)

  1. codingtony reporter

    I think the problem is with this code : rhodecode\lib\middleware\simplegit.py

    def is_git(environ):
        """Returns True if request's target is git server.
        ``HTTP_USER_AGENT`` would then have git client version given.
    
        :param environ:
        """
        http_user_agent = environ.get('HTTP_USER_AGENT')
        if http_user_agent and http_user_agent.startswith('git'):
            return True
        return False
    
  2. Marcin Kuzminski repo owner

    ok it look like EGit uses it's own USER_AGENT, that's why it's not detected as git-request. I can argue why it's not compatible with git client. I'll think about how to solve it than

  3. codingtony reporter

    I understand. However, I know that Egit works with GitHub and I'm unable to find out an official specification for the git User-Agent http header.

    I think this would do the job. Do you think it's a good idea?

    import re
    
    gitUserAgentPattern = re.compile("^git.*|^JGit.*")
    
    

    then :

    if http_user_agent and gitUserAgentPattern.match(http_user_agent):
            return True
    
  4. Marcin Kuzminski repo owner

    Hmm looks like a solution, but i'm only afraid that sometime EGit will change theire user_agent to SuperJGit :) or something, I'll try to look for better solution, maybe by detecting git-receive-pack/git-upload-pack

  5. Log in to comment