diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-03 19:49:38 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-03 19:49:38 +0100 |
commit | e648efdcc1ca904709a646c1dbc797454a307444 (patch) | |
tree | 1643094b3367c6c087e5e5ee2cb402c8318ce1e9 | |
parent | 9b426893ce331f71165c82b1a86252cd104ae3db (diff) | |
download | gitpython-e648efdcc1ca904709a646c1dbc797454a307444.tar.gz |
remotes are now retrieved directly by parsing the repository configuration file. This removes a git command invocation
-rw-r--r-- | TODO | 9 | ||||
-rw-r--r-- | lib/git/remote.py | 14 |
2 files changed, 14 insertions, 9 deletions
@@ -13,8 +13,6 @@ General the std-in command types, as it appears they are not killed when the repo gets deleted. A clear() method could already help to allow long-running programs to remove cached commands after an idle time. -* References should be parsed 'manually' to get around command invocation, but - be sure to be able to read packed refs. Object ------ @@ -83,6 +81,7 @@ Refs * For performance reasons it would be good to reimplement git-update-ref to be fully equivalent to what the command does. Currently it does some checking and handles symbolic refs as well as normal refs, updating the reflog if required. + Its low-priority though as we don't set references directly that often. * I have read that refs can be symbolic refs as well which would imply the need to possibly dereference them. This makes sense as they originally where possibly a symbolic link. This would mean References could be derived from SymbolicReference @@ -90,11 +89,11 @@ Refs * Making the reflog available as command might be useful actually. This way historical references/commits can be returned. Git internally manages this if refs are specified with HEAD@{0} for instance - +* References should be parsed 'manually' to get around command invocation, but + be sure to be able to read packed refs. + Remote ------ -* iter_items should parse the configuration file manually - currently a command - is issued which is much slower than it has to be ( compared to manual parsing ) * When parsing fetch-info, the regex will not allow spaces in the target remote ref as I couldn't properly parse the optional space separated note in that case. Probably the regex should be improved to handle this gracefully. diff --git a/lib/git/remote.py b/lib/git/remote.py index 5019daee..1b054253 100644 --- a/lib/git/remote.py +++ b/lib/git/remote.py @@ -444,10 +444,16 @@ class Remote(LazyMixin, Iterable): Returns Iterator yielding Remote objects of the given repository """ - seen_remotes = set() - for name in repo.git.remote().splitlines(): - yield Remote(repo, name) - # END for each ref + for section in repo.config_reader("repository").sections(): + print section + if not section.startswith('remote'): + continue + lbound = section.find('"') + rbound = section.rfind('"') + if lbound == -1 or rbound == -1: + raise ValueError("Remote-Section has invalid format: %r" % section) + yield Remote(repo, section[lbound+1:rbound]) + # END for each configuration section @property def refs(self): |