From: Catalin Marinas Date: Sun, 10 Sep 2006 13:56:38 +0000 (+0100) Subject: Use get-ref-list to get the commit parents X-Git-Tag: v0.14.3~468 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/2406f7d16cad24d396b3e8ea5605813f4011b5a6 Use get-ref-list to get the commit parents Thanks to Yann Dirson for submitting the initial patch. The patch was modified to only call git-rev-list when the commit parents are required, otherwise operations like 'push' would be slowed down. Signed-off-by: Catalin Marinas --- diff --git a/stgit/git.py b/stgit/git.py index c8b7b8f..2399996 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -39,7 +39,6 @@ class Commit: self.__id_hash = id_hash lines = _output_lines('git-cat-file commit %s' % id_hash) - self.__parents = [] for i in range(len(lines)): line = lines[i] if line == '\n': @@ -47,8 +46,6 @@ class Commit: field = line.strip().split(' ', 1) if field[0] == 'tree': self.__tree = field[1] - elif field[0] == 'parent': - self.__parents.append(field[1]) if field[0] == 'author': self.__author = field[1] if field[0] == 'committer': @@ -62,10 +59,11 @@ class Commit: return self.__tree def get_parent(self): - return self.__parents[0] + return self.get_parents()[0] def get_parents(self): - return self.__parents + return _output_lines('git-rev-list --parents --max-count=1 %s' + % self.__id_hash)[0].split()[1:] def get_author(self): return self.__author