Modify

Opened 3 years ago

Closed 14 months 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: hvr
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 follow-ups: Changed 3 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 3 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 3 years ago by phdm@…

  • Priority changed from normal to high
  • Severity changed from normal to critical

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 3 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 3 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 2 years ago by anonymous

  • Severity changed from critical to blocker

comment:7 in reply to: ↑ 1 Changed 2 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 2 years ago by stuge

  • Cc stuge added

comment:9 Changed 20 months ago by alx@…

  • Trac Release changed from 0.12 to 1.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 19 months ago by jun66j5

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

comment:11 Changed 14 months ago by jun66j5

  • Resolution set to fixed
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from hvr. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.