Do not crash list view when seeing a fully empty git repository
[phorkie.git] / src / phorkie / Repositories.php
index 729ff23afbab88e5664d45fa6330016388b68532..ab97c566a47291fbd58158e785f3bfe7413ca039 100644 (file)
@@ -65,7 +65,16 @@ class Repositories
         $repos = array();
         foreach ($some as $oneDir) {
             $r = new Repository();
         $repos = array();
         foreach ($some as $oneDir) {
             $r = new Repository();
-            $r->loadById(substr($oneDir, 0, -4));
+            try {
+                $r->loadById(substr($oneDir, 0, -4));
+            } catch (\VersionControl_Git_Exception $e) {
+                if (strpos($e->getMessage(), 'does not have any commits') !== false) {
+                    //the git repo is broken as the initial commit
+                    // has not been finished
+                    continue;
+                }
+                throw $e;
+            }
             $repos[] = $r;
         }
         return array($repos, count($dirs), $page);
             $repos[] = $r;
         }
         return array($repos, count($dirs), $page);