* [PATCH] gitweb: New feature last_modified_ref.
@ 2006-12-29 18:58 Robert Fitzsimons
2006-12-29 19:12 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Robert Fitzsimons @ 2006-12-29 18:58 UTC (permalink / raw)
To: Git Mailing List; +Cc: Jakub Narebski, Martin Langhoff
Added a new feature which allows the gitweb administrator to set a
symbolic ref name that will be used to work out the Last Change value
for the project_list action. This was suggested by Jakub Narebski in
<200612291140.46909.jnareb@gmail.com>.
Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
---
gitweb/gitweb.perl | 52 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d845e91..9fb5208 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -185,6 +185,21 @@ our %feature = (
'forks' => {
'override' => 0,
'default' => [0]},
+
+ # Set a symbolic ref name that will be used to working out the Last
+ # Change value for the project_list action. If the ref name does not
+ # exist for a project or the ref name is undefined, the code will fall
+ # back on doing a 'for-each-ref refs/heads'.
+ #
+ # To enable system wide have in $GITWEB_CONFIG
+ # $feature{'last_activity_ref'}{'default'} = ['HEAD'];
+ # or
+ # $feature{'last_activity_ref'}{'default'} = ['refs/heads/master'];
+ # etc.
+ # Project specific override is not supported.
+ 'last_activity_ref' => {
+ 'override' => 0,
+ 'default' => [undef]},
);
sub gitweb_check_feature {
@@ -1147,17 +1162,35 @@ sub git_get_project_owner {
}
sub git_get_last_activity {
- my ($path) = @_;
+ my ($path, $ref) = @_;
my $fd;
+ my $most_recent = undef;
$git_dir = "$projectroot/$path";
- open($fd, "-|", git_cmd(), 'for-each-ref',
- '--format=%(committer)',
- '--sort=-committerdate',
- '--count=1',
- 'refs/heads') or return;
- my $most_recent = <$fd>;
- close $fd or return;
+
+ if (defined $ref) {
+ open($fd, "-|", git_cmd(), "cat-file",
+ "commit",
+ $ref) or return;
+ while (my $line = <$fd>) {
+ last if $line eq "\n";
+ if ($line =~ m/^committer /) {
+ $most_recent = $line;
+ last;
+ }
+ }
+ close $fd;
+ }
+ if (!defined $most_recent) {
+ open($fd, "-|", git_cmd(), 'for-each-ref',
+ '--format=%(committer)',
+ '--sort=-committerdate',
+ '--count=1',
+ 'refs/heads') or return;
+ $most_recent = <$fd>;
+ close $fd or return;
+ }
+
if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
my $timestamp = $1;
my $age = time - $timestamp;
@@ -2561,10 +2594,11 @@ sub git_project_list_body {
my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
my ($check_forks) = gitweb_check_feature('forks');
+ my ($last_activity_ref) = gitweb_check_feature('last_activity_ref');
my @projects;
foreach my $pr (@$projlist) {
- my (@aa) = git_get_last_activity($pr->{'path'});
+ my (@aa) = git_get_last_activity($pr->{'path'}, $last_activity_ref);
unless (@aa) {
next;
}
--
1.5.0.rc0.g5b5f
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: New feature last_modified_ref.
2006-12-29 18:58 [PATCH] gitweb: New feature last_modified_ref Robert Fitzsimons
@ 2006-12-29 19:12 ` Junio C Hamano
2006-12-30 0:12 ` Robert Fitzsimons
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-12-29 19:12 UTC (permalink / raw)
To: Robert Fitzsimons; +Cc: Jakub Narebski, Martin Langhoff, git
I somehow suspect this is solving the problem with a wrong
tradeoff.
This change only affects the project list page, which I think is
simpler to deal with more aggressive caching (say, no more than
once every 10 minutes even if some project pushed a new head in
the meantime).
Not a firm refusal, but something to think about.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: New feature last_modified_ref.
2006-12-29 19:12 ` Junio C Hamano
@ 2006-12-30 0:12 ` Robert Fitzsimons
0 siblings, 0 replies; 3+ messages in thread
From: Robert Fitzsimons @ 2006-12-30 0:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Robert Fitzsimons, Jakub Narebski, Martin Langhoff, git
> I somehow suspect this is solving the problem with a wrong
> tradeoff.
I think the main problem is that we are trying to fix possible
performance problems with the latest version, just because they might
cause a major problem on kernel.org.
At this point I think we should get the latest version loaded and see
what the real problems are.
Robert
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-12-30 0:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-29 18:58 [PATCH] gitweb: New feature last_modified_ref Robert Fitzsimons
2006-12-29 19:12 ` Junio C Hamano
2006-12-30 0:12 ` Robert Fitzsimons
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).