Provide clean url endpoints for individual heads
Provide clean url endpoints for individual heads

--- a/include/router/Router.class.php
+++ b/include/router/Router.class.php
@@ -165,6 +165,14 @@
 			'action' => 'shortlog|log',
 			'hash' => '[^\?]+'
 		), array(), $projectroute);
+
+		// map heads to shortlog
+		$this->routes[] = new GitPHP_Route(':action/:hash', array(
+			'action' => 'heads',
+			'hash' => '[^\?]+'
+		), array(
+			'action' => 'shortlog'
+		), $projectroute);
 
 		// project-specific graphs
 		$this->routes[] = new GitPHP_Route(':action/:graphtype', array(
@@ -671,9 +679,7 @@
 	 */
 	private static function GetHash($value, $abbreviate = false)
 	{
-		if ($value instanceof GitPHP_Ref)
-			return $value->GetRefPath();
-		else if ($value instanceof GitPHP_GitObject)
+		if ($value instanceof GitPHP_GitObject)
 			return $value->GetHash($abbreviate);
 		else if (is_string($value))
 			return $value;

--- a/templates/headlist.tpl
+++ b/templates/headlist.tpl
@@ -15,7 +15,7 @@
        {assign var=headcommit value=$head->GetCommit()}
        <tr class="{cycle values="light,dark"}">
          <td><em>{agestring age=$headcommit->GetAge()}</em></td>
-         <td><a href="{geturl project=$project action=shortlog hash=$head}" class="list"><strong>{$head->GetName()}</strong></a></td>
+         <td><a href="{if $router->GetCleanUrl()}{geturl project=$project action=heads hash=$head->GetName()}{else}{geturl project=$project action=shortlog hash=$head}{/if}" class="list"><strong>{$head->GetName()}</strong></a></td>
          <td class="link"><a href="{geturl project=$project action=shortlog hash=$head}">{t}shortlog{/t}</a> | <a href="{geturl project=$project action=log hash=$head}">{t}log{/t}</a> | <a href="{geturl project=$project action=tree hashbase=$headcommit}">{t}tree{/t}</a></td>
        </tr>
    {/foreach}

comments