git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] gitweb: ref markers link to named shortlogs

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 22, 2008, 13:01 UTC
Message-ID
<200808221501.54908.jnareb@gmail.com>
In-Reply-To
<1219408777-13513-1-git-send-email-giuseppe.bilotta@gmail.com>
On Fri, 22 August 2008, Giuseppe Bilotta wrote:
Show 50 quoted lines
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index a0d9272..5cb332f 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1201,7 +1201,12 @@ sub format_ref_marker {
>  	my $markers = '';
>  
>  	if (defined $refs->{$id}) {
> -		foreach my $ref (@{$refs->{$id}}) {
> +		foreach my $aref (@{$refs->{$id}}) {
> +			# this code exploits the fact that non-lightweight tags are the
> +			# only indirect objects, and that they are the only objects for which
> +			# we want to use tag instead of shortlog as action
> +			my $ref = $aref->[0];
> +			my $indirect = $aref->[1];
>  			my ($type, $name) = qw();
>  			# e.g. tags/v2.6.11 or heads/next
>  			if ($ref =~ m!^(.*?)s?/(.*)$!) {
> @@ -1212,8 +1217,14 @@ sub format_ref_marker {
>  				$name = $ref;
>  			}
>  
> -			$markers .= " <span class=\"$type\" title=\"$ref\">" .
> -			            esc_html($name) . "</span>";
> +			my $class = $type;
> +			if ($indirect) {
> +				$class .= " indirect";
> +			}
> +
> +			$markers .= " <span class=\"$class\" title=\"$ref\">" .
> +				$cgi->a({-href => href(action=>( $indirect ? "tag" : "shortlog"), hash=>$ref)}, $name) .
> +				"</span>";
>  		}
>  	}
>  
> @@ -2035,11 +2046,11 @@ sub git_get_references {
>  
>  	while (my $line = <$fd>) {
>  		chomp $line;
> -		if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)!) {
> +		if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)(\^\{\})?$!) {
>  			if (defined $refs{$1}) {
> -				push @{$refs{$1}}, $2;
> +				push @{$refs{$1}}, [$2, $3];
>  			} else {
> -				$refs{$1} = [ $2 ];
> +				$refs{$1} = [ [$2, $3] ];
>  			}
>  		}
>  	}

Seems overly complicated. How about something like this, instead? It simply moves stripping ^{} from refs to format_ref_marker(), and uses "tags/v1.5.0^{}" instead of [ "tags/v1.5.0", 1 ].

NOT TESTED!
 gitweb/gitweb.perl |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4c104d2..261307f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1096,18 +1096,24 @@ sub format_ref_marker {
 
 	if (defined $refs->{$id}) {
 		foreach my $ref (@{$refs->{$id}}) {
-			my ($type, $name) = qw();
+			my ($class, $name, $indirect) = qw();
+			# strip ^{} suffix from indirect refs, like tags/v2.6.11^{}
+			$indirect = ($ref =~ s/\^{}$//);
 			# e.g. tags/v2.6.11 or heads/next
 			if ($ref =~ m!^(.*?)s?/(.*)$!) {
-				$type = $1;
-				$name = $2;
+				$class = $1;
+				$name  = $2;
 			} else {
-				$type = "ref";
-				$name = $ref;
+				$class = "ref";
+				$name  = $ref;
 			}
+			$class .= " indirect" if $indirect;
 
-			$markers .= " <span class=\"$type\" title=\"$ref\">" .
-			            esc_html($name) . "</span>";
+			$markers .= " <span class=\"$class\" title=\"$ref\">" .
+			            esc_html($name) .
+			            $cgi->a({-href => href(action=>($indirect ? "tag" : "shortlog"),
+			                                   hash=>$ref)}, $name) .
+			            "</span>";
 		}
 	}
 
@@ -1959,7 +1965,7 @@ sub git_get_references {
 
 	while (my $line = <$fd>) {
 		chomp $line;
-		if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)!) {
+		if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?.+)$!) {
 			if (defined $refs{$1}) {
 				push @{$refs{$1}}, $2;
 			} else {
-- 
Jakub Narebski
Poland
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 21 of 33 in “gitweb: ref markers link to named shortlogs”
  1. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 21, 2008
  2. Jakub NarebskiAug 21, 2008
  3. Giuseppe BilottaAug 22, 2008
  4. Jakub NarebskiAug 22, 2008
  5. [PATCHv3] gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 22, 2008
  6. Lea WiemannAug 24, 2008
  7. Giuseppe BilottaAug 24, 2008
  8. Jakub NarebskiAug 24, 2008
  9. Giuseppe BilottaAug 25, 2008
  10. Jakub NarebskiAug 26, 2008
  11. Giuseppe BilottaAug 26, 2008
  12. Jakub NarebskiAug 26, 2008
  13. Giuseppe BilottaAug 26, 2008
  14. Giuseppe BilottaAug 27, 2008
  15. Lea WiemannAug 28, 2008
  16. Giuseppe BilottaAug 28, 2008
  17. Jakub NarebskiAug 28, 2008
  18. Jakub NarebskiAug 22, 2008
  19. Giuseppe BilottaAug 22, 2008
  20. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 22, 2008
  21. Jakub NarebskiAug 22, 2008
  22. Giuseppe BilottaAug 22, 2008
  23. Jakub NarebskiAug 22, 2008
  24. Giuseppe BilottaAug 22, 2008
  25. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 22, 2008
  26. Jakub NarebskiAug 24, 2008
  27. Miklos VajnaAug 25, 2008
  28. Jakub NarebskiAug 25, 2008
  29. Junio C HamanoAug 25, 2008
  30. Jakub NarebskiAug 25, 2008
  31. Junio C HamanoAug 25, 2008
  32. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 26, 2008
  33. gitweb: ref markers link to named shortlogsGiuseppe Bilotta, Aug 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.