Subject: [PATCH 5/5] gitweb: Change appereance of marker of refs pointing to given object

From: Jakub Narebski <[email-masked]>
Date: Sat, 5 Aug 2006 00:43:18 +0200

Change default value of $type in git_read_info_refs to correctly show
full name of ref (and not only last part) if $type was not set.

Refs are now in separate span elements.  Class was changed from "tag"
to "ref", as ref can be head, not only tag.  Currently there is no way
to distinguish between tags and heads.

Signed-off-by: Jakub Narebski <[email-masked]>
---
 gitweb/gitweb.css  |    2 +-
 gitweb/gitweb.perl |   12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 460e728..921b339 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -317,7 +317,7 @@ a.rss_logo:hover {
 	background-color: #ee5500;
 }
 
-span.tag {
+span.ref {
 	padding: 0px 4px;
 	font-size: 10px;
 	font-weight: normal;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9e4822b..e983452 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -350,9 +350,13 @@ sub format_mark_referencing {
 	my ($refs, $id) = @_;
 
 	if (defined $refs->{$id}) {
-		return ' <span class="tag">' . esc_html($refs->{$id}) . '</span>';
+		my $markers = '';
+		foreach my $ref (split /:/, $refs->{$id}) {
+			$markers .= ' <span class="ref">' . esc_html($ref) . '</span>';
+		}
+		return $markers;
 	} else {
-		return "";
+		return '';
 	}
 }
 
@@ -496,7 +500,7 @@ sub git_read_projects {
 }
 
 sub git_read_info_refs {
-	my $type = shift || "";
+	my $type = shift || "(?:heads|tags)";
 	my %refs;
 	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c	refs/tags/v2.6.11
 	# c39ae07f393806ccf406ef966e9a15afc43cc36a	refs/tags/v2.6.11^{}
@@ -507,7 +511,7 @@ sub git_read_info_refs {
 		# e.g. from 'refs/heads/jn/gitweb' it would leave only 'gitweb'
 		if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\^]+)/) {
 			if (defined $refs{$1}) {
-				$refs{$1} .= " / $2";
+				$refs{$1} .= ':' . $2;
 			} else {
 				$refs{$1} = $2;
 			}
-- 
1.4.1.1