{"thread":{"id":"29461","subject":"[PATCH v2 1/2] gitweb: add project_filter to limit project list to a subdirectory","startedAt":"2012-01-28T16:56:10Z","lastAt":"2012-02-01T20:55:50Z","messageCount":40,"participants":["Bernhard R. Link","Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"183226","messageId":"20120128165606.GA6770@server.brlink.eu","threadId":"29461","inReplyTo":null,"subject":"[PATCH v2 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-28T16:56:10Z","receivedAt":"2012-01-28T16:56:10Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"This commit changes the project listings (project_list, project_index\nand opml) to limit the output to only projects in a subdirectory if the\nnew optional parameter ?pf=directory name is used.\n\nThe change is quite minimal as git_get_projects_list already can limit\nitself to a subdirectory (though that was previously only used for\n'forks').\n\nIf strict_export is enabled and there is no projects_list, it still\ntraverses the full tree and only filters afterwards to avoid anything\ngetting visible by this. Otherwise only the subtree needs to be\ntraversed, significantly reducing load times.\n\nReusing $project instead of adding a new parameter would have been\nnicer from a UI point-of-view (including PATH_INFO support) but\nwould complicate the $project validating code that is currently being\nused to ensure nothing is exported that should not be viewable.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n Changed since version 1:\n   - improve description\n   - simplify as suggested by Jakub Narebski\n   - support the strict_exports + no projects_list case\n\n gitweb/gitweb.perl |   29 ++++++++++++++++++++++-------\n 1 files changed, 22 insertions(+), 7 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex abb5a79..a114bd4 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -760,6 +760,7 @@ our @cgi_param_mapping = (\n \tsearch_use_regexp => \"sr\",\n \tctag => \"by_tag\",\n \tdiff_style => \"ds\",\n+\tproject_filter => \"pf\",\n \t# this must be last entry (for manipulation from JavaScript)\n \tjavascript => \"js\"\n );\n@@ -976,7 +977,7 @@ sub evaluate_path_info {\n \n our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,\n      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,\n-     $searchtext, $search_regexp);\n+     $searchtext, $search_regexp, $project_filter);\n sub evaluate_and_validate_params {\n \tour $action = $input_params{'action'};\n \tif (defined $action) {\n@@ -994,6 +995,13 @@ sub evaluate_and_validate_params {\n \t\t}\n \t}\n \n+\tour $project_filter = $input_params{'project_filter'};\n+\tif (defined $project_filter) {\n+\t\tif (!validate_pathname($project_filter)) {\n+\t\t\tdie_error(404, \"Invalid project_filter parameter\");\n+\t\t}\n+\t}\n+\n \tour $file_name = $input_params{'file_name'};\n \tif (defined $file_name) {\n \t\tif (!validate_pathname($file_name)) {\n@@ -2827,6 +2835,7 @@ sub git_get_project_url_list {\n \n sub git_get_projects_list {\n \tmy $filter = shift || '';\n+\tmy $paranoid = shift || 0;\n \tmy @list;\n \n \t$filter =~ s/\\.git$//;\n@@ -2839,7 +2848,7 @@ sub git_get_projects_list {\n \t\tmy $pfxlen = length(\"$dir\");\n \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n \t\t# when filtering, search only given subdirectory\n-\t\tif ($filter) {\n+\t\tif ($filter and not $paranoid) {\n \t\t\t$dir .= \"/$filter\";\n \t\t\t$dir =~ s!/+$!!;\n \t\t}\n@@ -2864,6 +2873,10 @@ sub git_get_projects_list {\n \t\t\t\t}\n \n \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n+\t\t\t\t# paranoidly only filter here\n+\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n \t\t\t\t# we check related file in $projectroot\n \t\t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n \t\t\t\t\tpush @list, { path => $path };\n@@ -3963,9 +3976,11 @@ sub git_footer_html {\n \t\t}\n \n \t} else {\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"OPML\") . \" \";\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n \t}\n \tprint \"</div>\\n\"; # class=\"page_footer\"\n@@ -5979,7 +5994,7 @@ sub git_project_list {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -6018,7 +6033,7 @@ sub git_forks {\n }\n \n sub git_project_index {\n-\tmy @projects = git_get_projects_list();\n+\tmy @projects = git_get_projects_list($project_filter, $strict_export);\n \tif (!@projects) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -7855,7 +7870,7 @@ sub git_atom {\n }\n \n sub git_opml {\n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n-- \n1.7.8.3\n"},{"id":"183227","messageId":"20120128165753.GA6795@server.brlink.eu","threadId":"29461","inReplyTo":"20120128165606.GA6770@server.brlink.eu","subject":"[PATCH v2 2/2] gitweb: place links to parent directories in page header","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-28T16:57:56Z","receivedAt":"2012-01-28T16:57:56Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Signed-off-by: Bernhard R. Link <brlink@debian.org>\n\n---\nThis patch was not yet part of v1.\n\nI'm not sure this if having this as seperate patch or merged into 1/2\nmakes more sense.\n\n gitweb/gitweb.perl |   23 ++++++++++++++++++++++-\n 1 files changed, 22 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a114bd4..ddce27d 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3841,7 +3841,18 @@ sub print_nav_breadcrumbs {\n \n \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n \tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tmy @dirname = split '/', $project;\n+\t\tmy $projectbasename = pop @dirname;\n+\t\tmy $dirprefix = undef;\n+\t\twhile (my $part = shift @dirname) {\n+\t\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t\t$dirprefix .= $part;\n+\t\t\tprint $cgi->a({-href => href(project => undef,\n+\t\t\t                             project_filter => $dirprefix,\n+\t\t\t                             action=>\"project_list\")},\n+\t\t\t              esc_html($part)) . \" / \";\n+\t\t}\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n \t\tif (defined $action) {\n \t\t\tmy $action_print = $action ;\n \t\t\tif (defined $opts{-action_extra}) {\n@@ -3854,6 +3865,16 @@ sub print_nav_breadcrumbs {\n \t\t\tprint \" / $opts{-action_extra}\";\n \t\t}\n \t\tprint \"\\n\";\n+\t} elsif (defined $project_filter) {\n+\t\tmy @dirname = split '/', $project_filter;\n+\t\tmy $dirprefix = undef;\n+\t\twhile (my $part = shift @dirname) {\n+\t\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t\t$dirprefix .= $part;\n+\t\t\tprint $cgi->a({-href => href(project_filter => $dirprefix,\n+\t\t\t                             action=>\"project_list\")},\n+\t\t\t              esc_html($part)) . \" / \";\n+\t\t}\n \t}\n }\n \n-- \n1.7.8.3\n"},{"id":"183232","messageId":"m3wr8bcuon.fsf@localhost.localdomain","threadId":"29461","inReplyTo":"20120128165606.GA6770@server.brlink.eu","subject":"Re: [PATCH v2 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-28T22:45:28Z","receivedAt":"2012-01-28T22:45:28Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n\n> This commit changes the project listings (project_list, project_index\n> and opml) to limit the output to only projects in a subdirectory if the\n> new optional parameter ?pf=directory name is used.\n> \n\"project listings\" to \"projects listing views\", isn't it?\n\n> The change is quite minimal as git_get_projects_list already can limit\n> itself to a subdirectory (though that was previously only used for\n> 'forks').\n>\nNice description, and more clear than before.\n \n> If strict_export is enabled and there is no projects_list, it still\n> traverses the full tree and only filters afterwards to avoid anything\n> getting visible by this. Otherwise only the subtree needs to be\n> traversed, significantly reducing load times.\n>\nI still don't understand interaction between project_filter ('pf'),\n$strict_export and $projects_list being either directory or a file\nwith a list of projects.\n\nDoes it mean, that when $projects_list is a file with a list of projects,\nand we use project_filter, then:\n\n* if $strict_export is false, then $project_list is ignored, and the\n  filtered list of projects is created by scanning\n  \"$projectroot/$project_filter\"\n\n* if $strict_export is true, then $project_list file is read in full,\n  and then filtered to project with $project_filter as prefix\n \nIs it correct?  Is it sane, stated this way?\n\n> Reusing $project instead of adding a new parameter would have been\n> nicer from a UI point-of-view (including PATH_INFO support) but\n> would complicate the $project validating code that is currently being\n> used to ensure nothing is exported that should not be viewable.\n> \nO.K.\n\nAnyway PATH_INFO support can be added in the future, by special casing\nsituation where project list action is stated using PATH_INFO... I think.\n\n\nA few nitpicks with respect to patch itself.\n\n> @@ -2827,6 +2835,7 @@ sub git_get_project_url_list {\n>  \n>  sub git_get_projects_list {\n>  \tmy $filter = shift || '';\n> +\tmy $paranoid = shift || 0;\n>  \tmy @list;\n>  \n\nFirst, undefined value is false in Perl, so there is no need for\n\" || 0\" in setting $paranoid variable.\n\nSecond, why not use global variable $strict_export instead of adding\nanother parameter to git_get_projects_list()?\n\n> @@ -5979,7 +5994,7 @@ sub git_project_list {\n>  \t\tdie_error(400, \"Unknown order parameter\");\n>  \t}\n>  \n> -\tmy @list = git_get_projects_list();\n> +\tmy @list = git_get_projects_list($project_filter, $strict_export);\n>  \tif (!@list) {\n>  \t\tdie_error(404, \"No projects found\");\n>  \t}\n\n[...]\n\n> @@ -3963,9 +3976,11 @@ sub git_footer_html {\n>  \t\t}\n>  \n>  \t} else {\n> -\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n> +\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n> +\t\t                             project_filter => $project_filter),\n>  \t\t              -class => $feed_class}, \"OPML\") . \" \";\n> -\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n> +\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n> +\t\t                             project_filter => $project_filter),\n>  \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n>  \t}\n\nO.K.\n\n-- \nJakub Narebski\n"},{"id":"183233","messageId":"m3sjizcu8x.fsf@localhost.localdomain","threadId":"29461","inReplyTo":"20120128165753.GA6795@server.brlink.eu","subject":"Re: [PATCH v2 2/2] gitweb: place links to parent directories in page header","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-28T22:54:55Z","receivedAt":"2012-01-28T22:54:55Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n\nDescription?\n\n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n> \n> ---\n> This patch was not yet part of v1.\n> \n> I'm not sure this if having this as seperate patch or merged into 1/2\n> makes more sense.\n\nWhile adding links that lead to gitweb URLs with project_filter\nparameter set, i.e. linking new feature in, could be postponed to a\nlater commit, I think some way of notifying client that project list\nis filtered would be better to have in 1/2.\n \n>  gitweb/gitweb.perl |   23 ++++++++++++++++++++++-\n>  1 files changed, 22 insertions(+), 1 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index a114bd4..ddce27d 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3841,7 +3841,18 @@ sub print_nav_breadcrumbs {\n>  \n>  \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n>  \tif (defined $project) {\n> -\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n> +\t\tmy @dirname = split '/', $project;\n> +\t\tmy $projectbasename = pop @dirname;\n> +\t\tmy $dirprefix = undef;\n> +\t\twhile (my $part = shift @dirname) {\n> +\t\t\t$dirprefix .= \"/\" if defined $dirprefix;\n> +\t\t\t$dirprefix .= $part;\n> +\t\t\tprint $cgi->a({-href => href(project => undef,\n> +\t\t\t                             project_filter => $dirprefix,\n> +\t\t\t                             action=>\"project_list\")},\n> +\t\t\t              esc_html($part)) . \" / \";\n> +\t\t}\n> +\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n>  \t\tif (defined $action) {\n>  \t\t\tmy $action_print = $action ;\n>  \t\t\tif (defined $opts{-action_extra}) {\n\nNice solution.\n\n> @@ -3854,6 +3865,16 @@ sub print_nav_breadcrumbs {\n>  \t\t\tprint \" / $opts{-action_extra}\";\n>  \t\t}\n>  \t\tprint \"\\n\";\n> +\t} elsif (defined $project_filter) {\n> +\t\tmy @dirname = split '/', $project_filter;\n> +\t\tmy $dirprefix = undef;\n> +\t\twhile (my $part = shift @dirname) {\n> +\t\t\t$dirprefix .= \"/\" if defined $dirprefix;\n> +\t\t\t$dirprefix .= $part;\n> +\t\t\tprint $cgi->a({-href => href(project_filter => $dirprefix,\n> +\t\t\t                             action=>\"project_list\")},\n> +\t\t\t              esc_html($part)) . \" / \";\n> +\t\t}\n>  \t}\n>  }\n\nHmmm... I'd have to check how it looks like, but seems like a good\nidea... even if there is a little bit of code duplication.\n\n-- \nJakub Narebski\n"},{"id":"183235","messageId":"20120129012234.GD16079@server.brlink.eu","threadId":"29461","inReplyTo":"m3wr8bcuon.fsf@localhost.localdomain","subject":"[PATCH v3] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-29T01:22:35Z","receivedAt":"2012-01-29T01:22:35Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"This commit changes the project listing views (project_list,\nproject_index and opml) to limit the output to only projects in a\nsubdirectory if the new optional parameter ?pf=directory name is used.\n\nThe change is quite minimal as git_get_projects_list already can limit\nitself to a subdirectory (though that was previously only used for\n'forks').\n\nIf there is a GITWEB_LIST file, the contents are just filtered like\nwith the forks action.\n\nWithout a GITWEB_LIST file only the given subdirectory is searched\nfor projects (like with forks) unless GITWEB_STRICT_EXPORT is enabled.\nIn the later case GITWEB_PROJECTROOT is traversed normally (unlike\nwith forks) and projects not in the directory ignored.\n(As there is no check if the filter_path would have been found in\nthe usual search as the project path is checked with forks).\n\nReusing $project instead of adding a new parameter would have been\nnicer from a UI point-of-view (including PATH_INFO support) but\nwould complicate the $project validating code that is currently being\nused to ensure nothing is exported that should not be viewable.\n\nAdditionally change html page headers to not only link the project\nroot and the currently selected project but also the directories in\nbetween using project_filter.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n\nchanges since v2:\n        improve description\n        remove || 0 for boolean argument\n        merge with patch using this feature\n        use user-visible configuration names instead of internal ones\n\n* Jakub Narebski <jnareb@gmail.com> [120128 23:45]:\n> \"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n> > If strict_export is enabled and there is no projects_list, it still\n> > traverses the full tree and only filters afterwards to avoid anything\n> > getting visible by this. Otherwise only the subtree needs to be\n> > traversed, significantly reducing load times.\n> >\n> I still don't understand interaction between project_filter ('pf'),\n> $strict_export and $projects_list being either directory or a file\n> with a list of projects.\n> \n> Does it mean, that when $projects_list is a file with a list of projects,\n> and we use project_filter, then:\n> \n> * if $strict_export is false, then $project_list is ignored, and the\n>   filtered list of projects is created by scanning\n>   \"$projectroot/$project_filter\"\n\nNo. If project_list is set, i.e. a file, then this is always used.\nIf it is a directory (because it is not set thus set to projectroot),\nthen with forks it still traverses that directory (as that was checked\nbefore to be a reachable project with a previous call to\ngit_get_projects_list). In the case of project_filter only the directory\nis traversed without strict_export and the whole projectroot is\ntraversed with strict_export.\n\nIs the new description better.\n\n> A few nitpicks with respect to patch itself.\n> \n> >  -2827,6 +2835,7 @@ sub git_get_project_url_list {\n> >  \n> >  sub git_get_projects_list {\n> >  \tmy $filter = shift || '';\n> > +\tmy $paranoid = shift || 0;\n> >  \tmy @list;\n> >  \n> \n> First, undefined value is false in Perl, so there is no need for\n> \" || 0\" in setting $paranoid variable.\n\nI thought it make it clearer that the argument might not be set and\nwhat the default is. But that is personal taste.\n\n> Second, why not use global variable $strict_export instead of adding\n> another parameter to git_get_projects_list()?\n\nThat would change the action=forks behaviour to traverse the whole\nprojectroot two times. This way paranoia is only activated if\nstrict_mode is set _and_ the argument was not yet checked to be\nreachable.\n\n\n gitweb/gitweb.perl |   52 ++++++++++++++++++++++++++++++++++++++++++++--------\n 1 files changed, 44 insertions(+), 8 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex abb5a79..089d45d 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -760,6 +760,7 @@ our @cgi_param_mapping = (\n \tsearch_use_regexp => \"sr\",\n \tctag => \"by_tag\",\n \tdiff_style => \"ds\",\n+\tproject_filter => \"pf\",\n \t# this must be last entry (for manipulation from JavaScript)\n \tjavascript => \"js\"\n );\n@@ -976,7 +977,7 @@ sub evaluate_path_info {\n \n our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,\n      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,\n-     $searchtext, $search_regexp);\n+     $searchtext, $search_regexp, $project_filter);\n sub evaluate_and_validate_params {\n \tour $action = $input_params{'action'};\n \tif (defined $action) {\n@@ -994,6 +995,13 @@ sub evaluate_and_validate_params {\n \t\t}\n \t}\n \n+\tour $project_filter = $input_params{'project_filter'};\n+\tif (defined $project_filter) {\n+\t\tif (!validate_pathname($project_filter)) {\n+\t\t\tdie_error(404, \"Invalid project_filter parameter\");\n+\t\t}\n+\t}\n+\n \tour $file_name = $input_params{'file_name'};\n \tif (defined $file_name) {\n \t\tif (!validate_pathname($file_name)) {\n@@ -2827,6 +2835,7 @@ sub git_get_project_url_list {\n \n sub git_get_projects_list {\n \tmy $filter = shift || '';\n+\tmy $paranoid = shift;\n \tmy @list;\n \n \t$filter =~ s/\\.git$//;\n@@ -2839,7 +2848,7 @@ sub git_get_projects_list {\n \t\tmy $pfxlen = length(\"$dir\");\n \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n \t\t# when filtering, search only given subdirectory\n-\t\tif ($filter) {\n+\t\tif ($filter and not $paranoid) {\n \t\t\t$dir .= \"/$filter\";\n \t\t\t$dir =~ s!/+$!!;\n \t\t}\n@@ -2864,6 +2873,10 @@ sub git_get_projects_list {\n \t\t\t\t}\n \n \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n+\t\t\t\t# paranoidly only filter here\n+\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n \t\t\t\t# we check related file in $projectroot\n \t\t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n \t\t\t\t\tpush @list, { path => $path };\n@@ -3828,7 +3841,18 @@ sub print_nav_breadcrumbs {\n \n \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n \tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tmy @dirname = split '/', $project;\n+\t\tmy $projectbasename = pop @dirname;\n+\t\tmy $dirprefix = undef;\n+\t\twhile (my $part = shift @dirname) {\n+\t\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t\t$dirprefix .= $part;\n+\t\t\tprint $cgi->a({-href => href(project => undef,\n+\t\t\t                             project_filter => $dirprefix,\n+\t\t\t                             action=>\"project_list\")},\n+\t\t\t              esc_html($part)) . \" / \";\n+\t\t}\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n \t\tif (defined $action) {\n \t\t\tmy $action_print = $action ;\n \t\t\tif (defined $opts{-action_extra}) {\n@@ -3841,6 +3865,16 @@ sub print_nav_breadcrumbs {\n \t\t\tprint \" / $opts{-action_extra}\";\n \t\t}\n \t\tprint \"\\n\";\n+\t} elsif (defined $project_filter) {\n+\t\tmy @dirname = split '/', $project_filter;\n+\t\tmy $dirprefix = undef;\n+\t\twhile (my $part = shift @dirname) {\n+\t\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t\t$dirprefix .= $part;\n+\t\t\tprint $cgi->a({-href => href(project_filter => $dirprefix,\n+\t\t\t                             action=>\"project_list\")},\n+\t\t\t              esc_html($part)) . \" / \";\n+\t\t}\n \t}\n }\n \n@@ -3963,9 +3997,11 @@ sub git_footer_html {\n \t\t}\n \n \t} else {\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"OPML\") . \" \";\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n \t}\n \tprint \"</div>\\n\"; # class=\"page_footer\"\n@@ -5979,7 +6015,7 @@ sub git_project_list {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -6018,7 +6054,7 @@ sub git_forks {\n }\n \n sub git_project_index {\n-\tmy @projects = git_get_projects_list();\n+\tmy @projects = git_get_projects_list($project_filter, $strict_export);\n \tif (!@projects) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -7855,7 +7891,7 @@ sub git_atom {\n }\n \n sub git_opml {\n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n-- \n1.7.8.3\n"},{"id":"183251","messageId":"201201291354.50241.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120129012234.GD16079@server.brlink.eu","subject":"Re: [PATCH v3] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-29T12:54:49Z","receivedAt":"2012-01-29T12:54:49Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sun, 29 Jan 2012, Bernhard R. Link wrote:\n\n> This commit changes the project listing views (project_list,\n> project_index and opml) to limit the output to only projects in a\n> subdirectory if the new optional parameter ?pf=directory name is used.\n> \n> The change is quite minimal as git_get_projects_list already can limit\n> itself to a subdirectory (though that was previously only used for\n> 'forks').\n>\nNice and succinct.\n \n> If there is a GITWEB_LIST file, the contents are just filtered like\n> with the forks action.\n> \nO.K.\n\n> Without a GITWEB_LIST file only the given subdirectory is searched\n> for projects (like with forks) unless GITWEB_STRICT_EXPORT is enabled.\n> In the later case GITWEB_PROJECTROOT is traversed normally (unlike\n> with forks) and projects not in the directory ignored.\n> (As there is no check if the filter_path would have been found in\n> the usual search as the project path is checked with forks).\n> \nNow I understand how project_filter interacts with strict_export.\n\nThough I am not sure if this \"paranoid mode\" is really necessary.  I don't\nsee how you could get in situation where scanning from $project_list and\nfiltering with $project_filter prefix, and scanning from \n$project_list/$project_filter would give different results.\n\nI think you are overly paranoid here, but perhaps it is better to be\noverly strict, and then relax it if it turns out to be not necessary.\n\n> Reusing $project instead of adding a new parameter would have been\n> nicer from a UI point-of-view (including PATH_INFO support) but\n> would complicate the $project validating code that is currently being\n> used to ensure nothing is exported that should not be viewable.\n> \nSidenote: support for actionless PATH_INFO URLs would make it even more\ncomplicated...\n\n> Additionally change html page headers to not only link the project\n> root and the currently selected project but also the directories in\n> between using project_filter.\n> \nExcuse me changing my mind, but I think that as far as this patch series\nis applied as whole, it would be better for maintability to keep those\ntwo patches split; though put the above as a [part of] commit message\nin 2/2 patch.\n\n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n> ---\n> \n> changes since v2:\n>         improve description\n>         remove || 0 for boolean argument\n>         merge with patch using this feature\n>         use user-visible configuration names instead of internal ones\n> \n> * Jakub Narebski <jnareb@gmail.com> [120128 23:45]:\n> > \"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n> > > If strict_export is enabled and there is no projects_list, it still\n> > > traverses the full tree and only filters afterwards to avoid anything\n> > > getting visible by this. Otherwise only the subtree needs to be\n> > > traversed, significantly reducing load times.\n> > >\n> > I still don't understand interaction between project_filter ('pf'),\n> > $strict_export and $projects_list being either directory or a file\n> > with a list of projects.\n> > \n> > Does it mean, that when $projects_list is a file with a list of projects,\n> > and we use project_filter, then:\n> > \n> > * if $strict_export is false, then $project_list is ignored, and the\n> >   filtered list of projects is created by scanning\n> >   \"$projectroot/$project_filter\"\n> \n> No. If project_list is set, i.e. a file, then this is always used.\n> If it is a directory (because it is not set thus set to projectroot),\n> then with forks it still traverses that directory (as that was checked\n> before to be a reachable project with a previous call to\n> git_get_projects_list). In the case of project_filter only the directory\n> is traversed without strict_export and the whole projectroot is\n> traversed with strict_export.\n> \nO.K., now I understand it.\n\n> Is the new description better.\n> \nYes it is.\n\n> > A few nitpicks with respect to patch itself.\n> > \n> > >  -2827,6 +2835,7 @@ sub git_get_project_url_list {\n> > >  \n> > >  sub git_get_projects_list {\n> > >  \tmy $filter = shift || '';\n> > > +\tmy $paranoid = shift || 0;\n> > >  \tmy @list;\n> > >  \n> > \n> > First, undefined value is false in Perl, so there is no need for\n> > \" || 0\" in setting $paranoid variable.\n> \n> I thought it make it clearer that the argument might not be set and\n> what the default is. But that is personal taste.\n\nFirst, optional parameter defaults to false in the 'my $foo = shift;'\nor equivalent form is (I think) idiomatic Perl.  Second, this way of\nwriting it is used through gitweb code (CodingGuidelines: imitate existing\ncoding practices). \n \n> > Second, why not use global variable $strict_export instead of adding\n> > another parameter to git_get_projects_list()?\n> \n> That would change the action=forks behaviour to traverse the whole\n> projectroot two times. This way paranoia is only activated if\n> strict_mode is set _and_ the argument was not yet checked to be\n> reachable.\n\nThanks for explanation.\n \n>  gitweb/gitweb.perl |   52 ++++++++++++++++++++++++++++++++++++++++++++--------\n>  1 files changed, 44 insertions(+), 8 deletions(-)\n\nNot that large for a new feature...\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183254","messageId":"20120129160615.GA13937@server.brlink.eu","threadId":"29461","inReplyTo":"201201291354.50241.jnareb@gmail.com","subject":"[PATCH v4 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-29T16:06:15Z","receivedAt":"2012-01-29T16:06:15Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"This commit changes the project listing views (project_list,\nproject_index and opml) to limit the output to only projects in a\nsubdirectory if the new optional parameter ?pf=directory name is used.\n\nThe change is quite minimal as git_get_projects_list already can limit\nitself to a subdirectory (though that was previously only used for\n'forks').\n\nIf there is a GITWEB_LIST file, the contents are just filtered like\nwith the forks action.\n\nWithout a GITWEB_LIST file only the given subdirectory is searched\nfor projects (like with forks) unless GITWEB_STRICT_EXPORT is enabled.\nIn the later case GITWEB_PROJECTROOT is traversed normally (unlike\nwith forks) and projects not in the directory ignored.\n(As there is no check if the filter_path would have been found in\nthe usual search as the project path is checked with forks).\n\nReusing $project instead of adding a new parameter would have been\nnicer from a UI point-of-view (including PATH_INFO support) but\nwould complicate the $project validating code that is currently being\nused to ensure nothing is exported that should not be viewable.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n\n* Jakub Narebski <jnareb@gmail.com> [120129 13:54]:\n> On Sun, 29 Jan 2012, Bernhard R. Link wrote:\n> Though I am not sure if this \"paranoid mode\" is really necessary.  I don't\n> see how you could get in situation where scanning from $project_list and\n> filtering with $project_filter prefix, and scanning from\n> $project_list/$project_filter would give different results.\n>\n> I think you are overly paranoid here, but perhaps it is better to be\n> overly strict, and then relax it if it turns out to be not necessary.\n\nAs far as I do understand it, this is the only (hopefully unecessary)\neffect strict_export without a project_list has in gitweb, so I did not\nwant to remove that with this change.\n\n> Excuse me changing my mind, but I think that as far as this patch series\n> is applied as whole, it would be better for maintability to keep those\n> two patches split; though put the above as a [part of] commit message\n> in 2/2 patch.\n\nSplit again, though this time only the change for existing pages in the\nsecond commit and the code duplication you spoke against removed.\n\n gitweb/gitweb.perl |   43 ++++++++++++++++++++++++++++++++++++-------\n 1 files changed, 36 insertions(+), 7 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex abb5a79..f0e03d8 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -760,6 +760,7 @@ our @cgi_param_mapping = (\n \tsearch_use_regexp => \"sr\",\n \tctag => \"by_tag\",\n \tdiff_style => \"ds\",\n+\tproject_filter => \"pf\",\n \t# this must be last entry (for manipulation from JavaScript)\n \tjavascript => \"js\"\n );\n@@ -976,7 +977,7 @@ sub evaluate_path_info {\n \n our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,\n      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,\n-     $searchtext, $search_regexp);\n+     $searchtext, $search_regexp, $project_filter);\n sub evaluate_and_validate_params {\n \tour $action = $input_params{'action'};\n \tif (defined $action) {\n@@ -994,6 +995,13 @@ sub evaluate_and_validate_params {\n \t\t}\n \t}\n \n+\tour $project_filter = $input_params{'project_filter'};\n+\tif (defined $project_filter) {\n+\t\tif (!validate_pathname($project_filter)) {\n+\t\t\tdie_error(404, \"Invalid project_filter parameter\");\n+\t\t}\n+\t}\n+\n \tour $file_name = $input_params{'file_name'};\n \tif (defined $file_name) {\n \t\tif (!validate_pathname($file_name)) {\n@@ -2827,6 +2835,7 @@ sub git_get_project_url_list {\n \n sub git_get_projects_list {\n \tmy $filter = shift || '';\n+\tmy $paranoid = shift;\n \tmy @list;\n \n \t$filter =~ s/\\.git$//;\n@@ -2839,7 +2848,7 @@ sub git_get_projects_list {\n \t\tmy $pfxlen = length(\"$dir\");\n \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n \t\t# when filtering, search only given subdirectory\n-\t\tif ($filter) {\n+\t\tif ($filter and not $paranoid) {\n \t\t\t$dir .= \"/$filter\";\n \t\t\t$dir =~ s!/+$!!;\n \t\t}\n@@ -2864,6 +2873,10 @@ sub git_get_projects_list {\n \t\t\t\t}\n \n \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n+\t\t\t\t# paranoidly only filter here\n+\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n \t\t\t\t# we check related file in $projectroot\n \t\t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n \t\t\t\t\tpush @list, { path => $path };\n@@ -3823,6 +3836,18 @@ sub print_header_links {\n \t}\n }\n \n+sub print_nav_breadcrumbs_path {\n+\tmy $dirprefix = undef;\n+\twhile (my $part = shift) {\n+\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t$dirprefix .= $part;\n+\t\tprint $cgi->a({-href => href(project => undef,\n+\t\t                             project_filter => $dirprefix,\n+\t\t\t\t\t     action=>\"project_list\")},\n+\t\t\t      esc_html($part)) . \" / \";\n+\t}\n+}\n+\n sub print_nav_breadcrumbs {\n \tmy %opts = @_;\n \n@@ -3841,6 +3866,8 @@ sub print_nav_breadcrumbs {\n \t\t\tprint \" / $opts{-action_extra}\";\n \t\t}\n \t\tprint \"\\n\";\n+\t} elsif (defined $project_filter) {\n+\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n \t}\n }\n \n@@ -3963,9 +3990,11 @@ sub git_footer_html {\n \t\t}\n \n \t} else {\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"OPML\") . \" \";\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n \t}\n \tprint \"</div>\\n\"; # class=\"page_footer\"\n@@ -5979,7 +6008,7 @@ sub git_project_list {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -6018,7 +6047,7 @@ sub git_forks {\n }\n \n sub git_project_index {\n-\tmy @projects = git_get_projects_list();\n+\tmy @projects = git_get_projects_list($project_filter, $strict_export);\n \tif (!@projects) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -7855,7 +7884,7 @@ sub git_atom {\n }\n \n sub git_opml {\n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n-- \n1.7.8.3\n"},{"id":"183256","messageId":"20120129161316.GD13937@server.brlink.eu","threadId":"29461","inReplyTo":"20120129160615.GA13937@server.brlink.eu","subject":"[PATCH v4 2/2] gitweb: place links to parent directories in page header","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-29T16:13:16Z","receivedAt":"2012-01-29T16:13:16Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Change html page headers to not only link the project root and the\ncurrently selected project but also the directories in between using\nproject_filter.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n gitweb/gitweb.perl |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f0e03d8..e2a9146 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3853,7 +3853,10 @@ sub print_nav_breadcrumbs {\n \n \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n \tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tmy @dirname = split '/', $project;\n+\t\tmy $projectbasename = pop @dirname;\n+\t\tprint_nav_breadcrumbs_path(@dirname);\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n \t\tif (defined $action) {\n \t\t\tmy $action_print = $action ;\n \t\t\tif (defined $opts{-action_extra}) {\n-- \n1.7.8.3\n"},{"id":"183258","messageId":"201201291741.58532.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120129160615.GA13937@server.brlink.eu","subject":"Re: [PATCH v4 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-29T16:41:57Z","receivedAt":"2012-01-29T16:41:57Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sun, 29 Jan 2012, Bernhard R. Link wrote:\n\n> This commit changes the project listing views (project_list,\n> project_index and opml) to limit the output to only projects in a\n> subdirectory if the new optional parameter ?pf=directory name is used.\n> \n> The change is quite minimal as git_get_projects_list already can limit\n> itself to a subdirectory (though that was previously only used for\n> 'forks').\n> \n> If there is a GITWEB_LIST file, the contents are just filtered like\n> with the forks action.\n> \n> Without a GITWEB_LIST file only the given subdirectory is searched\n> for projects (like with forks) unless GITWEB_STRICT_EXPORT is enabled.\n> In the later case GITWEB_PROJECTROOT is traversed normally (unlike\n> with forks) and projects not in the directory ignored.\n> (As there is no check if the filter_path would have been found in\n> the usual search as the project path is checked with forks).\n\nI am still unsure if it is really necessary, but nevermind...\n \n> Reusing $project instead of adding a new parameter would have been\n> nicer from a UI point-of-view (including PATH_INFO support) but\n> would complicate the $project validating code that is currently being\n> used to ensure nothing is exported that should not be viewable.\n> \n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n> ---\n[...]\n> @@ -3823,6 +3836,18 @@ sub print_header_links {\n>  \t}\n>  }\n>  \n> +sub print_nav_breadcrumbs_path {\n> +\tmy $dirprefix = undef;\n> +\twhile (my $part = shift) {\n> +\t\t$dirprefix .= \"/\" if defined $dirprefix;\n> +\t\t$dirprefix .= $part;\n> +\t\tprint $cgi->a({-href => href(project => undef,\n> +\t\t                             project_filter => $dirprefix,\n> +\t\t\t\t\t     action=>\"project_list\")},\n> +\t\t\t      esc_html($part)) . \" / \";\n> +\t}\n> +}\n> +\n>  sub print_nav_breadcrumbs {\n>  \tmy %opts = @_;\n>  \n> @@ -3841,6 +3866,8 @@ sub print_nav_breadcrumbs {\n>  \t\t\tprint \" / $opts{-action_extra}\";\n>  \t\t}\n>  \t\tprint \"\\n\";\n> +\t} elsif (defined $project_filter) {\n> +\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n>  \t}\n>  }\n>  \n\nThis could have been split into a separate 2/3 commit, but nevermind;\nit can be squashed here.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183259","messageId":"201201291746.09967.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120129161316.GD13937@server.brlink.eu","subject":"Re: [PATCH v4 2/2] gitweb: place links to parent directories in page header","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-29T16:46:09Z","receivedAt":"2012-01-29T16:46:09Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sun, 29 Jan 2012, Bernhard R. Link wrote:\n\n> Change html page headers to not only link the project root and the\n> currently selected project but also the directories in between using\n> project_filter.\n\nNice interface to the new feature... though it doesn't really address\nthe problem that gitweb homepage is slow to generate with large number\nof projects.  Still, it is IMVHO a good improvement.\n \n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n> ---\n>  gitweb/gitweb.perl |    5 ++++-\n>  1 files changed, 4 insertions(+), 1 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index f0e03d8..e2a9146 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3853,7 +3853,10 @@ sub print_nav_breadcrumbs {\n>  \n>  \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n>  \tif (defined $project) {\n> -\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n> +\t\tmy @dirname = split '/', $project;\n> +\t\tmy $projectbasename = pop @dirname;\n> +\t\tprint_nav_breadcrumbs_path(@dirname);\n> +\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n>  \t\tif (defined $action) {\n>  \t\t\tmy $action_print = $action ;\n>  \t\t\tif (defined $opts{-action_extra}) {\n> -- \n\nNicely short with refactoring of print_nav_breadcrumbs_path() in 1/2!\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183260","messageId":"7v7h0afcc2.fsf@alter.siamese.dyndns.org","threadId":"29461","inReplyTo":"20120129160615.GA13937@server.brlink.eu","subject":"Re: [PATCH v4 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-29T21:06:21Z","receivedAt":"2012-01-29T21:06:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n\n> This commit changes the project listing views (project_list,\n> project_index and opml) to limit the output to only projects in a\n> subdirectory if the new optional parameter ?pf=directory name is used.\n>\n> The change is quite minimal as git_get_projects_list already can limit\n> itself to a subdirectory (though that was previously only used for\n> 'forks').\n>\n> If there is a GITWEB_LIST file, the contents are just filtered like\n> with the forks action.\n\nMeaning, a directory is shown if it is listed on GITWEB_LIST and is a\nsubdirectory of the directory specified with project_filter?  If so,\nspelling it out instead of saying \"just filtered like with the forks\naction\" may be clearer without making the description excessively longer.\n\n> Without a GITWEB_LIST file only the given subdirectory is searched\n> for projects (like with forks) unless GITWEB_STRICT_EXPORT is enabled.\n> In the later case GITWEB_PROJECTROOT is traversed normally (unlike\n> with forks) and projects not in the directory ignored.\n\nIt is unclear to me what \"In the later case\" refers to, even assuming that\nit is a typo of \"the latter case\".\n\nDo you mean \"When there is no GITWEB_LIST but GITWEB_STRICT_EXPORT is set,\nproject_filter that specifies anything outside GITWEB_PROJECTROOT is\nignored\"?\n\nA more fundamental issue I have with this patch is how an end user starts\nusing this. Once project_filter is set, the breadcrumbs would let the user\nclick and navigate around, but in my superficial glance at the patch it is\nnot apparent how the initial setting of project_filter can happen without\nthe user manually adding pf= to the URL, which is a less than ideal end\nuser experience.\n\n> @@ -2839,7 +2848,7 @@ sub git_get_projects_list {\n>  \t\tmy $pfxlen = length(\"$dir\");\n>  \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n>  \t\t# when filtering, search only given subdirectory\n> -\t\tif ($filter) {\n> +\t\tif ($filter and not $paranoid) {\n>  \t\t\t$dir .= \"/$filter\";\n>  \t\t\t$dir =~ s!/+$!!;\n>  \t\t}\n> @@ -2864,6 +2873,10 @@ sub git_get_projects_list {\n>  \t\t\t\t}\n>  \n>  \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n> +\t\t\t\t# paranoidly only filter here\n> +\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n> +\t\t\t\t\tnext;\n> +\t\t\t\t}\n\nWhen you find \"foo\" directory and a project_filter tells you to match\n\"foo\", because $path does not match \"^foo/\", it will not match (even\nthough its subdirectory \"foo/bar\" would)?\n\n> +sub print_nav_breadcrumbs_path {\n> +\tmy $dirprefix = undef;\n> +\twhile (my $part = shift) {\n> +\t\t$dirprefix .= \"/\" if defined $dirprefix;\n> +\t\t$dirprefix .= $part;\n> +\t\tprint $cgi->a({-href => href(project => undef,\n> +\t\t                             project_filter => $dirprefix,\n> +\t\t\t\t\t     action=>\"project_list\")},\n> +\t\t\t      esc_html($part)) . \" / \";\n> +\t}\n> +}\n> +\n>  sub print_nav_breadcrumbs {\n>  \tmy %opts = @_;\n>  \n> @@ -3841,6 +3866,8 @@ sub print_nav_breadcrumbs {\n>  \t\t\tprint \" / $opts{-action_extra}\";\n>  \t\t}\n>  \t\tprint \"\\n\";\n> +\t} elsif (defined $project_filter) {\n> +\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n>  \t}\n>  }\n\nHmm.\n\nWhile this may not be wrong, I wonder if this is limiting a useful feature\ntoo narrowly. When I visit \"/pub/scm /linux/kernel/git/torvals/linux.git\"\nat git.kernel.org, for example, there currently are two links, \"/pub/scm\"\nto the toplevel and \"/linux/kernel/git/torvals/linux.git\" to itself. I\noften wish to see uplinks to intermediate levels like \"/linux/kernel/git\"\nand \"/linux/kernel/git/torvalds\".\n\nPerhaps that is the topic of your second patch. I dunno.\n"},{"id":"183264","messageId":"201201300006.30287.jnareb@gmail.com","threadId":"29461","inReplyTo":"7v7h0afcc2.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v4 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-29T23:06:29Z","receivedAt":"2012-01-29T23:06:29Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sun, 29 Jan 2012, Junio C Hamano wrote:\n> \"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n> \n> > This commit changes the project listing views (project_list,\n> > project_index and opml) to limit the output to only projects in a\n> > subdirectory if the new optional parameter ?pf=directory name is used.\n> >\n> > The change is quite minimal as git_get_projects_list already can limit\n> > itself to a subdirectory (though that was previously only used for\n> > 'forks').\n> >\n> > If there is a GITWEB_LIST file, the contents are just filtered like\n> > with the forks action.\n> \n> Meaning, a directory is shown if it is listed on GITWEB_LIST and is a\n> subdirectory of the directory specified with project_filter?  If so,\n> spelling it out instead of saying \"just filtered like with the forks\n> action\" may be clearer without making the description excessively longer.\n\nThis means the following:\n\n  If $projects_list point to file with a list of projects, gitweb will\n  show only those project on the list which name matches $project_filter\n  prefix.\n\n> > Without a GITWEB_LIST file only the given subdirectory is searched\n> > for projects (like with forks) unless GITWEB_STRICT_EXPORT is enabled.\n> > In the later case GITWEB_PROJECTROOT is traversed normally (unlike\n> > with forks) and projects not in the directory ignored.\n> \n> It is unclear to me what \"In the later case\" refers to, even assuming that\n> it is a typo of \"the latter case\".\n> \n> Do you mean \"When there is no GITWEB_LIST but GITWEB_STRICT_EXPORT is set,\n> project_filter that specifies anything outside GITWEB_PROJECTROOT is\n> ignored\"?\n\n  If $projects_list points to a directory, but $strict_export is true, then\n  $project_list is scanned recursively for git repositories, as without\n  this feature, but only those projects that begin with $project_filter\n  are shown.\n\n  Otherwise ($projects_list points to directory and $strict_export not true)\n  then $project_filter subdirectory of $projects_list is scanned recursively\n  for git repositories (i.e. starting from \"projects_list/$project_filter\").\n \nI am not sure if this paranoia mode is really needed for $strict_export,\nthough.\n\n> A more fundamental issue I have with this patch is how an end user starts\n> using this. Once project_filter is set, the breadcrumbs would let the user\n> click and navigate around, but in my superficial glance at the patch it is\n> not apparent how the initial setting of project_filter can happen without\n> the user manually adding pf= to the URL, which is a less than ideal end\n> user experience.\n\nThe second patch in series adds breadcrumbs allowing to filter projects\nin any per-project view.\n\nThis feature was originally intended for giving handcrafter URL with\n'pf=....' to people...\n\n> > @@ -2839,7 +2848,7 @@ sub git_get_projects_list {\n> >  \t\tmy $pfxlen = length(\"$dir\");\n> >  \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n> >  \t\t# when filtering, search only given subdirectory\n> > -\t\tif ($filter) {\n> > +\t\tif ($filter and not $paranoid) {\n> >  \t\t\t$dir .= \"/$filter\";\n> >  \t\t\t$dir =~ s!/+$!!;\n> >  \t\t}\n> > @@ -2864,6 +2873,10 @@ sub git_get_projects_list {\n> >  \t\t\t\t}\n> >  \n> >  \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n> > +\t\t\t\t# paranoidly only filter here\n> > +\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n> > +\t\t\t\t\tnext;\n> > +\t\t\t\t}\n> \n> When you find \"foo\" directory and a project_filter tells you to match\n> \"foo\", because $path does not match \"^foo/\", it will not match (even\n> though its subdirectory \"foo/bar\" would)?\n\nStrictly speaking the match is on dirname of a project path; the basename\nof a project does not matter.  It is intended, but perhaps should be made\nmore clear in the commit message.\n \n> > +sub print_nav_breadcrumbs_path {\n> > +\tmy $dirprefix = undef;\n> > +\twhile (my $part = shift) {\n> > +\t\t$dirprefix .= \"/\" if defined $dirprefix;\n> > +\t\t$dirprefix .= $part;\n> > +\t\tprint $cgi->a({-href => href(project => undef,\n> > +\t\t                             project_filter => $dirprefix,\n> > +\t\t\t\t\t     action=>\"project_list\")},\n> > +\t\t\t      esc_html($part)) . \" / \";\n> > +\t}\n> > +}\n> > +\n> >  sub print_nav_breadcrumbs {\n> >  \tmy %opts = @_;\n> >  \n> > @@ -3841,6 +3866,8 @@ sub print_nav_breadcrumbs {\n> >  \t\t\tprint \" / $opts{-action_extra}\";\n> >  \t\t}\n> >  \t\tprint \"\\n\";\n> > +\t} elsif (defined $project_filter) {\n> > +\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n> >  \t}\n> >  }\n> \n> Hmm.\n> \n> While this may not be wrong, I wonder if this is limiting a useful feature\n> too narrowly. When I visit \"/pub/scm /linux/kernel/git/torvals/linux.git\"\n> at git.kernel.org, for example, there currently are two links, \"/pub/scm\"\n> to the toplevel and \"/linux/kernel/git/torvals/linux.git\" to itself. I\n> often wish to see uplinks to intermediate levels like \"/linux/kernel/git\"\n> and \"/linux/kernel/git/torvalds\".\n> \n> Perhaps that is the topic of your second patch. I dunno.\n\nYes, it is.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183296","messageId":"20120130095252.GA6183@server.brlink.eu","threadId":"29461","inReplyTo":"7v7h0afcc2.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v4 1/2] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T09:52:52Z","receivedAt":"2012-01-30T09:52:52Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"* Junio C Hamano <gitster@pobox.com> [120129 22:06]:\n> > @@ -2864,6 +2873,10 @@ sub git_get_projects_list {\n> >  \t\t\t\t}\n> >  \n> >  \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n> > +\t\t\t\t# paranoidly only filter here\n> > +\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n> > +\t\t\t\t\tnext;\n> > +\t\t\t\t}\n>\n> When you find \"foo\" directory and a project_filter tells you to match\n> \"foo\", because $path does not match \"^foo/\", it will not match (even\n> though its subdirectory \"foo/bar\" would)?\n\nYes, for consistency with what would be shown with a project list file.\n(And that it would only show projects which would have a link to this\ndirectory in their breadcrumbs (with 2/2)).\n\n> Perhaps that is the topic of your second patch. I dunno.\n\nYes, that is what the second patch does.\n\n        Bernhard R. Link\n"},{"id":"183310","messageId":"20120130114447.GA9267@server.brlink.eu","threadId":"29461","inReplyTo":"20120130095252.GA6183@server.brlink.eu","subject":"[PATCH v5 1/5] gitweb: prepare git_get_projects_list for use outside 'forks'.","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T11:44:47Z","receivedAt":"2012-01-30T11:44:47Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Use of the filter option of git_get_projects_list is currently\nlimited to forks. It hard codes removal of \".git\" suffixes from\nthe filter and assumes the project belonging to the filter directory\nwas already validated to be visible in the project list.\n\nTo make it more generic move the .git suffix removal to the callers\nand add an optional argument to denote visibility verification is\nstill needed.\n\nIf there is a projects list file (GITWEB_LIST) only projects from\nthis list are returned anyway, so no more checks needed.\n\nIf there is no projects list file and the caller requests strict\nchecking (GITWEB_STRICT_EXPORT), do not jump directly to the\ngiven directory but instead do a normal search and filter the\nresults instead.\n\nThe only (hopefully non-existing) effect of GITWEB_STRICT_EXPORT\nwithout GITWEB_LIST is to make sure no project can be viewed without\nalso be found starting from project root. git_get_projects_list without\nthis patch does not enforce this but all callers only call it with\na filter already checked this way. With this parameter a caller\ncan request this check if the filter cannot be checked this way.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n\nChanges to v4:\n\t- split patch in smaller parts\n\t- move \".git\" suffix removal from filters to forks specific code\n          (if you want this as patch on top of the previous series, let me know)\n\t- improve the descriptions of all patches\n---\n gitweb/gitweb.perl |   13 ++++++++-----\n 1 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 9cf7e71..acf1bae 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2829,10 +2829,9 @@ sub git_get_project_url_list {\n \n sub git_get_projects_list {\n \tmy $filter = shift || '';\n+\tmy $paranoid = shift;\n \tmy @list;\n \n-\t$filter =~ s/\\.git$//;\n-\n \tif (-d $projects_list) {\n \t\t# search in directory\n \t\tmy $dir = $projects_list;\n@@ -2841,7 +2840,7 @@ sub git_get_projects_list {\n \t\tmy $pfxlen = length(\"$dir\");\n \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n \t\t# when filtering, search only given subdirectory\n-\t\tif ($filter) {\n+\t\tif ($filter and not $paranoid) {\n \t\t\t$dir .= \"/$filter\";\n \t\t\t$dir =~ s!/+$!!;\n \t\t}\n@@ -2866,6 +2865,10 @@ sub git_get_projects_list {\n \t\t\t\t}\n \n \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n+\t\t\t\t# paranoidly only filter here\n+\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n \t\t\t\t# we check related file in $projectroot\n \t\t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n \t\t\t\t\tpush @list, { path => $path };\n@@ -6007,7 +6010,7 @@ sub git_forks {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list($project);\n+\tmy @list = git_get_projects_list($project =~ s/\\.git$//r);\n \tif (!@list) {\n \t\tdie_error(404, \"No forks found\");\n \t}\n@@ -6066,7 +6069,7 @@ sub git_summary {\n \n \tif ($check_forks) {\n \t\t# find forks of a project\n-\t\t@forklist = git_get_projects_list($project);\n+\t\t@forklist = git_get_projects_list($project =~ s/\\.git$//r);\n \t\t# filter out forks of forks\n \t\t@forklist = filter_forks_from_projects_list(\\@forklist)\n \t\t\tif (@forklist);\n-- \n1.7.8.3\n"},{"id":"183311","messageId":"20120130114557.GB9267@server.brlink.eu","threadId":"29461","inReplyTo":"20120130095252.GA6183@server.brlink.eu","subject":"[PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T11:45:57Z","receivedAt":"2012-01-30T11:45:57Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"This commit changes the project listing views (project_list,\nproject_index and opml) to limit the output to only projects in a\nsubdirectory if the new optional parameter ?pf=directory name is\nused.\n\nThe implementation of the filter reuses the implementation used for\nthe 'forks' action (i.e. listing all projects within that directory\nfrom the projects list file (GITWEB_LIST) or only projects in the\ngiven subdirectory of the project root directory without a projects\nlist file).\n\nReusing $project instead of adding a new parameter would have been\nnicer from a UI point-of-view (including PATH_INFO support) but\nwould complicate the $project validating code that is currently\nbeing used to ensure nothing is exported that should not be viewable.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n gitweb/gitweb.perl |   16 ++++++++++++----\n 1 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex acf1bae..36efc10 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -760,6 +760,7 @@ our @cgi_param_mapping = (\n \tsearch_use_regexp => \"sr\",\n \tctag => \"by_tag\",\n \tdiff_style => \"ds\",\n+\tproject_filter => \"pf\",\n \t# this must be last entry (for manipulation from JavaScript)\n \tjavascript => \"js\"\n );\n@@ -976,7 +977,7 @@ sub evaluate_path_info {\n \n our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,\n      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,\n-     $searchtext, $search_regexp);\n+     $searchtext, $search_regexp, $project_filter);\n sub evaluate_and_validate_params {\n \tour $action = $input_params{'action'};\n \tif (defined $action) {\n@@ -994,6 +995,13 @@ sub evaluate_and_validate_params {\n \t\t}\n \t}\n \n+\tour $project_filter = $input_params{'project_filter'};\n+\tif (defined $project_filter) {\n+\t\tif (!validate_pathname($project_filter)) {\n+\t\t\tdie_error(404, \"Invalid project_filter parameter\");\n+\t\t}\n+\t}\n+\n \tour $file_name = $input_params{'file_name'};\n \tif (defined $file_name) {\n \t\tif (!validate_pathname($file_name)) {\n@@ -5984,7 +5992,7 @@ sub git_project_list {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -6023,7 +6031,7 @@ sub git_forks {\n }\n \n sub git_project_index {\n-\tmy @projects = git_get_projects_list();\n+\tmy @projects = git_get_projects_list($project_filter, $strict_export);\n \tif (!@projects) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -7860,7 +7868,7 @@ sub git_atom {\n }\n \n sub git_opml {\n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n-- \n1.7.8.3\n"},{"id":"183312","messageId":"20120130114706.GC9267@server.brlink.eu","threadId":"29461","inReplyTo":"20120130095252.GA6183@server.brlink.eu","subject":"[PATCH 3/5] gitweb: limit links to alternate forms of project_list to active project_filter","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T11:47:06Z","receivedAt":"2012-01-30T11:47:06Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"If project_list action is given a project_filter argument, pass that to\nTXT and OPML formats.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n gitweb/gitweb.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 36efc10..e022e11 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3976,9 +3976,11 @@ sub git_footer_html {\n \t\t}\n \n \t} else {\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"OPML\") . \" \";\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n \t}\n \tprint \"</div>\\n\"; # class=\"page_footer\"\n-- \n1.7.8.3\n"},{"id":"183314","messageId":"20120130114852.GD9267@server.brlink.eu","threadId":"29461","inReplyTo":"20120130095252.GA6183@server.brlink.eu","subject":"[PATCH v5 4/5] gitweb: show active project_filter in project_list page header","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T11:48:52Z","receivedAt":"2012-01-30T11:48:52Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"In a project_list view show breadcrumbs with the currently active\nproject_filter (and those of parent directories) in the page header.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n gitweb/gitweb.perl |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex e022e11..dfc79df 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3836,6 +3836,18 @@ sub print_header_links {\n \t}\n }\n \n+sub print_nav_breadcrumbs_path {\n+\tmy $dirprefix = undef;\n+\twhile (my $part = shift) {\n+\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t$dirprefix .= $part;\n+\t\tprint $cgi->a({-href => href(project => undef,\n+\t\t                             project_filter => $dirprefix,\n+\t\t\t\t\t     action=>\"project_list\")},\n+\t\t\t      esc_html($part)) . \" / \";\n+\t}\n+}\n+\n sub print_nav_breadcrumbs {\n \tmy %opts = @_;\n \n@@ -3854,6 +3866,8 @@ sub print_nav_breadcrumbs {\n \t\t\tprint \" / $opts{-action_extra}\";\n \t\t}\n \t\tprint \"\\n\";\n+\t} elsif (defined $project_filter) {\n+\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n \t}\n }\n \n-- \n1.7.8.3\n"},{"id":"183315","messageId":"20120130115046.GE9267@server.brlink.eu","threadId":"29461","inReplyTo":"20120130095252.GA6183@server.brlink.eu","subject":"[PATCH v5 5/5] gitweb: place links to parent directories in page header","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T11:50:46Z","receivedAt":"2012-01-30T11:50:46Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Change html page headers to not only link the project root and the\ncurrently selected project but also the directories in between using\nproject_filter. (Allowing to jump to a list of all projects within\nthat intermediate directory directly and making the project_filter\nfeature visible to users).\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n gitweb/gitweb.perl |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex dfc79df..b54ddb9 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3853,7 +3853,10 @@ sub print_nav_breadcrumbs {\n \n \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n \tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tmy @dirname = split '/', $project;\n+\t\tmy $projectbasename = pop @dirname;\n+\t\tprint_nav_breadcrumbs_path(@dirname);\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n \t\tif (defined $action) {\n \t\t\tmy $action_print = $action ;\n \t\t\tif (defined $opts{-action_extra}) {\n-- \n1.7.8.3\n"},{"id":"183321","messageId":"201201301442.06707.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120130114447.GA9267@server.brlink.eu","subject":"Re: [PATCH v5 1/5] gitweb: prepare git_get_projects_list for use outside 'forks'.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T13:42:03Z","receivedAt":"2012-01-30T13:42:03Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Bernhard R. Link wrote:\n\n> @@ -6066,7 +6069,7 @@ sub git_summary {\n>  \n>  \tif ($check_forks) {\n>  \t\t# find forks of a project\n> -\t\t@forklist = git_get_projects_list($project);\n> +\t\t@forklist = git_get_projects_list($project =~ s/\\.git$//r);\n>  \t\t# filter out forks of forks\n>  \t\t@forklist = filter_forks_from_projects_list(\\@forklist)\n>  \t\t\tif (@forklist);\n> -- \n\nThe '/r' non-destructive modifier for regexp replacement is quite new \ninvention and requires Perl 5.14, while gitweb requires Perl 5.8.x\nsomething.  Please don't use it.\n\nYou can use this instead.\n\n  (my $filter = $project) =~ s/\\.git$//\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183326","messageId":"20120130145538.GA2162@server.brlink.eu","threadId":"29461","inReplyTo":"201201301442.06707.jnareb@gmail.com","subject":"[PATCH v5.5 1/5] gitweb: prepare git_get_projects_list for use outside 'forks'.","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T14:55:38Z","receivedAt":"2012-01-30T14:55:38Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Use of the filter option of git_get_projects_list is currently\nlimited to forks. It hard codes removal of \".git\" suffixes from\nthe filter and assumes the project belonging to the filter directory\nwas already validated to be visible in the project list.\n\nTo make it more generic move the .git suffix removal to the callers\nand add an optional argument to denote visibility verification is\nstill needed.\n\nIf there is a projects list file (GITWEB_LIST) only projects from\nthis list are returned anyway, so no more checks needed.\n\nIf there is no projects list file and the caller requests strict\nchecking (GITWEB_STRICT_EXPORT), do not jump directly to the\ngiven directory but instead do a normal search and filter the\nresults instead.\n\nThe only (hopefully non-existing) effect of GITWEB_STRICT_EXPORT\nwithout GITWEB_LIST is to make sure no project can be viewed without\nalso be found starting from project root. git_get_projects_list without\nthis patch does not enforce this but all callers only call it with\na filter already checked this way. With this parameter a caller\ncan request this check if the filter cannot be checked this way.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n\nChanges since v5:\n\t- don't you use s/.../.../r\n\n gitweb/gitweb.perl |   13 ++++++++-----\n 1 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 9cf7e71..19daabc 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2829,10 +2829,9 @@ sub git_get_project_url_list {\n \n sub git_get_projects_list {\n \tmy $filter = shift || '';\n+\tmy $paranoid = shift;\n \tmy @list;\n \n-\t$filter =~ s/\\.git$//;\n-\n \tif (-d $projects_list) {\n \t\t# search in directory\n \t\tmy $dir = $projects_list;\n@@ -2841,7 +2840,7 @@ sub git_get_projects_list {\n \t\tmy $pfxlen = length(\"$dir\");\n \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n \t\t# when filtering, search only given subdirectory\n-\t\tif ($filter) {\n+\t\tif ($filter and not $paranoid) {\n \t\t\t$dir .= \"/$filter\";\n \t\t\t$dir =~ s!/+$!!;\n \t\t}\n@@ -2866,6 +2865,10 @@ sub git_get_projects_list {\n \t\t\t\t}\n \n \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n+\t\t\t\t# paranoidly only filter here\n+\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n \t\t\t\t# we check related file in $projectroot\n \t\t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n \t\t\t\t\tpush @list, { path => $path };\n@@ -6007,7 +6010,7 @@ sub git_forks {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list($project);\n+\tmy @list = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n \tif (!@list) {\n \t\tdie_error(404, \"No forks found\");\n \t}\n@@ -6066,7 +6069,7 @@ sub git_summary {\n \n \tif ($check_forks) {\n \t\t# find forks of a project\n-\t\t@forklist = git_get_projects_list($project);\n+\t\t@forklist = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n \t\t# filter out forks of forks\n \t\t@forklist = filter_forks_from_projects_list(\\@forklist)\n \t\t\tif (@forklist);\n-- \n1.7.8.3\n"},{"id":"183330","messageId":"201201301640.35843.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120130145538.GA2162@server.brlink.eu","subject":"Re: [PATCH v5.5 1/5] gitweb: prepare git_get_projects_list for use outside 'forks'.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T15:40:34Z","receivedAt":"2012-01-30T15:40:34Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 30 Jul 2012, Bernhard R. Link wrote:\n\n> Use of the filter option of git_get_projects_list is currently\n> limited to forks. It hard codes removal of \".git\" suffixes from\n> the filter and assumes the project belonging to the filter directory\n> was already validated to be visible in the project list.\n> \n> To make it more generic move the .git suffix removal to the callers\n> and add an optional argument to denote visibility verification is\n> still needed.\n\nEven better for patch readability would be to split this patch further,\nwith the first part just moving removal of \".git\" suffix from said\nfunction to callers.\n \n> If there is a projects list file (GITWEB_LIST) only projects from\n> this list are returned anyway, so no more checks needed.\n> \n> If there is no projects list file and the caller requests strict\n> checking (GITWEB_STRICT_EXPORT), do not jump directly to the\n> given directory but instead do a normal search and filter the\n> results instead.\n> \n> The only (hopefully non-existing) effect of GITWEB_STRICT_EXPORT\n> without GITWEB_LIST is to make sure no project can be viewed without\n> also be found starting from project root. git_get_projects_list without\n> this patch does not enforce this but all callers only call it with\n> a filter already checked this way. With this parameter a caller\n> can request this check if the filter cannot be checked this way.\n\nO.K. now I see where the \"paranoid mode\" might make difference: if\none of intermediate directories in $project_filter subdirectory has\nsearch/access permission ('x' bit) but is not readable ('r' bit),\nthen gitweb would show nothing in $strict_export mode, but scan from\n\"$projects_list/$project_filter\" in non-strict mode.\n\nPerhaps there are other cases...\n \n> @@ -2841,7 +2840,7 @@ sub git_get_projects_list {\n>  \t\tmy $pfxlen = length(\"$dir\");\n>  \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n>  \t\t# when filtering, search only given subdirectory\n> -\t\tif ($filter) {\n> +\t\tif ($filter and not $paranoid) {\n\nHmmmm... ($filter and !$paranoid) or ($filter && !$paranoid)?\nWhich would be more Perl-ish and fit current code style better...\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183331","messageId":"201201301657.12944.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120130114557.GB9267@server.brlink.eu","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T15:57:12Z","receivedAt":"2012-01-30T15:57:12Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 30 Jan 2012, Bernhard R. Link wrote:\n\n> This commit changes the project listing views (project_list,\n> project_index and opml) to limit the output to only projects in a\n> subdirectory if the new optional parameter ?pf=directory name is\n> used.\n\nIt would be nice to have in this or in a separate commit an update\nto get_page_title() for HTML output, and to git_opml() updating\n<title> element in OPML output, so that it mentions that project\nlist is limitied to $project_filter subdirectory.\n\nFor plain text output of git_project_index() nothing really can be\ndone -- there is no title.  Well, we could fiddle with 'filename'\npart of Content-Disposition HTTP header...\n \n> The implementation of the filter reuses the implementation used for\n> the 'forks' action (i.e. listing all projects within that directory\n> from the projects list file (GITWEB_LIST) or only projects in the\n> given subdirectory of the project root directory without a projects\n> list file).\n\nO.K., more detailed description of $strict_export interaction is in\nthat other commit.\n\n> Reusing $project instead of adding a new parameter would have been\n> nicer from a UI point-of-view (including PATH_INFO support) but\n> would complicate the $project validating code that is currently\n> being used to ensure nothing is exported that should not be viewable.\n\nNb. I wonder if we should make it invalid to have both 'project' and\n'project_filter' parameters...\n \n> @@ -994,6 +995,13 @@ sub evaluate_and_validate_params {\n>  \t\t}\n>  \t}\n>  \n> +\tour $project_filter = $input_params{'project_filter'};\n> +\tif (defined $project_filter) {\n> +\t\tif (!validate_pathname($project_filter)) {\n> +\t\t\tdie_error(404, \"Invalid project_filter parameter\");\n> +\t\t}\n> +\t}\n> +\n\nThat accidentally makes \"pf=foo/\" (with trailing slash) invalid.\nOn the other hand being able to assume that $project_filter doesn't\nend in '/' simplifies code a bit.\n\n> @@ -5984,7 +5992,7 @@ sub git_project_list {\n> -\tmy @list = git_get_projects_list();\n> +\tmy @list = git_get_projects_list($project_filter, $strict_export);\n\n>  sub git_project_index {\n> -\tmy @projects = git_get_projects_list();\n> +\tmy @projects = git_get_projects_list($project_filter, $strict_export);\n\n>  sub git_opml {\n> -\tmy @list = git_get_projects_list();\n> +\tmy @list = git_get_projects_list($project_filter, $strict_export);\n\nNice!\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183333","messageId":"201201301710.04406.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120130114706.GC9267@server.brlink.eu","subject":"Re: [PATCH 3/5] gitweb: limit links to alternate forms of project_list to active project_filter","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T16:09:51Z","receivedAt":"2012-01-30T16:09:51Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 30 Jan 2012, Bernhard R. Link wrote:\n\n> If project_list action is given a project_filter argument, pass that to\n> TXT and OPML formats.\n\nNice.\n\nThis way [OPML] and [TXT] links provide the same list of projects as\nthe projects_list page they are linked from.\n\n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n> ---\n>  gitweb/gitweb.perl |    6 ++++--\n>  1 files changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 36efc10..e022e11 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3976,9 +3976,11 @@ sub git_footer_html {\n>  \t\t}\n>  \n>  \t} else {\n> -\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n> +\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n> +\t\t                             project_filter => $project_filter),\n>  \t\t              -class => $feed_class}, \"OPML\") . \" \";\n> -\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n> +\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n> +\t\t                             project_filter => $project_filter),\n>  \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n>  \t}\n\nNicely short.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183335","messageId":"20120130162932.GA18773@server.brlink.eu","threadId":"29461","inReplyTo":"201201301640.35843.jnareb@gmail.com","subject":"Re: [PATCH v5.5 1/5] gitweb: prepare git_get_projects_list for use outside 'forks'.","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T16:29:32Z","receivedAt":"2012-01-30T16:29:32Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"* Jakub Narebski <jnareb@gmail.com> [120130 16:40]:\n> Perhaps there are other cases...\n>  \n> > @@ -2841,7 +2840,7 @@ sub git_get_projects_list {\n> >  \t\tmy $pfxlen = length(\"$dir\");\n> >  \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n> >  \t\t# when filtering, search only given subdirectory\n> > -\t\tif ($filter) {\n> > +\t\tif ($filter and not $paranoid) {\n> \n> Hmmmm... ($filter and !$paranoid) or ($filter && !$paranoid)?\n> Which would be more Perl-ish and fit current code style better...\n\nI cannot say what is more perlish, but gitweb.perl seems to contain\nonly the combinations \"and not\" (1 time) and \"&& !\" (8 times).\n\n\tBernhard R. Link\n"},{"id":"183334","messageId":"201201301738.31982.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120130114852.GD9267@server.brlink.eu","subject":"Re: [PATCH v5 4/5] gitweb: show active project_filter in project_list page header","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T16:38:30Z","receivedAt":"2012-01-30T16:38:30Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 30 Jan 2012, Bernhard R. Link wrote:\n\n> In a project_list view show breadcrumbs with the currently active\n> project_filter (and those of parent directories) in the page header.\n\nO.K. (though I'd prefer written it less concise and more clear).\n \n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n> ---\n>  gitweb/gitweb.perl |   14 ++++++++++++++\n>  1 files changed, 14 insertions(+), 0 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index e022e11..dfc79df 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3836,6 +3836,18 @@ sub print_header_links {\n>  \t}\n>  }\n>  \n> +sub print_nav_breadcrumbs_path {\n> +\tmy $dirprefix = undef;\n> +\twhile (my $part = shift) {\n\nHmmm... using agument list directly, without copying it?  Well, all right.\n\n> +\t\t$dirprefix .= \"/\" if defined $dirprefix;\n> +\t\t$dirprefix .= $part;\n> +\t\tprint $cgi->a({-href => href(project => undef,\n> +\t\t                             project_filter => $dirprefix,\n> +\t\t\t\t\t     action=>\"project_list\")},\n\nMinor nitpick: Let's use same whitespace rules for all key-value pairs\n\n  +\t\t\t\t\t     action => \"project_list\")},\n\n\n> +\t\t\t      esc_html($part)) . \" / \";\n> +\t}\n> +}\n> +\n>  sub print_nav_breadcrumbs {\n>  \tmy %opts = @_;\n>  \n> @@ -3854,6 +3866,8 @@ sub print_nav_breadcrumbs {\n>  \t\t\tprint \" / $opts{-action_extra}\";\n>  \t\t}\n>  \t\tprint \"\\n\";\n> +\t} elsif (defined $project_filter) {\n> +\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n>  \t}\n>  }\n\nNice!\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183339","messageId":"201201301810.10072.jnareb@gmail.com","threadId":"29461","inReplyTo":"20120130115046.GE9267@server.brlink.eu","subject":"Re: [PATCH v5 5/5] gitweb: place links to parent directories in page header","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T17:10:08Z","receivedAt":"2012-01-30T17:10:08Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 30 Jan 2012, Bernhard R. Link wrote:\n\n> Change html page headers to not only link the project root and the\n> currently selected project but also the directories in between using\n> project_filter. (Allowing to jump to a list of all projects within\n> that intermediate directory directly and making the project_filter\n> feature visible to users).\n\nNice idea, nice description.\n \n> Signed-off-by: Bernhard R. Link <brlink@debian.org>\n> ---\n>  gitweb/gitweb.perl |    5 ++++-\n>  1 files changed, 4 insertions(+), 1 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index dfc79df..b54ddb9 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3853,7 +3853,10 @@ sub print_nav_breadcrumbs {\n>  \n>  \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n>  \tif (defined $project) {\n> -\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n> +\t\tmy @dirname = split '/', $project;\n> +\t\tmy $projectbasename = pop @dirname;\n> +\t\tprint_nav_breadcrumbs_path(@dirname);\n> +\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n>  \t\tif (defined $action) {\n>  \t\t\tmy $action_print = $action ;\n>  \t\t\tif (defined $opts{-action_extra}) {\n> -- \n\nNice code.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183371","messageId":"20120130200355.GA2584@server.brlink.eu","threadId":"29461","inReplyTo":"201201301657.12944.jnareb@gmail.com","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl@mail.brlink.eu","sentAt":"2012-01-30T20:03:55Z","receivedAt":"2012-01-30T20:03:55Z","isPatch":true,"sender":{"key":"brl@mail.brlink.eu","avatar":null},"body":"* Jakub Narebski <jnareb@gmail.com> [120130 16:56]:\n> On Mon, 30 Jan 2012, Bernhard R. Link wrote:\n> \n> > This commit changes the project listing views (project_list,\n> > project_index and opml) to limit the output to only projects in a\n> > subdirectory if the new optional parameter ?pf=directory name is\n> > used.\n> \n> It would be nice to have in this or in a separate commit an update\n> to get_page_title() for HTML output, and to git_opml() updating\n> <title> element in OPML output, so that it mentions that project\n> list is limitied to $project_filter subdirectory.\n\nIndeed. I overlooked that.\n\n> > Reusing $project instead of adding a new parameter would have been\n> > nicer from a UI point-of-view (including PATH_INFO support) but\n> > would complicate the $project validating code that is currently\n> > being used to ensure nothing is exported that should not be viewable.\n>\n> Nb. I wonder if we should make it invalid to have both 'project' and\n> 'project_filter' parameters...\n\n$project_filter should be ignored when $project is defined which is\nenforced in all but those three actions.\n\naction=project_list gets confused (shows wrong breadcrumbs) if $project\nis defined, but that is unrelated to this changes, so one might to fix\nthat independently.\n\nI'll resend the series as replies to this mail. What to do next? Wait\nforanother explitit Acked-By of those? Or resend it to gitster@pobox.com\nif no new issues are found?\n\n        Bernhard R. Link\n"},{"id":"183372","messageId":"20120130200547.GB2584@server.brlink.eu","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"[PATCH 1/6] gitweb: move hard coded .git suffix out of git_get_projects_list","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:05:47Z","receivedAt":"2012-01-30T20:05:47Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Use of the filter option of git_get_projects_list is currently\nlimited to forks. It hard codes removal of \".git\" suffixes from\nthe filter.\n\nTo make it more generic move the .git suffix removal to the callers.\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n\nChanges to v5.5:\n\t- split first patch in two as suggested by Jakub Narebski\n---\n gitweb/gitweb.perl |    6 ++----\n 1 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 9cf7e71..0ee3290 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2831,8 +2831,6 @@ sub git_get_projects_list {\n \tmy $filter = shift || '';\n \tmy @list;\n \n-\t$filter =~ s/\\.git$//;\n-\n \tif (-d $projects_list) {\n \t\t# search in directory\n \t\tmy $dir = $projects_list;\n@@ -6007,7 +6005,7 @@ sub git_forks {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list($project);\n+\tmy @list = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n \tif (!@list) {\n \t\tdie_error(404, \"No forks found\");\n \t}\n@@ -6066,7 +6064,7 @@ sub git_summary {\n \n \tif ($check_forks) {\n \t\t# find forks of a project\n-\t\t@forklist = git_get_projects_list($project);\n+\t\t@forklist = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n \t\t# filter out forks of forks\n \t\t@forklist = filter_forks_from_projects_list(\\@forklist)\n \t\t\tif (@forklist);\n-- \n1.7.8.3\n"},{"id":"183373","messageId":"20120130200638.GC2584@server.brlink.eu","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"[PATCH v6 2/6] gitweb: prepare git_get_projects_list for use outside 'forks'.","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:06:38Z","receivedAt":"2012-01-30T20:06:38Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Use of the filter option of git_get_projects_list is currently limited\nto forks. It currently assumes the project belonging to the filter\ndirectory was already validated to be visible in the project list.\n\nTo make it more generic add an optional argument to denote visibility\nverification is still needed.\n\nIf there is a projects list file (GITWEB_LIST) only projects from\nthis list are returned anyway, so no more checks needed.\n\nIf there is no projects list file and the caller requests strict\nchecking (GITWEB_STRICT_EXPORT), do not jump directly to the\ngiven directory but instead do a normal search and filter the\nresults instead.\n\nThe only effect of GITWEB_STRICT_EXPORT without GITWEB_LIST is to make\nsure no project can be viewed without also be found starting from\nproject root. git_get_projects_list without this patch does not enforce\nthis but all callers only call it with a filter already checked this\nway. With this parameter a caller can request this check if the filter\ncannot be checked this way.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n---\n\nChanges to v5:\n\t- split first patch in two as suggested by Jakub Narebski\n\t- replace \"and not\" with the more common \"&& !\"\n---\n gitweb/gitweb.perl |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 0ee3290..9a296e2 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2829,6 +2829,7 @@ sub git_get_project_url_list {\n \n sub git_get_projects_list {\n \tmy $filter = shift || '';\n+\tmy $paranoid = shift;\n \tmy @list;\n \n \tif (-d $projects_list) {\n@@ -2839,7 +2840,7 @@ sub git_get_projects_list {\n \t\tmy $pfxlen = length(\"$dir\");\n \t\tmy $pfxdepth = ($dir =~ tr!/!!);\n \t\t# when filtering, search only given subdirectory\n-\t\tif ($filter) {\n+\t\tif ($filter && !$paranoid) {\n \t\t\t$dir .= \"/$filter\";\n \t\t\t$dir =~ s!/+$!!;\n \t\t}\n@@ -2864,6 +2865,10 @@ sub git_get_projects_list {\n \t\t\t\t}\n \n \t\t\t\tmy $path = substr($File::Find::name, $pfxlen + 1);\n+\t\t\t\t# paranoidly only filter here\n+\t\t\t\tif ($paranoid && $filter && $path !~ m!^\\Q$filter\\E/!) {\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n \t\t\t\t# we check related file in $projectroot\n \t\t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n \t\t\t\t\tpush @list, { path => $path };\n-- \n1.7.8.3\n"},{"id":"183374","messageId":"20120130200737.GD2584@server.brlink.eu","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"[PATCH v6 3/6] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:07:37Z","receivedAt":"2012-01-30T20:07:37Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"This commit changes the project listing views (project_list,\nproject_index and opml) to limit the output to only projects in a\nsubdirectory if the new optional parameter ?pf=directory name is\nused.\n\nThe implementation of the filter reuses the implementation used for\nthe 'forks' action (i.e. listing all projects within that directory\nfrom the projects list file (GITWEB_LIST) or only projects in the\ngiven subdirectory of the project root directory without a projects\nlist file).\n\nReusing $project instead of adding a new parameter would have been\nnicer from a UI point-of-view (including PATH_INFO support) but\nwould complicate the $project validating code that is currently\nbeing used to ensure nothing is exported that should not be viewable.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n\n---\nchanged since v5.5:\n\t- change page titles to show what directory it is limited to\n---\n gitweb/gitweb.perl |   31 +++++++++++++++++++++++++------\n 1 files changed, 25 insertions(+), 6 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 9a296e2..b895f4c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -760,6 +760,7 @@ our @cgi_param_mapping = (\n \tsearch_use_regexp => \"sr\",\n \tctag => \"by_tag\",\n \tdiff_style => \"ds\",\n+\tproject_filter => \"pf\",\n \t# this must be last entry (for manipulation from JavaScript)\n \tjavascript => \"js\"\n );\n@@ -976,7 +977,7 @@ sub evaluate_path_info {\n \n our ($action, $project, $file_name, $file_parent, $hash, $hash_parent, $hash_base,\n      $hash_parent_base, @extra_options, $page, $searchtype, $search_use_regexp,\n-     $searchtext, $search_regexp);\n+     $searchtext, $search_regexp, $project_filter);\n sub evaluate_and_validate_params {\n \tour $action = $input_params{'action'};\n \tif (defined $action) {\n@@ -994,6 +995,13 @@ sub evaluate_and_validate_params {\n \t\t}\n \t}\n \n+\tour $project_filter = $input_params{'project_filter'};\n+\tif (defined $project_filter) {\n+\t\tif (!validate_pathname($project_filter)) {\n+\t\t\tdie_error(404, \"Invalid project_filter parameter\");\n+\t\t}\n+\t}\n+\n \tour $file_name = $input_params{'file_name'};\n \tif (defined $file_name) {\n \t\tif (!validate_pathname($file_name)) {\n@@ -3734,7 +3742,12 @@ sub run_highlighter {\n sub get_page_title {\n \tmy $title = to_utf8($site_name);\n \n-\treturn $title unless (defined $project);\n+\tunless (defined $project) {\n+\t\tif (defined $project_filter) {\n+\t\t\t$title .= \" - \" . to_utf8($project_filter);\n+\t\t}\n+\t\treturn $title;\n+\t}\n \t$title .= \" - \" . to_utf8($project);\n \n \treturn $title unless (defined $action);\n@@ -5984,7 +5997,7 @@ sub git_project_list {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -6023,7 +6036,7 @@ sub git_forks {\n }\n \n sub git_project_index {\n-\tmy @projects = git_get_projects_list();\n+\tmy @projects = git_get_projects_list($project_filter, $strict_export);\n \tif (!@projects) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -7860,7 +7873,7 @@ sub git_atom {\n }\n \n sub git_opml {\n-\tmy @list = git_get_projects_list();\n+\tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n \t\tdie_error(404, \"No projects found\");\n \t}\n@@ -7871,11 +7884,17 @@ sub git_opml {\n \t\t-content_disposition => 'inline; filename=\"opml.xml\"');\n \n \tmy $title = esc_html($site_name);\n+\tmy $filter = \" within subdirectory \";\n+\tif (defined $project_filter) {\n+\t\t$filter .= esc_html($project_filter);\n+\t} else {\n+\t\t$filter = \"\";\n+\t}\n \tprint <<XML;\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <opml version=\"1.0\">\n <head>\n-  <title>$title OPML Export</title>\n+  <title>$title OPML Export$filter</title>\n </head>\n <body>\n <outline text=\"git RSS feeds\">\n-- \n1.7.8.3\n"},{"id":"183375","messageId":"20120130200900.GE2584@server.brlink.eu","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"[PATCH v6 4/6] gitweb: limit links to alternate forms of project_list to active project_filter","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:09:00Z","receivedAt":"2012-01-30T20:09:00Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"If project_list action is given a project_filter argument, pass that to\nTXT and OPML formats.\n\nThis way [OPML] and [TXT] links provide the same list of projects as\nthe projects_list page they are linked from.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n\n---\n\nChanges since v5:\n\tadd additional description paragraph from Jakub Narebski\n---\n gitweb/gitweb.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b895f4c..9299504 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3981,9 +3981,11 @@ sub git_footer_html {\n \t\t}\n \n \t} else {\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"opml\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"OPML\") . \" \";\n-\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\"),\n+\t\tprint $cgi->a({-href => href(project=>undef, action=>\"project_index\",\n+\t\t                             project_filter => $project_filter),\n \t\t              -class => $feed_class}, \"TXT\") . \"\\n\";\n \t}\n \tprint \"</div>\\n\"; # class=\"page_footer\"\n-- \n1.7.8.3\n"},{"id":"183376","messageId":"20120130200943.GF2584@server.brlink.eu","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"[PATCH v6 5/6] gitweb: show active project_filter in project_list page header","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:09:43Z","receivedAt":"2012-01-30T20:09:43Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"In the page header of a project_list view with a project_filter\ngiven show breadcrumbs in the page headers showing which directory\nit is currently limited to and also containing links to the parent\ndirectories.\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\n\n---\nChanges since v5:\n\t- improve description, better?\n\t- equalize whitespace\n---\n gitweb/gitweb.perl |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 9299504..27db84e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3841,6 +3841,18 @@ sub print_header_links {\n \t}\n }\n \n+sub print_nav_breadcrumbs_path {\n+\tmy $dirprefix = undef;\n+\twhile (my $part = shift) {\n+\t\t$dirprefix .= \"/\" if defined $dirprefix;\n+\t\t$dirprefix .= $part;\n+\t\tprint $cgi->a({-href => href(project => undef,\n+\t\t                             project_filter => $dirprefix,\n+\t\t                             action => \"project_list\")},\n+\t\t\t      esc_html($part)) . \" / \";\n+\t}\n+}\n+\n sub print_nav_breadcrumbs {\n \tmy %opts = @_;\n \n@@ -3859,6 +3871,8 @@ sub print_nav_breadcrumbs {\n \t\t\tprint \" / $opts{-action_extra}\";\n \t\t}\n \t\tprint \"\\n\";\n+\t} elsif (defined $project_filter) {\n+\t\tprint_nav_breadcrumbs_path(split '/', $project_filter);\n \t}\n }\n \n-- \n1.7.8.3\n"},{"id":"183377","messageId":"20120130201023.GG2584@server.brlink.eu","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"[PATCH v6 6/6] gitweb: place links to parent directories in page header","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:10:23Z","receivedAt":"2012-01-30T20:10:23Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"Change html page headers to not only link the project root and the\ncurrently selected project but also the directories in between using\nproject_filter. (Allowing to jump to a list of all projects within\nthat intermediate directory directly and making the project_filter\nfeature visible to users).\n\nSigned-off-by: Bernhard R. Link <brlink@debian.org>\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n---\n\nWhat are the rules for copying Acked-by? This change and it's\ndescription are unchanged since v4 which got a Acked-by. Do\nI keep that Acked-by if only the other patches change or do I reset\nit?\n---\n gitweb/gitweb.perl |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 27db84e..c45e0e7 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3858,7 +3858,10 @@ sub print_nav_breadcrumbs {\n \n \tprint $cgi->a({-href => esc_url($home_link)}, $home_link_str) . \" / \";\n \tif (defined $project) {\n-\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($project));\n+\t\tmy @dirname = split '/', $project;\n+\t\tmy $projectbasename = pop @dirname;\n+\t\tprint_nav_breadcrumbs_path(@dirname);\n+\t\tprint $cgi->a({-href => href(action=>\"summary\")}, esc_html($projectbasename));\n \t\tif (defined $action) {\n \t\t\tmy $action_print = $action ;\n \t\t\tif (defined $opts{-action_extra}) {\n-- \n1.7.8.3\n"},{"id":"183380","messageId":"7v39axaq0v.fsf@alter.siamese.dyndns.org","threadId":"29461","inReplyTo":"20120130200355.GA2584@server.brlink.eu","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-30T20:34:08Z","receivedAt":"2012-01-30T20:34:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Bernhard R. Link\" <brl@mail.brlink.eu> writes:\n\n> I'll resend the series as replies to this mail.\n\nThanks; I'll queue them in 'pu' for now (if Jakub wants to Ack the pieces,\nI'll amend them).\n\nRegarding the first patch in the series, while it may be a valid perl to\nintroduce a new variable, assign to it and then munge its contents with\ns///, all inside a parameter list of a function call, it is doing a bit\ntoo much and makes it hard to see if the variable may or may not later be\nused in the same scope (in this case, it is not).\n\nI am tempted to squash the following in.\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b764d51..f215eaa 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -6003,7 +6003,8 @@ sub git_forks {\n \t\tdie_error(400, \"Unknown order parameter\");\n \t}\n \n-\tmy @list = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n+\tmy ($filter = $project) =~ s/\\.git$//;\n+\tmy @list = git_get_projects_list($filter);\n \tif (!@list) {\n \t\tdie_error(404, \"No forks found\");\n \t}\n@@ -6062,7 +6063,8 @@ sub git_summary {\n \n \tif ($check_forks) {\n \t\t# find forks of a project\n-\t\t@forklist = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n+\t\tmy ($filter = $project) =~ s/\\.git$//;\n+\t\t@forklist = git_get_projects_list($filter);\n \t\t# filter out forks of forks\n \t\t@forklist = filter_forks_from_projects_list(\\@forklist)\n \t\t\tif (@forklist);\n-- \n1.7.9.154.g413bff\n"},{"id":"183382","messageId":"201201302148.03909.jnareb@gmail.com","threadId":"29461","inReplyTo":"7v39axaq0v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-01-30T20:48:03Z","receivedAt":"2012-01-30T20:48:03Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 30 Jan 2012, Junio C Hamano wrote:\n> \"Bernhard R. Link\" <brl@mail.brlink.eu> writes:\n> \n> > I'll resend the series as replies to this mail.\n> \n> Thanks; I'll queue them in 'pu' for now (if Jakub wants to Ack the pieces,\n> I'll amend them).\n\nYou can add Ack from me for the whole series.\n\n> Regarding the first patch in the series, while it may be a valid perl to\n> introduce a new variable, assign to it and then munge its contents with\n> s///, all inside a parameter list of a function call, it is doing a bit\n> too much and makes it hard to see if the variable may or may not later be\n> used in the same scope (in this case, it is not).\n> \n> I am tempted to squash the following in.\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index b764d51..f215eaa 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -6003,7 +6003,8 @@ sub git_forks {\n>  \t\tdie_error(400, \"Unknown order parameter\");\n>  \t}\n>  \n> -\tmy @list = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n> +\tmy ($filter = $project) =~ s/\\.git$//;\n\nThis doesn't work: it is syntax error:\n\n  Can't declare scalar assignment in \"my\"\n  \nIt has to be either\n\n +\t(my $filter = $project) =~ s/\\.git$//;\n\nor\n\n +\tmy $filter = $project;\n +\t$filter =~ s/\\.git$//;\n\n-- \nJakub Narebski\nPoland\n"},{"id":"183383","messageId":"20120130204831.GA4701@server.brlink.eu","threadId":"29461","inReplyTo":"7v39axaq0v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-01-30T20:48:31Z","receivedAt":"2012-01-30T20:48:31Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"* Junio C Hamano <gitster@pobox.com> [120130 21:34]:\n> \"Bernhard R. Link\" <brl@mail.brlink.eu> writes:\n> Regarding the first patch in the series, while it may be a valid perl to\n> introduce a new variable, assign to it and then munge its contents with\n> s///, all inside a parameter list of a function call, it is doing a bit\n> too much and makes it hard to see if the variable may or may not later be\n> used in the same scope (in this case, it is not).\n\nI'm fine either way.\nI had interpreted <201201301442.06707.jnareb@gmail.com> to be meant this\nway, but rereading it I am not sure it was meant this way at all.\nI thought this was to express that those variables are not used outside\nthis scope.\n\n        Bernhard R. Link\n"},{"id":"183386","messageId":"7vty3caoku.fsf@alter.siamese.dyndns.org","threadId":"29461","inReplyTo":"201201302148.03909.jnareb@gmail.com","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-30T21:05:21Z","receivedAt":"2012-01-30T21:05:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n>> -\tmy @list = git_get_projects_list((my $filter = $project) =~ s/\\.git$//);\n>> +\tmy ($filter = $project) =~ s/\\.git$//;\n>\n> This doesn't work: it is syntax error:\n>\n>   Can't declare scalar assignment in \"my\"\n>   \n> It has to be either\n>\n>  +\t(my $filter = $project) =~ s/\\.git$//;\n\nSorry, that is what I meant.\n"},{"id":"183387","messageId":"7vpqe0aoev.fsf@alter.siamese.dyndns.org","threadId":"29461","inReplyTo":"201201302148.03909.jnareb@gmail.com","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-30T21:08:56Z","receivedAt":"2012-01-30T21:08:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> On Mon, 30 Jan 2012, Junio C Hamano wrote:\n>> \"Bernhard R. Link\" <brl@mail.brlink.eu> writes:\n>> \n>> > I'll resend the series as replies to this mail.\n>> \n>> Thanks; I'll queue them in 'pu' for now (if Jakub wants to Ack the pieces,\n>> I'll amend them).\n>\n> You can add Ack from me for the whole series.\n\nOk, amended and queued (but not pushed out yet).\n"},{"id":"183482","messageId":"20120201165902.GA14706@server.brlink.eu","threadId":"29461","inReplyTo":"7v39axaq0v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2012-02-01T16:59:02Z","receivedAt":"2012-02-01T16:59:02Z","isPatch":true,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"* Junio C Hamano <gitster@pobox.com> [120130 21:34]:\n> Thanks; I'll queue them in 'pu' for now (if Jakub wants to Ack the pieces,\n> I'll amend them).\n>\n> Regarding the first patch in the series, while it may be a valid perl to\n> introduce a new variable, assign to it and then munge its contents with\n> s///, all inside a parameter list of a function call, it is doing a bit\n> too much and makes it hard to see if the variable may or may not later be\n> used in the same scope (in this case, it is not).\n>\n> I am tempted to squash the following in.\n\nLook liks a change like that is actually needed. I made the mistake of\nassuming\n  (my $filter = $project) =~ s/\\.git$//;\nwas the same like\n  $project =~ s/\\.git$//r;\nbut the latter returns the changed string, the former returns the number\nof arguments. (So it looks for forks in a directory named '1').\n\n(Should have tested it again after this last change)...\n\nCan you squash it in (with the correction of Jakub Narebski), or do you\nprefer a new patch?\n\n        Bernhard R. Link\n"},{"id":"183496","messageId":"7vpqdy2rzd.fsf@alter.siamese.dyndns.org","threadId":"29461","inReplyTo":"20120201165902.GA14706@server.brlink.eu","subject":"Re: [PATCH v5 2/5] gitweb: add project_filter to limit project list to a subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-01T20:55:50Z","receivedAt":"2012-02-01T20:55:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Bernhard R. Link\" <brl+git@mail.brlink.eu> writes:\n\n> Look liks a change like that is actually needed...\n> ... So it looks for forks in a directory named '1'\n\nYeah, that was exactly what was causing failures in 9502.  Fixed locally\nso no further action is required.\n\nThanks.\n"}]}