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

Re: [PATCH] gitweb: prefer git_get_project_owner() over get_file_owner()

From
LTLuben Tuikov <ltuikov@yahoo.com>
Date
Jul 7, 2007, 19:05 UTC
Message-ID
<260120.95921.qm@web31806.mail.mud.yahoo.com>
In-Reply-To
<7vzm2ckb3h.fsf@assigned-by-dhcp.cox.net>
--- Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> Miklos Vajna <vmiklos@frugalware.org> writes:
> 
> > This way if $projects_list exists, it'll be used, otherwise get_file_owner()
> > will be used as before.
> >
> > Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> 
> The patch looks good to me.
> 
> HOWEVER.
> 
> It strikes me that repeated call to git_get_project_owner()
> would be way too inefficient.  Not caller's fault.
> 
> How about doing something like this on top of your patch?
Yes, this sounds sensible. ACK.
    Luben
Show 57 quoted lines
> 
>  gitweb/gitweb.perl |   28 ++++++++++++++++++++--------
>  1 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index dbfb044..f114585 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1465,12 +1465,12 @@ sub git_get_projects_list {
>  	return @list;
>  }
>  
> -sub git_get_project_owner {
> -	my $project = shift;
> -	my $owner;
> +our $gitweb_project_owner = undef;
> +sub git_get_project_list_from_file {
>  
> -	return undef unless $project;
> +	return if (defined $gitweb_project_owner);
>  
> +	$gitweb_project_owner = {};
>  	# read from file (url-encoded):
>  	# 'git%2Fgit.git Linus+Torvalds'
>  	# 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
> @@ -1482,13 +1482,25 @@ sub git_get_project_owner {
>  			my ($pr, $ow) = split ' ', $line;
>  			$pr = unescape($pr);
>  			$ow = unescape($ow);
> -			if ($pr eq $project) {
> -				$owner = to_utf8($ow);
> -				last;
> -			}
> +			$gitweb_project_owner->{$project} = to_utf8($ow);
>  		}
>  		close $fd;
>  	}
> +}
> +
> +sub git_get_project_owner {
> +	my $project = shift;
> +	my $owner;
> +
> +	return undef unless $project;
> +
> +	if (!defined $gitweb_project_owner) {
> +		git_get_project_list_from_file();
> +	}
> +
> +	if (exists $gitweb_project_owner->{$project}) {
> +		$owner = $gitweb_project_owner->{$project};
> +	}
>  	if (!defined $owner) {
>  		$owner = get_file_owner("$projectroot/$project");
>  	}
> 
> 
Previous: Junio C Hamano
Message 3 of 3 in “gitweb: prefer git_get_project_owner() over get_file_owner()”
  1. gitweb: prefer git_get_project_owner() over get_file_owner()Miklos Vajna, Jul 3, 2007
  2. Junio C HamanoJul 4, 2007
  3. Luben TuikovJul 7, 2007

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.