From: Kay Sievers Date: Sun, 7 Aug 2005 18:26:49 +0000 (+0200) Subject: v206 X-Git-Tag: v1.4.0~1^2~79 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ea4a6df4089f6cfba0e6c6c50290ed18033f641b;p=git.git v206 --- diff --git a/gitweb.cgi b/gitweb.cgi index 408d9d1e6..f096f40d9 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "205"; +my $version = "206"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -109,11 +109,11 @@ if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) { die_error(undef, "Invalid parent hash parameter."); } -my $time_back = $cgi->param('t'); -if (defined $time_back) { - if ($time_back =~ m/^[^0-9]+$/) { - undef $time_back; - die_error(undef, "Invalid time parameter."); +my $page = $cgi->param('pg'); +if (defined $page) { + if ($page =~ m/^[^0-9]+$/) { + undef $page; + die_error(undef, "Invalid page parameter."); } } @@ -1232,17 +1232,9 @@ sub git_log { if (!defined $hash) { $hash = $head; } - my $limit_option = ""; - if (!defined $time_back) { - $limit_option = "--max-count=100"; - } elsif ($time_back > 0) { - my $date = time - $time_back*24*60*60; - $limit_option = "--max-age=$date"; + if (!defined $page) { + $page = 0; } - open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" or die_error(undef, "Open failed."); - my (@revlist) = map { chomp; $_ } <$fd>; - close $fd or die_error(undef, "Reading rev-list failed."); - git_header_html(); print "
\n"; print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . @@ -1251,15 +1243,27 @@ sub git_log { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "
\n"; - if ($hash ne $head) { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD") . " ⋅ "; - } - print $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "100") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=1;h=$hash"}, "day") . - " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=log;t=7;h=$hash"}, "week") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=31;h=$hash"}, "month") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=365;h=$hash"}, "year") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0;h=$hash"}, "all"); + + my $limit = sprintf("--max-count=%i", (100 * ($page+1))); + open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + + if ($hash ne $head || $page) { + print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + } else { + print "HEAD"; + } + if ($page > 0) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p"}, "prev"); + } else { + print " ⋅ prev"; + } + if ($#revlist >= (100 * ($page+1)-1)) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n"}, "next"); + } else { + print " ⋅ next"; + } print "
\n" . "
\n"; if (!@revlist) { @@ -1421,7 +1425,7 @@ sub git_commit { my $from_id = $3; my $to_id = $4; my $status = $5; - my $percentage = int $6; + my $similarity = $6; my $file = $7; #print "$line ($status)
\n"; if ($alternate) { @@ -1488,7 +1492,7 @@ sub git_commit { $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML($to_file)) . "\n" . "[moved from " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML($from_file)) . - " with $percentage% similarity$mode_chng]\n" . + " with " . (int $similarity) . "% similarity$mode_chng]\n" . "" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob"); if ($to_id ne $from_id) { @@ -1845,7 +1849,9 @@ sub git_shortlog { if (!defined $hash) { $hash = $head; } - + if (!defined $page) { + $page = 0; + } git_header_html(); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . @@ -1854,38 +1860,36 @@ sub git_shortlog { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "
\n"; - if ($hash ne $head) { - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD") . " ⋅ "; - } - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "100") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=1;h=$hash"}, "day") . - " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=7;h=$hash"}, "week") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=31;h=$hash"}, "month") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=365;h=$hash"}, "year") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=0;h=$hash"}, "all") . - "
\n" . - "
\n"; - my $limit = ""; - if (defined $time_back) { - if ($time_back) { - $limit = sprintf(" --max-age=%i", time - 60*60*24*$time_back); - } - } else { - $limit = " --max-count=100"; - } + + my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; + + if ($hash ne $head || $page) { + print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + } else { + print "HEAD"; + } + if ($page > 0) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p"}, "prev"); + } else { + print " ⋅ prev"; + } + if ($#revlist >= (100 * ($page+1)-1)) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n"}, "next"); + } else { + print " ⋅ next"; + } + print "
\n" . + "\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . "
\n"; print "\n"; - if (!@revlist) { - my %co = git_read_commit($hash); - print "
Last change $co{'age_string'}.

\n"; - } my $alternate = 0; - foreach my $commit (@revlist) { + for (my $i = ($page * 100); $i <= $#revlist; $i++) { + my $commit = $revlist[$i]; my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); if ($alternate) {