+sub get_file_owner {
+ my $path = shift;
+
+ my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
+ my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
+ if (!defined $gcos) {
+ return undef;
+ }
+ my $owner = $gcos;
+ $owner =~ s/[,;].*$//;
+ return $owner;
+}
+
+sub git_project_list {
+ my @list;
+
+ if (-d $projects_list) {
+ # search in directory
+ my $dir = $projects_list;
+ opendir my $dh, $dir || return undef;
+ while (my $dir = readdir($dh)) {
+ if (-e "$projectroot/$dir/HEAD") {
+ my $pr = {
+ path => $dir,
+ };
+ push @list, $pr
+ }
+ }
+ closedir($dh);
+ } elsif (-f $projects_list) {
+ # read from file:
+ # 'git/git.git:Linus Torvalds'
+ # 'linux/hotplug/udev.git'
+ open my $fd , $projects_list || return undef;
+ while (my $line = <$fd>) {
+ chomp $line;
+ my ($path, $owner) = split ':', $line;
+ if (!defined $path) {
+ next;
+ }
+ if (-e "$projectroot/$path/HEAD") {
+ my $pr = {
+ path => $path,
+ owner => $owner,
+ };
+ push @list, $pr
+ }
+ }
+ close $fd;
+ }
+
+ if (!@list) {
+ die_error(undef, "No project found.");
+ }
+ @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
+
+ git_header_html();
+ if (-f $home_text) {
+ print "<div class=\"index_include\">\n";
+ open (my $fd, $home_text);
+ print <$fd>;
+ close $fd;
+ print "</div>\n";
+ }
+ print "<div class=\"page_body\"><br/>\n" .
+ "<table cellspacing=\"0\">\n" .
+ "<tr>\n" .
+ "<th>Project</th>\n" .
+ "<th>Description</th>\n" .
+ "<th>Owner</th>\n" .
+ "<th>last change</th>\n" .
+ "<th></th>\n" .
+ "</tr>\n";
+ foreach my $pr (@list) {
+ my %proj = %$pr;
+ my $head = git_read_hash("$proj{'path'}/HEAD");
+ if (!defined $head) {
+ next;
+ }
+ $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
+ $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj{'path'}/objects";
+ my %co = git_read_commit($head);
+ if (!%co) {
+ next;
+ }
+ my $descr = git_read_description($proj{'path'}) || "";
+ # get directory owner if not already specified
+ if (!defined $proj{'owner'}) {
+ $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || "";
+ }
+ print "<tr>\n" .
+ "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, escapeHTML($proj{'path'})) . "</td>\n" .
+ "<td>$descr</td>\n" .
+ "<td><i>$proj{'owner'}</i></td>\n";
+ my $colored_age;
+ if ($co{'age'} < 60*60*2) {
+ $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>";
+ } elsif ($co{'age'} < 60*60*24*2) {
+ $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>";
+ } else {
+ $colored_age = "<i>$co{'age_string'}</i>";
+ }
+ print "<td>$colored_age</td>\n" .
+ "<td class=\"link\">" .
+ $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, "summary") .
+ " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") .
+ " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=tree"}, "tree") .
+ "</td>\n" .
+ "</tr>\n";
+ }
+ print "</table>\n" .
+ "<br/>\n" .
+ "</div>\n";
+ git_footer_html();