diff --git a/pygit/pygit.py b/pygit/pygit.py
index c3fb008..0edb26e 100644
--- a/pygit/pygit.py
+++ b/pygit/pygit.py
@@ -161,7 +161,10 @@ def commits_stats(rid,branch='master'):
def commit_stats(rid,cid):
r = open_repo(rid)
c = r.commit(cid)
- return c.stats.total, c.stats.files
+ try:
+ return c.stats.total, c.stats.files
+ except ValueError: # This is a bug in GitPython
+ return {'files':0, 'insertions':0,'deletions':0,'lines':0}, {}
def commit_message(rid,cid):
r = open_repo(rid)
diff --git a/pygit/views.py b/pygit/views.py
index c18ed46..1ddb017 100644
--- a/pygit/views.py
+++ b/pygit/views.py
@@ -135,7 +135,10 @@ def diff_file(request,rid,branch,cid,path):
total,files = pygit.commit_stats(rid,cid)
ds = pygit.diff_path(rid,path,cid)
if ds:
- ds[0] = (ds[0][0], ds[0][1], files[path])
+ try:
+ ds[0] = (ds[0][0], ds[0][1], files[path])
+ except KeyError: # Workaround bug in GitPython
+ ds[0] = ('NoFile','',{'lines':0, 'insertions':0, 'deletions':0})
repo = repo_rid(rid)
ds = map(format_diff,ds)
return render_it('git_diff.html',
@@ -159,7 +162,10 @@ def diff_all(request,rid,branch,cid):
total,files = pygit.commit_stats(rid,cid)
ds = pygit.diff_all(rid,cid)
if ds:
- ds = [(d[0],d[1], files[d[0]]) for d in ds]
+ try:
+ ds = [(d[0],d[1], files[d[0]]) for d in ds]
+ except KeyError: # Workaround bug in GitPython
+ ds = []
repo = repo_rid(rid)
ds = map(format_diff,ds)
return render_it('git_diff.html',