From ab7d5ea58ca0a7a129af2453105c80e48b24ab00 Mon Sep 17 00:00:00 2001 From: Aria Stewart Date: Sat, 17 Mar 2012 22:48:43 -0400 Subject: [PATCH 1/2] Avoid errors on repositories with no packs --- lib/Glip/Git.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Glip/Git.php b/lib/Glip/Git.php index 58f2dfe..43f7ce1 100644 --- a/lib/Glip/Git.php +++ b/lib/Glip/Git.php @@ -112,7 +112,7 @@ public function __construct($dir, &$stashSource = null, $stashKey = 'git_stash') $this->packs = array(); $dh = opendir(sprintf('%s/objects/pack', $this->dir)); - while (($entry = readdir($dh)) !== FALSE) + while ($dh and ($entry = readdir($dh)) !== FALSE) if (preg_match('#^pack-([0-9a-fA-F]{40})\.idx$#', $entry, $m)) $this->packs[] = new SHA($m[1]); } From 18044b47c93707d4c00c4ecec1d88d525819ffc8 Mon Sep 17 00:00:00 2001 From: Aria Stewart Date: Sun, 18 Mar 2012 00:14:14 -0400 Subject: [PATCH 2/2] Improve non-pack handling --- lib/Glip/Git.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Glip/Git.php b/lib/Glip/Git.php index 43f7ce1..5f071d7 100644 --- a/lib/Glip/Git.php +++ b/lib/Glip/Git.php @@ -111,10 +111,11 @@ public function __construct($dir, &$stashSource = null, $stashKey = 'git_stash') } $this->packs = array(); - $dh = opendir(sprintf('%s/objects/pack', $this->dir)); - while ($dh and ($entry = readdir($dh)) !== FALSE) - if (preg_match('#^pack-([0-9a-fA-F]{40})\.idx$#', $entry, $m)) - $this->packs[] = new SHA($m[1]); + $dir = sprintf('%s/objects/pack', $this->dir); + if (is_dir($dir) and $dh = opendir(sprintf('%s/objects/pack', $this->dir))) + while (($entry = readdir($dh)) !== FALSE) + if (preg_match('#^pack-([0-9a-fA-F]{40})\.idx$#', $entry, $m)) + $this->packs[] = new SHA($m[1]); } /**