From cdd4037d7053647c97139ac77d4319124f17d47e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Jun 2006 18:54:32 -0700 Subject: [PATCH 1/3] gitweb: optimize per-file history generation The rev-list command that is recent enough can filter commits based on paths they touch, so use it instead of generating the full list and limiting it by passing it with diff-tree --stdin. [jc: The patch originally came from Luben Tuikov but the it was corrupt, but it was short enough to be applied by hand. I added the --full-history to make the output compatible with the original while doing so.] Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 035e76d0a3..1007742153 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -2295,16 +2295,13 @@ sub git_history { "\n"; print "
/" . esc_html($file_name) . "
\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -- \'$file_name\'"; - my $commit; + open my $fd, "-|", + "$gitbin/git-rev-list --full-history $hash -- \'$file_name\'"; print "\n"; my $alternate = 0; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40})/){ - $commit = $1; - next; - } - if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) { + my $commit = $1; my %co = git_read_commit($commit); if (!%co) { next; @@ -2336,7 +2333,6 @@ sub git_history { } print "\n" . "\n"; - undef $commit; } } print "
\n"; From 85b7cfb1036b4218d13cbc215729ad083a61a0ea Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Fri, 30 Jun 2006 19:11:18 -0700 Subject: [PATCH 2/3] gitweb: Enable tree (directory) history display This patch allows history display of whole trees/directories a la "git-rev-list HEAD -- ". I find this useful especially when a project lives in its own subdirectory, as opposed to being all of the GIT repository (i.e. when a sub-project is merged into a super-project). Signed-off-by: Luben Tuikov Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 1 + 1 file changed, 1 insertion(+) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 1007742153..efffc8d078 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -1676,6 +1676,7 @@ sub git_tree { "\n" . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . "\n"; } print "\n"; From 4a87b43e374626a95c14362f21c9ca1023638a2c Mon Sep 17 00:00:00 2001 From: Dennis Stosberg Date: Wed, 21 Jun 2006 15:07:08 +0200 Subject: [PATCH 3/3] gitweb: Declare global variables with "our" Variables declared with "my" in the file scope cannot be accessed from subroutines with mod_perl. Signed-off-by: Junio C Hamano --- gitweb/gitweb.cgi | 55 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index efffc8d078..3e2790c5d6 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -16,21 +16,21 @@ use Encode; use Fcntl ':mode'; binmode STDOUT, ':utf8'; -my $cgi = new CGI; -my $version = "267"; -my $my_url = $cgi->url(); -my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +our $cgi = new CGI; +our $version = "267"; +our $my_url = $cgi->url(); +our $my_uri = $cgi->url(-absolute => 1); +our $rss_link = ""; # location of the git-core binaries -my $gitbin = "/usr/bin"; +our $gitbin = "/usr/bin"; # absolute fs-path which will be prepended to the project path -#my $projectroot = "/pub/scm"; -my $projectroot = "/home/kay/public_html/pub/scm"; +#our $projectroot = "/pub/scm"; +our $projectroot = "/home/kay/public_html/pub/scm"; # version of the git-core binaries -my $git_version = qx($gitbin/git --version); +our $git_version = qx($gitbin/git --version); if ($git_version =~ m/git version (.*)$/) { $git_version = $1; } else { @@ -38,32 +38,31 @@ if ($git_version =~ m/git version (.*)$/) { } # location for temporary files needed for diffs -my $git_temp = "/tmp/gitweb"; +our $git_temp = "/tmp/gitweb"; # target of the home link on top of all pages -my $home_link = $my_uri; +our $home_link = $my_uri; # html text to include at home page -my $home_text = "indextext.html"; +our $home_text = "indextext.html"; # URI of default stylesheet -my $stylesheet = "gitweb.css"; +our $stylesheet = "gitweb.css"; # source of projects list -#my $projects_list = $projectroot; -my $projects_list = "index/index.aux"; +#our $projects_list = $projectroot; +our $projects_list = "index/index.aux"; # default blob_plain mimetype and default charset for text/plain blob -my $default_blob_plain_mimetype = 'text/plain'; -my $default_text_plain_charset = undef; +our $default_blob_plain_mimetype = 'text/plain'; +our $default_text_plain_charset = undef; # file to use for guessing MIME types before trying /etc/mime.types # (relative to the current git repository) -my $mimetypes_file = undef; - +our $mimetypes_file = undef; # input validation and dispatch -my $action = $cgi->param('a'); +our $action = $cgi->param('a'); if (defined $action) { if ($action =~ m/[^0-9a-zA-Z\.\-_]/) { undef $action; @@ -78,7 +77,7 @@ if (defined $action) { } } -my $order = $cgi->param('o'); +our $order = $cgi->param('o'); if (defined $order) { if ($order =~ m/[^0-9a-zA-Z_]/) { undef $order; @@ -86,7 +85,7 @@ if (defined $order) { } } -my $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); +our $project = ($cgi->param('p') || $ENV{'PATH_INFO'}); if (defined $project) { $project =~ s|^/||; $project =~ s|/$||; $project = validate_input($project); @@ -109,7 +108,7 @@ if (defined $project) { exit; } -my $file_name = $cgi->param('f'); +our $file_name = $cgi->param('f'); if (defined $file_name) { $file_name = validate_input($file_name); if (!defined($file_name)) { @@ -117,7 +116,7 @@ if (defined $file_name) { } } -my $hash = $cgi->param('h'); +our $hash = $cgi->param('h'); if (defined $hash) { $hash = validate_input($hash); if (!defined($hash)) { @@ -125,7 +124,7 @@ if (defined $hash) { } } -my $hash_parent = $cgi->param('hp'); +our $hash_parent = $cgi->param('hp'); if (defined $hash_parent) { $hash_parent = validate_input($hash_parent); if (!defined($hash_parent)) { @@ -133,7 +132,7 @@ if (defined $hash_parent) { } } -my $hash_base = $cgi->param('hb'); +our $hash_base = $cgi->param('hb'); if (defined $hash_base) { $hash_base = validate_input($hash_base); if (!defined($hash_base)) { @@ -141,7 +140,7 @@ if (defined $hash_base) { } } -my $page = $cgi->param('pg'); +our $page = $cgi->param('pg'); if (defined $page) { if ($page =~ m/[^0-9]$/) { undef $page; @@ -149,7 +148,7 @@ if (defined $page) { } } -my $searchtext = $cgi->param('s'); +our $searchtext = $cgi->param('s'); if (defined $searchtext) { if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { undef $searchtext;