﻿id	summary	reporter	owner	description	type	status	priority	component	severity	resolution	keywords	cc	release
2672	git plugin complains of: UnboundLocalError: local variable 'rev' referenced before assignment  with an empty repository	wam-trac-hacks-org@…	Samat Jain	"When loading the Git plugin (for the trac .11 release) I get:

Trac detected an internal error:
UnboundLocalError: local variable 'rev' referenced before assignment

If I go into the source of the TracGit module, and execute PyGit.py, I get a similar error:

draal:~/gitplugin/0.11/tracext/git$ python PyGIT.py /data/git/[scrubbed]/.git
git version [{'v_tuple': (1, 5, 2, 5), 'v_min_tuple': (1, 5, 2), 'v_compatible': True, 'v_min_str': '1.5.2', 'v_str': '1.5.2.5'}]
statm = (5029888, 3309568, 1613824, 1011712, 0, 1720320, 0)
DATA:      0     +0
DATA:      0     +0
Traceback (most recent call last):
  File ""PyGIT.py"", line 694, in <module>
    print ""[%s]"" % g.head()
  File ""PyGIT.py"", line 358, in head
    return self.verifyrev(""HEAD"")
  File ""PyGIT.py"", line 364, in verifyrev
    db, tag_db = self.rev_cache[2:4]
  File ""PyGIT.py"", line 269, in get_rev_cache
    oldest = rev
UnboundLocalError: local variable 'rev' referenced before assignment

This was from the latest zip file that was pulled down Feb 26, 2008

Looking into the code a bit, I realized that the problem comes from PyGIT's processing of an empty repository (immediately after 'git init' and before any commits). Once I discovered this, I added a file to the repository and the problem went away.
"	defect	new	normal	TracGitPlugin	normal		git GitPlugin		0.11
