From e4582f805156095604fe07e71195cd9aa43d7a34 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Tue, 16 Dec 2008 19:44:49 -0500 Subject: fixed Commit.stats retrieval for parentless commits in bare repos (cherry picked from commit 88852ed7bcde4f4b18c1ae8b6fba7f3fab8e9bf5) --- lib/git/commit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/git/commit.py') diff --git a/lib/git/commit.py b/lib/git/commit.py index 091cf78c..f8c7e61f 100644 --- a/lib/git/commit.py +++ b/lib/git/commit.py @@ -165,7 +165,7 @@ class Commit(LazyMixin): message = '\n'.join(messages) - commits.append(Commit(repo, id=id, parents=parents, tree=tree, author=author, authored_date=authored_date, + commits.append(Commit(repo, id=id, parents=parents, tree=tree, author=author, authored_date=authored_date, committer=committer, committed_date=committed_date, message=message)) return commits @@ -224,11 +224,11 @@ class Commit(LazyMixin): @property def stats(self): if not self.parents: - text = self.repo.git.diff(self.id, '--', numstat=True) + text = self.repo.git.diff_tree(self.id, '--', numstat=True, root=True) text2 = "" - for line in text.splitlines(): + for line in text.splitlines()[1:]: (insertions, deletions, filename) = line.split("\t") - text2 += "%s\t%s\t%s\n" % (deletions, insertions, filename) + text2 += "%s\t%s\t%s\n" % (insertions, deletions, filename) text = text2 else: text = self.repo.git.diff(self.parents[0].id, self.id, '--', numstat=True) -- cgit v1.2.1