Modify

Opened 13 years ago

Closed 11 years ago

#8682 closed defect (fixed)

GitConnector: __init__ calls git_version(git_bin) from PyGIT using git-receive-pack instead of git

Reported by: stiffy2@… Owned by: Herbert Valerio Riedel
Priority: high Component: GitPlugin
Severity: blocker Keywords:
Cc: stuge Trac Release: 1.0

Description

In version '0.12.0.5', GitConnector.__init__ calls Storage.git_version with /usr/bin/git-receive-pack. Storage.git_version fails, as git-receive-pack hasn't got the option --version. I don't know what causes this error, as i explicitly set git_bin = /usr/bin/git in conf/trac.ini. Adding

self.log.error("My git_bin is %s" %self._git_bin)

to GitConnector.__init__ causes the following output:

2011-04-07 13:04:31,435 Trac[git_fs] ERROR: My git_bin is /usr/bin/git-receive-pack

Attachments (0)

Change History (11)

comment:1 Changed 13 years ago by mgarraha

Some Linux distros have a chain of symbolic links from /usr/bin/git to /usr/bin/git-receive-pack. I suppose the os.path.realpath in Section.getpath (called by PathOption constructor, config.py in Trac) follows the links. I patched my trac-git-plugin sources as follows:

  • tracext/git/git_fs.py

    diff --git a/tracext/git/git_fs.py b/tracext/git/git_fs.py
    index c33536c..de04769 100644
    a b class GitConnector(Component): 
    193193    _git_fs_encoding = Option('git', 'git_fs_encoding', 'utf-8',
    194194                              "define charset encoding of paths within git repository")
    195195
    196     _git_bin = PathOption('git', 'git_bin', '/usr/bin/git',
     196    _git_bin = Option('git', 'git_bin', '/usr/bin/git',
    197197                          "path to git executable (relative to trac project folder!)")
    198198
    199199

comment:2 in reply to:  1 Changed 13 years ago by mgarraha

PS: this may cause bug #8465.

Alternative workaround: build Git from source, install to /usr/local, and put this in conf/trac.ini:

[git]
git_bin = /usr/local/bin/git

comment:3 in reply to:  1 Changed 13 years ago by phdm@…

Priority: normalhigh
Severity: normalcritical

Replying to mgarraha:

[...]

This causes bug #8465 on opensuse 11.3 e.g., making the git trac plugin unusable there :(

Your patch fixes it for me.

comment:4 Changed 13 years ago by admin@…

I also have this problem on a Ubuntu (10.04) machine where git is installed at /usr/bin/git (with no symlink).

it was announced as TypeError: 'NoneType' object is unsubscriptable.

Trace:

File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", Line 511, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", Line 202, in dispatch
  chosen_handler)
File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", Line 344, in _pre_process_request
  chosen_handler = filter_.pre_process_request(req, chosen_handler)
File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/versioncontrol/api.py", Line 330, in pre_process_request
  repo = self.get_repository(reponame)
File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/versioncontrol/api.py", Line 526, in get_repository
  repos = connector.get_repository(rtype, rdir, repoinfo.copy())
File "/usr/lib/python2.6/dist-packages/tracext/git/git_fs.py", Line 159, in get_repository
  shortrev_len=self._shortrev_len)
File "/usr/lib/python2.6/dist-packages/tracext/git/git_fs.py", Zeile 177, in __init__
  Repository.__init__(self, "git:"+path, None, log)
File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/versioncontrol/api.py", Line 732, in __init__
  self.reponame = params['name']

however I guess the problem is here: File "/usr/lib/python2.6/dist-packages/tracext/git/git_fs.py", Zeile 177, in init

Code:
Line    
172		self.gitrepo = path
173		self._shortrev_len = max(4, min(shortrev_len, 40))
174		
175		self.git = PyGIT.StorageFactory(path, log, not persistent_cache,
176		git_bin=git_bin).getInstance()
177		Repository.__init__(self, "git:"+path, None, log)
178	
179	def close(self):
180		self.git = None
181		
182	def clear(self, youngest_rev=None):

Local Variables:
Name		Value
git_bin		 u'/usr/bin/git'
log		 <logging.Logger instance at 0x30edd88>
path		 u'/var/git/project/.git'
persistent_cache False
self		 <tracext.git.git_fs.GitRepository object at 0x3728ad0>
shortrev_len	 7

comment:5 Changed 12 years ago by sven@…

Patch from mgarraha works fine on openSUSE 11.3 and 11.4.

https://bugzilla.novell.com/show_bug.cgi?id=697156

Trac-Hacks ticket#8473 discusses same problem -> maybe merge it?

comment:6 Changed 12 years ago by anonymous

Severity: criticalblocker

comment:7 in reply to:  1 Changed 12 years ago by scottso@…

Replying to mgarraha:

I had the same problem on OpenSuSE 12.1, and mgarraha's did the trick for me too.

comment:8 Changed 12 years ago by stuge

Cc: stuge added; anonymous removed

comment:9 Changed 11 years ago by alx@…

Trac Release: 0.121.0

Same problem with openSUSE 12.2 (x86_64) and Trac-1.0

Trac-1.0 was built and installed from source archive (with sudo python setup.py install) git version 1.7.10.4 installed with yast2. python 2.7.3 installed with yast2.

Patch from mgarraha solve the problem.

Can you confirm that there is no side effect with it ?

Regards,

comment:10 Changed 11 years ago by Jun Omae

The patch should be applied to Trac core. I've filed the issue in t:#10997.

comment:11 Changed 11 years ago by Jun Omae

Resolution: fixed
Status: newclosed

The t:#10997 has been fixed in Trac 1.0.1. If you are using Trac 0.12.x, try https://github.com/jun66j5/trac-git-plugin.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Herbert Valerio Riedel.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.