{"thread":{"id":"6152","subject":"[PATCH] gitweb: New feature last_modified_ref.","startedAt":"2006-12-29T18:58:05Z","lastAt":"2006-12-30T00:12:18Z","messageCount":3,"participants":["Robert Fitzsimons","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"30484","messageId":"20061229185805.GF6558@localhost","threadId":"6152","inReplyTo":null,"subject":"[PATCH] gitweb: New feature last_modified_ref.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-29T18:58:05Z","receivedAt":"2006-12-29T18:58:05Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"Added a new feature which allows the gitweb administrator to set a\nsymbolic ref name that will be used to work out the Last Change value\nfor the project_list action.  This was suggested by Jakub Narebski in\n<200612291140.46909.jnareb@gmail.com>.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   52 +++++++++++++++++++++++++++++++++++++++++++---------\n 1 files changed, 43 insertions(+), 9 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d845e91..9fb5208 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -185,6 +185,21 @@ our %feature = (\n \t'forks' => {\n \t\t'override' => 0,\n \t\t'default' => [0]},\n+\n+\t# Set a symbolic ref name that will be used to working out the Last\n+\t# Change value for the project_list action.  If the ref name does not\n+\t# exist for a project or the ref name is undefined, the code will fall\n+\t# back on doing a 'for-each-ref refs/heads'.\n+\t#\n+\t# To enable system wide have in $GITWEB_CONFIG\n+\t# $feature{'last_activity_ref'}{'default'} = ['HEAD'];\n+\t# or\n+\t# $feature{'last_activity_ref'}{'default'} = ['refs/heads/master'];\n+\t# etc.\n+\t# Project specific override is not supported.\n+\t'last_activity_ref' => {\n+\t\t'override' => 0,\n+\t\t'default' => [undef]},\n );\n \n sub gitweb_check_feature {\n@@ -1147,17 +1162,35 @@ sub git_get_project_owner {\n }\n \n sub git_get_last_activity {\n-\tmy ($path) = @_;\n+\tmy ($path, $ref) = @_;\n \tmy $fd;\n+\tmy $most_recent = undef;\n \n \t$git_dir = \"$projectroot/$path\";\n-\topen($fd, \"-|\", git_cmd(), 'for-each-ref',\n-\t     '--format=%(committer)',\n-\t     '--sort=-committerdate',\n-\t     '--count=1',\n-\t     'refs/heads') or return;\n-\tmy $most_recent = <$fd>;\n-\tclose $fd or return;\n+\n+\tif (defined $ref) {\n+\t\topen($fd, \"-|\", git_cmd(), \"cat-file\",\n+\t\t     \"commit\",\n+\t\t     $ref) or return;\n+\t\twhile (my $line = <$fd>) {\n+\t\t\tlast if $line eq \"\\n\";\n+\t\t\tif ($line =~ m/^committer /) {\n+\t\t\t\t$most_recent = $line;\n+\t\t\t\tlast;\n+\t\t\t}\n+\t\t}\n+\t\tclose $fd;\n+\t}\n+\tif (!defined $most_recent) {\n+\t\topen($fd, \"-|\", git_cmd(), 'for-each-ref',\n+\t\t     '--format=%(committer)',\n+\t\t     '--sort=-committerdate',\n+\t\t     '--count=1',\n+\t\t     'refs/heads') or return;\n+\t\t$most_recent = <$fd>;\n+\t\tclose $fd or return;\n+\t}\n+\n \tif ($most_recent =~ / (\\d+) [-+][01]\\d\\d\\d$/) {\n \t\tmy $timestamp = $1;\n \t\tmy $age = time - $timestamp;\n@@ -2561,10 +2594,11 @@ sub git_project_list_body {\n \tmy ($projlist, $order, $from, $to, $extra, $no_header) = @_;\n \n \tmy ($check_forks) = gitweb_check_feature('forks');\n+\tmy ($last_activity_ref) = gitweb_check_feature('last_activity_ref');\n \n \tmy @projects;\n \tforeach my $pr (@$projlist) {\n-\t\tmy (@aa) = git_get_last_activity($pr->{'path'});\n+\t\tmy (@aa) = git_get_last_activity($pr->{'path'}, $last_activity_ref);\n \t\tunless (@aa) {\n \t\t\tnext;\n \t\t}\n-- \n1.5.0.rc0.g5b5f\n"},{"id":"30485","messageId":"7vlkkqms8n.fsf@assigned-by-dhcp.cox.net","threadId":"6152","inReplyTo":"20061229185805.GF6558@localhost","subject":"Re: [PATCH] gitweb: New feature last_modified_ref.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-29T19:12:08Z","receivedAt":"2006-12-29T19:12:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I somehow suspect this is solving the problem with a wrong\ntradeoff.\n\nThis change only affects the project list page, which I think is\nsimpler to deal with more aggressive caching (say, no more than\nonce every 10 minutes even if some project pushed a new head in\nthe meantime).\n\nNot a firm refusal, but something to think about.\n"},{"id":"30493","messageId":"20061230001218.GH6558@localhost","threadId":"6152","inReplyTo":"7vlkkqms8n.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: New feature last_modified_ref.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-30T00:12:18Z","receivedAt":"2006-12-30T00:12:18Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"> I somehow suspect this is solving the problem with a wrong\n> tradeoff.\n\nI think the main problem is that we are trying to fix possible\nperformance problems with the latest version, just because they might\ncause a major problem on kernel.org.\n\nAt this point I think we should get the latest version loaded and see\nwhat the real problems are.\n\nRobert\n"}]}