From 60b95e211926167f1d5aa31311ff6d2d12431ea9 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Fri, 12 Jun 2009 23:06:58 -0400 Subject: [PATCH] - Horde_Vcs_Git::isFile() now optionally knows about branches other than master - use isFile when instantiating a file object to optionally throw a better error message if we get no output. --- framework/Vcs/lib/Horde/Vcs/Git.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 655acdb87..9788d97af 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -80,10 +80,12 @@ class Horde_Vcs_Git extends Horde_Vcs /** * TODO */ - public function isFile($where) + public function isFile($where, $branch = null) { + if (!$branch) { $branch = 'master'; } + $where = str_replace($this->sourceroot() . '/', '', $where); - $command = $this->getCommand() . ' ls-tree master ' . escapeshellarg($where) . ' 2>&1'; + $command = $this->getCommand() . ' ls-tree ' . escapeshellarg($branch) . ' ' . escapeshellarg($where) . ' 2>&1'; exec($command, $entry, $retval); if (!count($entry)) { return false; } @@ -406,6 +408,13 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File } exec($cmd, $revs); + if (count($revs) == 0) { + if (!$rep->isFile($fl, isset($opts['branch']) ? $opts['branch'] : null)) { + throw new Horde_Vcs_Exception('No such file: ' . $fl); + } else { + throw new Horde_Vcs_Exception('No revisions found'); + } + } if (stripos($revs[0], 'fatal') === 0) { throw new Horde_Vcs_Exception(implode(', ', $revs)); } -- 2.11.0