@matheusbsbs / matheus-bagliano / commits / 83ee94c12c
Fork 0

gitweb: minimally fix "fork" support.

A forked project is defined to be $projname/$forkname.git for $projname.git; the code did not check this correctly and mistook $projname/.git to be a fork of itself. This minimally fixes the breakage. Also forks were not checked when index.aux file was in use. Listing the forked ones in index.aux would show them also on the toplevel index which may go against the hierarchical nature of forks, but again this is a minimal fix to whip it in a better shape suitable to be in the 'master' branch. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 7, 2006 at 22:37 UTC 83ee94c12ca16ef020f3d71eda34b6559ed6dc67
1 file changed +20 -2
gitweb/gitweb.perl
+20 -2
@@ -962,6 +962,17 @@ sub git_get_projects_list {
962 if (!defined $path) {
963 next;
964 }
965 + if ($filter ne '') {
966 + # looking for forks;
967 + my $pfx = substr($path, 0, length($filter));
968 + if ($pfx ne $filter) {
969 + next;
970 + }
971 + my $sfx = substr($path, length($filter));
972 + if ($sfx !~ /^\/.*\.git$/) {
973 + next;
974 + }
975 + }
976 if (check_export_ok("$projectroot/$path")) {
977 my $pr = {
978 path => $path,
@@ -2230,8 +2241,14 @@ sub git_project_list_body {
2241 }
2242 if ($check_forks) {
2243 my $pname = $pr->{'path'};
2233 - $pname =~ s/\.git$//;
2234 - $pr->{'forks'} = -d "$projectroot/$pname";
2244 + if (($pname =~ s/\.git$//) &&
2245 + ($pname !~ /\/$/) &&
2246 + (-d "$projectroot/$pname")) {
2247 + $pr->{'forks'} = "-d $projectroot/$pname";
2248 + }
2249 + else {
2250 + $pr->{'forks'} = 0;
2251 + }
2252 }
2253 push @projects, $pr;
2254 }
@@ -2297,6 +2314,7 @@ sub git_project_list_body {
2314 if ($check_forks) {
2315 print "<td>";
2316 if ($pr->{'forks'}) {
2317 + print "<!-- $pr->{'forks'} -->\n";
2318 print $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "+");
2319 }
2320 print "</td>\n";