# Buggy code
def get_last_remote_commit(self):
    """
    Returns latest remote commit we know.
    """
    try:
        return self.git_repo.commit("origin/%s" % self.branch)
    except ODBError:
        # Try to reread git database in case our in memory object is not
        # up to date with it.
        self.reset_git_repo()
        return self.git_repo.commit("origin/%s" % self.branch)


# Traceback (wsgi.error)
Traceback (most recent call last):

File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/home/paour/weblate/trans/views/basic.py", line 360, in show_translation
kwargs=obj.get_kwargs(),

File "/usr/lib/python2.7/dist-packages/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)

File "/usr/lib/python2.7/dist-packages/django/template/loader.py", line 171, in render_to_string
return t.render(Context(dictionary))

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
return self._render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 123, in render
return compiled_parent._render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 62, in render
result = block.nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 155, in render
return self.render_template(self.template, context)

File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 137, in render_template
output = template.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
return self._render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/defaulttags.py", line 478, in render
output = self.nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 155, in render
return self.render_template(self.template, context)

File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 137, in render_template
output = template.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
return self._render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/defaulttags.py", line 282, in render
return nodelist.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
bit = self.render_node(node, context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 837, in render_node
return node.render(context)

File "/usr/lib/python2.7/dist-packages/django/template/defaulttags.py", line 476, in render
self.extra_context.iteritems()])

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 571, in resolve
obj = self.var.resolve(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 721, in resolve
value = self._resolve_lookup(context)

File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 772, in _resolve_lookup
current = current()

File "/home/paour/weblate/trans/models/subproject.py", line 394, in get_last_remote_commit
return self.git_repo.commit('origin/%s' % self.branch)

File "/usr/lib/python2.7/dist-packages/git/repo/base.py", line 378, in commit
return self.rev_parse(str(rev)+"^0")

File "/usr/lib/python2.7/dist-packages/git/repo/fun.py", line 151, in rev_parse
obj = name_to_object(repo, rev[:start])

File "/usr/lib/python2.7/dist-packages/git/repo/fun.py", line 86, in name_to_object
raise BadObject(name)

BadObject: BadObject: 6f726967696e2f6d6173746572


<WSGIRequest
path:/projects/mytrails/latest/hu/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': '75KCTAMYeIfPYwDPRj5UzS2dvrZgVf4S',
'sessionid': '2e45f6a09009615bdf05bfcc93098d31'},
META:{'CSRF_COOKIE': '75KCTAMYeIfPYwDPRj5UzS2dvrZgVf4S',
'DOCUMENT_ROOT': '/home/paour/weblate/weblate/media/',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
'HTTP_CONNECTION': 'Keep-Alive',
'HTTP_COOKIE': 'csrftoken=75KCTAMYeIfPYwDPRj5UzS2dvrZgVf4S; sessionid=2e45f6a09009615bdf05bfcc93098d31',
'HTTP_HOST': 'weblate.frogsparks.com',
'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)',
'PATH_INFO': u'/projects/mytrails/latest/hu/',
'PATH_TRANSLATED': '/home/paour/weblate/weblate/wsgi.py/projects/mytrails/latest/hu/',
'QUERY_STRING': '',
'REMOTE_ADDR': '198.143.175.122',
'REMOTE_PORT': '58400',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/projects/mytrails/latest/hu/',
'SCRIPT_FILENAME': '/home/paour/weblate/weblate/wsgi.py',
'SCRIPT_NAME': u'',
'SERVER_ADDR': '88.191.237.139',
'SERVER_ADMIN': 'support@frogsparks.com',
'SERVER_NAME': 'weblate.frogsparks.com',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.22 (Debian) Server at weblate.frogsparks.com Port 80</address>\n',
'SERVER_SOFTWARE': 'Apache/2.2.22 (Debian)',
'mod_wsgi.application_group': 'weblate.frogsparks.com|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80',
'mod_wsgi.process_group': '',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 3),
'wsgi.errors': <mod_wsgi.Log object at 0xb97e9ca0>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0xb98843c8>,
'wsgi.input': <mod_wsgi.Input object at 0xb97e9188>,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 1)}>

Language: None
User: None

Versions:
* Weblate weblate-1.8
* Django 1.4.5
* python-social-auth 0.1.17
* Translate Toolkit 1.9.0
* Whoosh 2.5.6
* GitPython 0.3.2 RC1
* Git 1.7.10.4
* South 0.7.5
* Pillow (PIL) 1.1.7
* ICU 1.4
* pyLibravatar N/A

# Fixed code
def get_last_remote_commit(self):
    """
    Returns latest remote commit we know.
    """
    try:
        return self.git_repo.commit("origin/%s" % self.branch)
    except ODBError:
        # Try to reread git database in case our in memory object is not
        # up to date with it.
        self.git_repo.odb.update_cache()
        return self.git_repo.commit("origin/%s" % self.branch)