summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/git/cmd.py1
-rw-r--r--lib/git/commit.py11
-rw-r--r--lib/git/repo.py1
3 files changed, 4 insertions, 9 deletions
diff --git a/lib/git/cmd.py b/lib/git/cmd.py
index aef53350..21e235b1 100644
--- a/lib/git/cmd.py
+++ b/lib/git/cmd.py
@@ -6,7 +6,6 @@
import os, sys
import subprocess
-import re
from utils import *
from errors import GitCommandError
diff --git a/lib/git/commit.py b/lib/git/commit.py
index 3d383df2..961e483b 100644
--- a/lib/git/commit.py
+++ b/lib/git/commit.py
@@ -20,6 +20,9 @@ class Commit(LazyMixin):
This class will act lazily on some of its attributes and will query the
value on demand only if it involves calling the git binary.
"""
+ # precompiled regex
+ re_actor_epoch = re.compile(r'^.+? (.*) (\d+) .*$')
+
def __init__(self, repo, id, tree=None, author=None, authored_date=None,
committer=None, committed_date=None, message=None, parents=None):
"""
@@ -246,12 +249,6 @@ class Commit(LazyMixin):
"""
if not self.parents:
d = self.repo.git.show(self.id, '-M', full_index=True, pretty='raw')
- if re.search(r'diff --git a', d):
- if not re.search(r'^diff --git a', d):
- p = re.compile(r'.+?(diff --git a)', re.MULTILINE | re.DOTALL)
- d = p.sub(r'diff --git a', d, 1)
- else:
- d = ''
return diff.Diff.list_from_string(self.repo, d)
else:
return self.diff(self.repo, self.parents[0].id, self.id)
@@ -291,6 +288,6 @@ class Commit(LazyMixin):
Returns
[Actor, gmtime(acted at time)]
"""
- m = re.search(r'^.+? (.*) (\d+) .*$', line)
+ m = cls.re_actor_epoch.search(line)
actor, epoch = m.groups()
return (Actor.from_string(actor), time.gmtime(int(epoch)))
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 1c4b4095..811cf6f0 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -5,7 +5,6 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
-import re
import gzip
import StringIO
from errors import InvalidGitRepositoryError, NoSuchPathError