From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 2/3] gitweb: Refactor common parts of 'log' and 'shortlog' views
Date: Fri, 13 Nov 2009 02:02:13 +0100 [thread overview]
Message-ID: <1258074134-27011-3-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <1258074134-27011-1-git-send-email-jnareb@gmail.com>
Put the common parts of git_log and git_shortlog into git_log_generic
subroutine: git_log and git_shortlog are now thin wrappers calling
git_log_generic with appropriate arguments.
The unification of code responsible for 'log' and 'shorlog' actions
lead to the following changes in gitweb output
* 'tree' link in page_nav now uses $hash parameter, as was the case
for 'shortlog' but not for 'log'
* 'log' view now respect $hash_parent limiting, like 'shortlog' did
* 'log' view doesn't have special case for empty list anymore, and it
always uses page_header linking to summary view, like 'shortlog'
did.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 72 ++++++++++++++-------------------------------------
1 files changed, 20 insertions(+), 52 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 68dbd9e..14661cc 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -5336,7 +5336,9 @@ sub git_snapshot {
close $fd;
}
-sub git_log {
+sub git_log_generic {
+ my ($fmt_name, $body_subr) = @_;
+
my $head = git_get_head_hash($project);
if (!defined $hash) {
$hash = $head;
@@ -5346,16 +5348,21 @@ sub git_log {
}
my $refs = git_get_references();
- my @commitlist = parse_commits($hash, 101, (100 * $page));
+ my $commit_hash = $hash;
+ if (defined $hash_parent) {
+ $commit_hash = "$hash_parent..$hash";
+ }
+ my @commitlist = parse_commits($commit_hash, 101, (100 * $page));
- my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
- my $next_link;
+ my $paging_nav = format_paging_nav($fmt_name, $hash, $head,
+ $page, $#commitlist >= 100);
+ my $next_link = '';
if ($#commitlist >= 100) {
$next_link =
$cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
}
- my ($patch_max) = gitweb_get_feature('patches');
+ my $patch_max = gitweb_get_feature('patches');
if ($patch_max) {
if ($patch_max < 0 || @commitlist <= $patch_max) {
$paging_nav .= " ⋅ " .
@@ -5365,20 +5372,18 @@ sub git_log {
}
git_header_html();
- git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
-
- if (!@commitlist) {
- my %co = parse_commit($hash);
-
- git_print_header_div('summary', $project);
- print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
- }
+ git_print_page_nav($fmt_name,'', $hash,$hash,$hash, $paging_nav);
+ git_print_header_div('summary', $project);
- git_log_body(\@commitlist, 0, 99, $refs, $next_link);
+ $body_subr->(\@commitlist, 0, 99, $refs, $next_link);
git_footer_html();
}
+sub git_log {
+ git_log_generic('log', \&git_log_body);
+}
+
sub git_commit {
$hash ||= $hash_base || "HEAD";
my %co = parse_commit($hash)
@@ -6242,44 +6247,7 @@ EOT
}
sub git_shortlog {
- my $head = git_get_head_hash($project);
- if (!defined $hash) {
- $hash = $head;
- }
- if (!defined $page) {
- $page = 0;
- }
- my $refs = git_get_references();
-
- my $commit_hash = $hash;
- if (defined $hash_parent) {
- $commit_hash = "$hash_parent..$hash";
- }
- my @commitlist = parse_commits($commit_hash, 101, (100 * $page));
-
- my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
- my $next_link = '';
- if ($#commitlist >= 100) {
- $next_link =
- $cgi->a({-href => href(-replay=>1, page=>$page+1),
- -accesskey => "n", -title => "Alt-n"}, "next");
- }
- my $patch_max = gitweb_check_feature('patches');
- if ($patch_max) {
- if ($patch_max < 0 || @commitlist <= $patch_max) {
- $paging_nav .= " ⋅ " .
- $cgi->a({-href => href(action=>"patches", -replay=>1)},
- "patches");
- }
- }
-
- git_header_html();
- git_print_page_nav('shortlog','', $hash,$hash,$hash, $paging_nav);
- git_print_header_div('summary', $project);
-
- git_shortlog_body(\@commitlist, 0, 99, $refs, $next_link);
-
- git_footer_html();
+ git_log_generic('shortlog', \&git_shortlog_body);
}
## ......................................................................
--
1.6.5
next prev parent reply other threads:[~2009-11-13 1:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 1:02 [RFC/PATCH 0/3] gitweb: Refactor common parts of log-like views Jakub Narebski
2009-11-13 1:02 ` [PATCH 1/3] gitweb: Refactor 'log' action generation, adding git_log_body() Jakub Narebski
2009-11-13 23:10 ` Nanako Shiraishi
2009-11-13 23:59 ` Jakub Narebski
2009-11-13 1:02 ` Jakub Narebski [this message]
2009-11-13 1:02 ` [PATCH 3/3] gitweb: Make 'history' view (re)use git_log_generic() Jakub Narebski
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=1258074134-27011-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).