All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 2/7] gitweb: Paginate history output
Date: Wed,  6 Sep 2006 15:08:06 +0200	[thread overview]
Message-ID: <11575480912922-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <1157548091229-git-send-email-jnareb@gmail.com>

git_history output is now divided into pages, like git_shortlog,
git_tags and git_heads output. As whole git-rev-list output is now
read into array before writing anything, it allows for better
signaling of errors.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   61 +++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e95d16f..4c76032 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1936,12 +1936,15 @@ sub git_shortlog_body {
 
 sub git_history_body {
 	# Warning: assumes constant type (blob or tree) during history
-	my ($fd, $refs, $hash_base, $ftype, $extra) = @_;
+	my ($revlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;
+
+	$from = 0 unless defined $from;
+	$to = $#{$revlist} unless (defined $to && $to <= $#{$revlist});
 
 	print "<table class=\"history\" cellspacing=\"0\">\n";
 	my $alternate = 0;
-	while (my $line = <$fd>) {
-		if ($line !~ m/^([0-9a-fA-F]{40})/) {
+	for (my $i = $from; $i <= $to; $i++) {
+		if ($revlist->[$i] !~ m/^([0-9a-fA-F]{40})/) {
 			next;
 		}
 
@@ -3122,24 +3125,62 @@ sub git_history {
 	if (!%co) {
 		die_error(undef, "Unknown commit object");
 	}
+
 	my $refs = git_get_references();
-	git_header_html();
-	git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base);
-	git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
+	my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
+
 	if (!defined $hash && defined $file_name) {
 		$hash = git_get_hash_by_path($hash_base, $file_name);
 	}
 	if (defined $hash) {
 		$ftype = git_get_type($hash);
 	}
-	git_print_page_path($file_name, $ftype, $hash_base);
 
 	open my $fd, "-|",
-		git_cmd(), "rev-list", "--full-history", $hash_base, "--", $file_name;
+		git_cmd(), "rev-list", $limit, "--full-history", $hash_base, "--", $file_name
+			or die_error(undef, "Open git-rev-list-failed");
+	my @revlist = map { chomp; $_ } <$fd>;
+	close $fd
+		or die_error(undef, "Reading git-rev-list failed");
 
-	git_history_body($fd, $refs, $hash_base, $ftype);
+	my $paging_nav = '';
+	if ($page > 0) {
+		$paging_nav .=
+			$cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
+			                       file_name=>$file_name)},
+			        "first");
+		$paging_nav .= " &sdot; " .
+			$cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
+			                       file_name=>$file_name, page=>$page-1),
+			         -accesskey => "p", -title => "Alt-p"}, "prev");
+	} else {
+		$paging_nav .= "first";
+		$paging_nav .= " &sdot; prev";
+	}
+	if ($#revlist >= (100 * ($page+1)-1)) {
+		$paging_nav .= " &sdot; " .
+			$cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
+			                       file_name=>$file_name, page=>$page+1),
+			         -accesskey => "n", -title => "Alt-n"}, "next");
+	} else {
+		$paging_nav .= " &sdot; next";
+	}
+	my $next_link = '';
+	if ($#revlist >= (100 * ($page+1)-1)) {
+		$next_link =
+			$cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base,
+			                       file_name=>$file_name, page=>$page+1),
+			         -title => "Alt-n"}, "next");
+	}
+
+	git_header_html();
+	git_print_page_nav('history','', $hash_base,$co{'tree'},$hash_base, $paging_nav);
+	git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
+	git_print_page_path($file_name, $ftype, $hash_base);
+
+	git_history_body(\@revlist, ($page * 100), $#revlist,
+	                 $refs, $hash_base, $ftype, $next_link);
 
-	close $fd;
 	git_footer_html();
 }
 
-- 
1.4.2

  reply	other threads:[~2006-09-06 13:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06 13:04 [PATCH 0/7] gitweb: Trying to improve history view speed Jakub Narebski
2006-09-06 13:08 ` [PATCH 1/7] gitweb: Make pickaxe search a feature Jakub Narebski
2006-09-06 13:08   ` Jakub Narebski [this message]
2006-09-06 13:08     ` [PATCH 3/7] gitweb: Use @hist_opts as git-rev-list parameters in git_history Jakub Narebski
2006-09-06 13:08       ` [PATCH 4/7] gitweb: Add parse_rev_list for later use Jakub Narebski
2006-09-06 13:08         ` [PATCH 5/7] gitweb: Use parse_rev_list in git_shortlog and git_history Jakub Narebski
2006-09-06 13:08           ` [PATCH 6/7] gitweb: Assume parsed revision list in git_shortlog_body and git_history_body Jakub Narebski
2006-09-06 13:08             ` [PATCH 7/7] gitweb: Set page to 0 if it is not defined, in git_history Jakub Narebski
2006-09-06 20:56               ` [PATCH 8/8] gitweb: Remove --parents from call to git-rev-list in parse_rev_list Jakub Narebski
2006-09-06 21:08                 ` Linus Torvalds
2006-09-06 21:18                   ` Jakub Narebski
2006-09-06 21:51                     ` Junio C Hamano
2006-09-06 21:53                 ` Jakub Narebski
2006-09-07  8:39                   ` Jakub Narebski
2006-09-07  0:37   ` [PATCH 1/7] gitweb: Make pickaxe search a feature Junio C Hamano
2006-09-07  8:34     ` Jakub Narebski
2006-09-07  9:02       ` Junio C Hamano
2006-09-07  9:07         ` Jakub Narebski
2006-09-06 15:57 ` [PATCH 0/7] gitweb: Trying to improve history view speed Linus Torvalds
2006-09-06 17:06   ` Jakub Narebski
2006-09-06 18:30     ` Linus Torvalds
2006-09-06 18:48       ` Jakub Narebski
2006-09-06 19:04         ` Linus Torvalds
2006-09-06 22:01 ` Junio C Hamano
2006-09-09  8:42 ` Jakub Narebski
2006-09-09  9:10   ` Junio C Hamano
2006-09-09  9:24     ` Jakub Narebski
2006-09-09  9:54       ` Junio C Hamano

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=11575480912922-git-send-email-jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /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.