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

Re: [PATCH] gitweb: Show project's git URL on summary page

From
DRDavid Rientjes <rientjes@google.com>
Date
Aug 15, 2006, 18:43 UTC
Message-ID
<Pine.LNX.4.63.0608151139280.29668@chino.corp.google.com>
In-Reply-To
<200608152003.05693.jnareb@gmail.com>
On Tue, 15 Aug 2006, Jakub Narebski wrote:
Show 37 quoted lines
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index ab28caa..6dcf6a2 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -51,6 +51,10 @@ our $logo = "++GITWEB_LOGO++";
>  # source of projects list
>  our $projects_list = "++GITWEB_LIST++";
>  
> +# list of git base URLs used for URL to where fetch project from,
> +# i.e. full URL is "$git_base_url/$project"
> +our @git_base_url_list = ("++GIT_BASE_URL++");
> +
>  # default blob_plain mimetype and default charset for text/plain blob
>  our $default_blob_plain_mimetype = 'text/plain';
>  our $default_text_plain_charset  = undef;
> @@ -1665,8 +1669,18 @@ sub git_summary {
>  	print "<table cellspacing=\"0\">\n" .
>  	      "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
>  	      "<tr><td>owner</td><td>$owner</td></tr>\n" .
> -	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
> -	      "</table>\n";
> +	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
> +	my $is_first_url = 1;
> +	foreach my $git_base_url (@git_base_url_list) {
> +		next unless $git_base_url; # skip empty/zerolength URLs
> +		print "<tr><td>";
> +		if ($is_first_url) {
> +			print "URL";
> +			$is_first_url = 0;
> +		}
> +		print "</td><td>$git_base_url/$project</td></tr>\n";
> +	}
> +	print "</table>\n";
>  
>  	open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash($project)
>  		or die_error(undef, "Open git-rev-list failed");
> 
Isn't it faster to do this (over 1.4.2):
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b5b89de..82b246d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -53,6 +53,7 @@ our $logo = "++GITWEB_LOGO++";
 
 # source of projects list
 our $projects_list = "++GITWEB_LIST++";
+our @git_base_url_list = ("++GIT_BASE_URL++");
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
@@ -1668,8 +1669,14 @@ sub git_summary {
 	print "<table cellspacing=\"0\">\n" .
 	      "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
 	      "<tr><td>owner</td><td>$owner</td></tr>\n" .
-	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
-	      "</table>\n";
+	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
+	my $url_tag = "URL";
+	foreach my $git_base_url (@git_base_url_list) {
+		next unless $git_base_url;
+		print "<tr><td>$url_tag</td><td>$git_base_url/$project</td></tr>\n";
+		$url_tag = "";
+	}
+	print "</table>\n";
 
 	open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash($project)
 		or die_error(undef, "Open git-rev-list failed");
--

All the series of prints in this script could also probably more elegantly be 
written in the form:

print <<"(END HTML)";
	<table cellspacing="0">
		...
	</table>
	<tr><td>last change</td><td>$cd{'rfc2822'}</td><tr>
	...
(END HTML)

and then all the escape characters around quotes aren't needed.

		David
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 10 in “gitweb: Show project's git URL on summary page”
  1. gitweb: Show project's git URL on summary pageJakub Narebski, Aug 15, 2006
  2. David RientjesAug 15, 2006
  3. Jakub NarebskiAug 15, 2006
  4. gitweb: Show project's git URL on summary pageJakub Narebski, Aug 15, 2006
  5. David RientjesAug 15, 2006
  6. Aneesh Kumar K.VAug 16, 2006
  7. Jakub NarebskiAug 16, 2006
  8. 2/2 gitweb: Add support for per project git URLsJakub Narebski, Aug 16, 2006
  9. Junio C HamanoAug 16, 2006
  10. Jakub NarebskiAug 17, 2006

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.