{"thread":{"id":"7549","subject":"[PATCH(resend)] gitweb: Allow forks with project list file","startedAt":"2007-04-06T21:58:11Z","lastAt":"2007-04-06T21:58:11Z","messageCount":1,"participants":["Frank Lichtenheld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38809","messageId":"11758966911292-git-send-email-frank@lichtenheld.de","threadId":"7549","inReplyTo":null,"subject":"[PATCH(resend)] gitweb: Allow forks with project list file","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-04-06T21:58:11Z","receivedAt":"2007-04-06T21:58:11Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"Make it possible to use the forks feature even when\nreading the list of projects from a file, by creating\na list of known prefixes as we go. Forks have to be\nlisted after the main project in order to be recognised\nas such.\n\nSigned-off-by: Frank Lichtenheld <frank@lichtenheld.de>\n---\n gitweb/gitweb.perl |   34 +++++++++++++++++++++++++++-------\n 1 files changed, 27 insertions(+), 7 deletions(-)\n\nProbably got lost in the noise since I never received a comment on it.\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex ea49156..379c89c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -176,8 +176,8 @@ our %feature = (\n \t# projects matching $projname/*.git will not be shown in the main\n \t# projects list, instead a '+' mark will be added to $projname\n \t# there and a 'forks' view will be enabled for the project, listing\n-\t# all the forks. This feature is supported only if project list\n-\t# is taken from a directory, not file.\n+\t# all the forks. If project list is taken from a file, forks have\n+\t# to be listed after the main project.\n \n \t# To enable system wide have in $GITWEB_CONFIG\n \t# $feature{'forks'}{'default'} = [1];\n@@ -1047,6 +1047,8 @@ sub git_get_projects_list {\n \t$filter ||= '';\n \t$filter =~ s/\\.git$//;\n \n+\tmy ($check_forks) = gitweb_check_feature('forks');\n+\n \tif (-d $projects_list) {\n \t\t# search in directory\n \t\tmy $dir = $projects_list . ($filter ? \"/$filter\" : '');\n@@ -1054,8 +1056,6 @@ sub git_get_projects_list {\n \t\t$dir =~ s!/+$!!;\n \t\tmy $pfxlen = length(\"$dir\");\n \n-\t\tmy ($check_forks) = gitweb_check_feature('forks');\n-\n \t\tFile::Find::find({\n \t\t\tfollow_fast => 1, # follow symbolic links\n \t\t\tdangling_symlinks => 0, # ignore dangling symlinks, silently\n@@ -1081,7 +1081,9 @@ sub git_get_projects_list {\n \t\t# 'git%2Fgit.git Linus+Torvalds'\n \t\t# 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'\n \t\t# 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'\n+\t\tmy %paths;\n \t\topen my ($fd), $projects_list or return;\n+\tPROJECT:\n \t\twhile (my $line = <$fd>) {\n \t\t\tchomp $line;\n \t\t\tmy ($path, $owner) = split ' ', $line;\n@@ -1094,11 +1096,27 @@ sub git_get_projects_list {\n \t\t\t\t# looking for forks;\n \t\t\t\tmy $pfx = substr($path, 0, length($filter));\n \t\t\t\tif ($pfx ne $filter) {\n-\t\t\t\t\tnext;\n+\t\t\t\t\tnext PROJECT;\n \t\t\t\t}\n \t\t\t\tmy $sfx = substr($path, length($filter));\n \t\t\t\tif ($sfx !~ /^\\/.*\\.git$/) {\n-\t\t\t\t\tnext;\n+\t\t\t\t\tnext PROJECT;\n+\t\t\t\t}\n+\t\t\t} elsif ($check_forks) {\n+\t\t\tPATH:\n+\t\t\t\tforeach my $filter (keys %paths) {\n+\t\t\t\t\t# looking for forks;\n+\t\t\t\t\tmy $pfx = substr($path, 0, length($filter));\n+\t\t\t\t\tif ($pfx ne $filter) {\n+\t\t\t\t\t\tnext PATH;\n+\t\t\t\t\t}\n+\t\t\t\t\tmy $sfx = substr($path, length($filter));\n+\t\t\t\t\tif ($sfx !~ /^\\/.*\\.git$/) {\n+\t\t\t\t\t\tnext PATH;\n+\t\t\t\t\t}\n+\t\t\t\t\t# is a fork, don't include it in\n+\t\t\t\t\t# the list\n+\t\t\t\t\tnext PROJECT;\n \t\t\t\t}\n \t\t\t}\n \t\t\tif (check_export_ok(\"$projectroot/$path\")) {\n@@ -1106,7 +1124,9 @@ sub git_get_projects_list {\n \t\t\t\t\tpath => $path,\n \t\t\t\t\towner => to_utf8($owner),\n \t\t\t\t};\n-\t\t\t\tpush @list, $pr\n+\t\t\t\tpush @list, $pr;\n+\t\t\t\t(my $forks_path = $path) =~ s/\\.git$//;\n+\t\t\t\t$paths{$forks_path}++;\n \t\t\t}\n \t\t}\n \t\tclose $fd;\n-- \n1.5.1\n"}]}