~dupunkto/gitz

Awesome PHP-based Git frontend.

Support branch names in blob view

Commited on by Robin.

diff --git a/index.php b/index.php
index a7a78ec..450420b 100644
--- a/index.php
+++ b/index.php
@@ -94,7 +94,14 @@ switch(true) {
 
         case route("@/blob/{$alnum}(.*)$@"):
           $page ??= "blob";
-          $hash = $params[1];
+
+          if(\core\isCommitHash($params[1])) {
+            $hash = $params[1];
+          } else {
+            $branch = $params[1];
+            $hash = \core\getLatestCommits($repo, $branch, 1)[0]['hash'];
+          }
+
           $request_path = trim($params[2], "/");
           break;
       }