{"thread":{"id":"29291","subject":"[PATCH] gitweb: accept trailing \"/\" in $project_list","startedAt":"2012-01-04T10:07:45Z","lastAt":"2012-01-04T17:51:14Z","messageCount":2,"participants":["Matthieu Moy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"181916","messageId":"1325671665-16847-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"29291","inReplyTo":null,"subject":"[PATCH] gitweb: accept trailing \"/\" in $project_list","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-01-04T10:07:45Z","receivedAt":"2012-01-04T10:07:45Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"The current code is removing the trailing \"/\", but computing the string\nlength on the previous value, i.e. with the trailing \"/\". Later in the\ncode, we do\n\n  my $path = substr($File::Find::name, $pfxlen + 1);\n\nAnd the \"$pfxlen + 1\" is supposed to mean \"the length of the prefix, plus\n1 for the / separating the prefix and the path\", but with an incorrect\n$pfxlen, this basically eats the first character of the path, and yields\n\"404 - No projects found\".\n\nWhile we're there, also fix $pfxdepth to use $dir, although a change of 1\nin the depth shouldn't really matter.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nI'm not fluent in Perl, and not familiar at all with gitweb, but this\nsounds a rather obvious (too obvious?) fix.\n\n gitweb/gitweb.perl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f80f259..4512b89 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2835,8 +2835,8 @@ sub git_get_projects_list {\n \t\tmy $dir = $projects_list;\n \t\t# remove the trailing \"/\"\n \t\t$dir =~ s!/+$!!;\n-\t\tmy $pfxlen = length(\"$projects_list\");\n-\t\tmy $pfxdepth = ($projects_list =~ tr!/!!);\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\t\t$dir .= \"/$filter\";\n-- \n1.7.8.384.g29bb3\n"},{"id":"181932","messageId":"7v39bvqru5.fsf@alter.siamese.dyndns.org","threadId":"29291","inReplyTo":"1325671665-16847-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] gitweb: accept trailing \"/\" in $project_list","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-04T17:51:14Z","receivedAt":"2012-01-04T17:51:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> The current code is removing the trailing \"/\", but computing the string\n> length on the previous value, i.e. with the trailing \"/\". Later in the\n> code, we do\n>\n>   my $path = substr($File::Find::name, $pfxlen + 1);\n>\n> And the \"$pfxlen + 1\" is supposed to mean \"the length of the prefix, plus\n> 1 for the / separating the prefix and the path\", but with an incorrect\n> $pfxlen, this basically eats the first character of the path, and yields\n> \"404 - No projects found\".\n>\n> While we're there, also fix $pfxdepth to use $dir, although a change of 1\n> in the depth shouldn't really matter.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n> I'm not fluent in Perl, and not familiar at all with gitweb, but this\n> sounds a rather obvious (too obvious?) fix.\n\nYeah, probably not many people use $project_maxdepth with a meaningful\nvalue.\n"}]}