From 268c9f7250965aea3708e53a313e625700e45413 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 14 Jun 2009 00:32:06 -0400 Subject: [PATCH] - Catch a few more error conditions - Set deleted status properly when generating patchsets --- framework/Vcs/lib/Horde/Vcs/Git.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 2668fe2e3..fafccdcfb 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -192,8 +192,12 @@ class Horde_Vcs_Git extends Horde_Vcs $this->assertValidRevision($rev); $file_ob = $this->getFileObject($file); + $hash = $file_ob->getHashForRevision($rev); + if ($hash == '0000000000000000000000000000000000000000') { + throw new Horde_Vcs_Exception($file . ' is deleted in commit ' . $rev); + } - if ($pipe = popen($this->getCommand() . ' cat-file blob ' . $file_ob->getHashForRevision($rev) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r')) { + if ($pipe = popen($this->getCommand() . ' cat-file blob ' . $hash . ' 2>&1', VC_WINDOWS ? 'rb' : 'r')) { return $pipe; } @@ -478,6 +482,9 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File */ public function getHashForRevision($rev) { + if (!isset($this->_logs[$rev])) { + throw new Horde_Vcs_Exception('This file doesn\'t exist at that revision'); + } return $this->_logs[$rev]->getHashForPath($this->queryModulePath()); } @@ -754,7 +761,7 @@ class Horde_Vcs_Patchset_Git extends Horde_Vcs_Patchset 'branches' => $log->queryBranch(), 'tags' => $log->queryTags(), 'log' => $log->queryLog(), - 'members' => array() + 'members' => array(), ); foreach ($log->queryFiles() as $file) { @@ -769,19 +776,19 @@ class Horde_Vcs_Patchset_Git extends Horde_Vcs_Patchset case 'D': $from = $to; - $to = self::DEAD; + $to = null; + $status = self::DEAD; break; default: $from = $log->queryParent(); - break; } $this->_patchsets[$rev]['members'][] = array( 'file' => $file['srcPath'], 'from' => $from, 'status' => $status, - 'to' => $to + 'to' => $to, ); } } -- 2.11.0