Fix HEAD commit lookup on blob_plain
Fix HEAD commit lookup on blob_plain

Bug #79

--- a/include/controller/Controller_Blob.class.php
+++ b/include/controller/Controller_Blob.class.php
@@ -120,14 +120,20 @@
 				else
 					$saveas = $this->params['hash'] . ".txt";
 
-				$blob = $this->project->GetBlob($this->params['hash']);
-				$blob->SetPath($this->params['file']);
-
 				$headers = array();
 
 				$mime = null;
-				if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true))
+				if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) {
+					if ((!isset($this->params['hash'])) && (isset($this->params['file']))) {
+						$commit = $this->project->GetCommit($this->params['hashbase']);
+						$this->params['hash'] = $commit->PathToHash($this->params['file']);
+					}
+
+					$blob = $this->project->GetBlob($this->params['hash']);
+					$blob->SetPath($this->params['file']);
+
 					$mime = $blob->FileMime();
+				}
 
 				if ($mime)
 					$headers[] = "Content-type: " . $mime;

comments