Browse files

Hopefully fix GitPlugin's broken caching behavior.

This hopefully fixes all the "no such changeset" errors in Trac.  Basically
trac-admin's changeset added event updates trac-admin's GitPlugin's cache
(and Trac's persistent cache), but Trac that's running under Apache is a
separate process and thus GitPlugin's non-peristent cache goes stale without
GitPlugin knowing it.  Trac's persistent cache contains a new changeset, Trac
attempts to construct a CachedChangeset, which calls normalize_rev, which in
turn calls verifyrev.  This fix causes verifyrev to rebuild GitPlugin's cache
if git rev-parse returns a valid SHA that isn't in the current cache.
  • Loading branch information...
1 parent 4d8d447 commit f65bc126fd9d2926a81f0d0ae5009edc986c8cf3 @scbash scbash committed with Oct 8, 2010
Showing with 6 additions and 0 deletions.
  1. +6 −0 tracext/git/
6 tracext/git/
@@ -503,13 +503,19 @@ def verifyrev(self, rev):
if rc in _rev_cache.rev_dict:
return rc
+ elif GitCore.is_sha(rc):
+ # rev-parse returned a sha, it's possible the db is just out of date
+ # Flag the db for rebuilding, and try again
+ self.__rev_cache = None
+ return self.verifyrev(rev)
if rc in _rev_cache.tag_set:
sha = self.repo.cat_file("tag", rc).split(None, 2)[:2]
if sha[0] != 'object':
self.logger.debug("unexpected result from 'git-cat-file tag %s'" % rc)
return None
return sha[1]
+ # XXX might need a "db is out of date" branch here as well
return None

0 comments on commit f65bc12

Please sign in to comment.