All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v4] gitweb: ref markers link to named shortlogs
Date: Fri, 22 Aug 2008 15:01:54 +0200	[thread overview]
Message-ID: <200808221501.54908.jnareb@gmail.com> (raw)
In-Reply-To: <1219408777-13513-1-git-send-email-giuseppe.bilotta@gmail.com>

On Fri, 22 August 2008, Giuseppe Bilotta wrote:

> 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

  reply	other threads:[~2008-08-22 13:03 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 18:04 [PATCH] gitweb: ref markers link to named shortlogs Giuseppe Bilotta
2008-08-21 21:32 ` Jakub Narebski
2008-08-22  7:21   ` Giuseppe Bilotta
2008-08-22  8:49     ` Jakub Narebski
     [not found]       ` <cb7bb73a0808220231w37d2341eic56cabb595399f68@mail.gmail.com>
2008-08-22 10:56         ` Jakub Narebski
2008-08-22 12:34           ` Giuseppe Bilotta
2008-08-22 12:39           ` [PATCH v4] " Giuseppe Bilotta
2008-08-22 13:01             ` Jakub Narebski [this message]
2008-08-22 13:20               ` Giuseppe Bilotta
2008-08-22 13:42                 ` Jakub Narebski
2008-08-22 14:03                   ` Giuseppe Bilotta
2008-08-22 13:29               ` [PATCH v5] " Giuseppe Bilotta
2008-08-24 23:53                 ` Jakub Narebski
2008-08-25  2:05                   ` Miklos Vajna
2008-08-25  2:44                     ` Jakub Narebski
2008-08-25  4:11                       ` Junio C Hamano
2008-08-25 18:42                         ` Jakub Narebski
2008-08-25 19:48                           ` Junio C Hamano
2008-08-26 12:16                           ` [PATCH v6] " Giuseppe Bilotta
2008-08-26 13:09                           ` [PATCH v7] " Giuseppe Bilotta
2008-08-22  8:03   ` [PATCHv3] " Giuseppe Bilotta
2008-08-24 19:30 ` [PATCH] " Lea Wiemann
2008-08-24 19:41   ` Giuseppe Bilotta
2008-08-24 20:37   ` Jakub Narebski
2008-08-25 23:28     ` Giuseppe Bilotta
2008-08-26  8:15       ` Jakub Narebski
2008-08-26 10:58         ` Giuseppe Bilotta
2008-08-26 11:49           ` Jakub Narebski
2008-08-26 12:29             ` Giuseppe Bilotta
2008-08-27 18:36             ` Giuseppe Bilotta
2008-08-28  1:43             ` Lea Wiemann
2008-08-28  6:26               ` Giuseppe Bilotta
2008-08-28  6:48               ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200808221501.54908.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=giuseppe.bilotta@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.