--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -256,7 +256,8 @@
         self.compute_diffs(commit_ids)
         for head in self.heads + self.branches + self.tags:
             ci = self.commit(head.object_id)
-            head.count = ci.count_revisions()
+            if ci is not None:
+                head.count = ci.count_revisions()
         session(self).flush()
         return len(commit_ids)