Readd blob HEAD link and ref lookup fixes
Readd blob HEAD link and ref lookup fixes

--- a/include/display.git_blob.php
+++ b/include/display.git_blob.php
@@ -18,13 +18,15 @@
 function git_blob($projectroot, $project, $hash, $file, $hashbase)
 {
 	global $gitphp_conf,$tpl;
+	$head = git_read_head($projectroot . $project);
 	if (!isset($hashbase))
-		$hashbase = git_read_head($projectroot . $project);
+		$hashbase = $head;
 	if (!isset($hash) && isset($file))
 		$hash = git_get_hash_by_path($projectroot . $project, $hashbase,$file,"blob");
 	$catout = git_cat_file($projectroot . $project, $hash);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("hashbase",$hashbase);
+	$tpl->assign("head", $head);
 	if ($co = git_read_commit($projectroot . $project, $hashbase)) {
 		$tpl->assign("fullnav",TRUE);
 		$refs = read_info_ref($projectroot . $project);
@@ -32,8 +34,13 @@
 		$tpl->assign("title",$co['title']);
 		if (isset($file))
 			$tpl->assign("file",$file);
-		if (isset($refs[$hashbase]))
-			$tpl->assign("hashbaseref",$refs[$hashbase]);
+		if ($hashbase == "HEAD") {
+			if (isset($refs[$head]))
+				$tpl->assign("hashbaseref",$refs[$head]);
+		} else {
+			if (isset($refs[$hashbase]))
+				$tpl->assign("hashbaseref",$refs[$hashbase]);
+		}
 	}
 	$paths = git_path_trees($projectroot . $project, $hashbase, $file);
 	$tpl->assign("paths",$paths);

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -13,7 +13,13 @@
    {if $fullnav}
      <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hashbase}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hashbase}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hashbase}">tree</a><br />
      {if $file}
-       <a href="{$SCRIPT_NAME}?p={$project}&a=blob_plain&h={$hash}&f={$file}">plain</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=blob&hb=HEAD&f={$file}">head</a><br />
+       <a href="{$SCRIPT_NAME}?p={$project}&a=blob_plain&h={$hash}&f={$file}">plain</a> | 
+       {if ($hashbase != "HEAD") && ($hashbase != $head)}
+         <a href="{$SCRIPT_NAME}?p={$project}&a=blob&hb=HEAD&f={$file}">HEAD</a>
+       {else}
+         HEAD
+       {/if}
+       <br />
      {else}
        <a href="{$SCRIPT_NAME}?p={$project}&a=blob_plain&h={$hash}">plain</a><br />
      {/if}

comments