# gitweb - simple web interface to track changes in git repositories
#
-# (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
-# (C) 2005, Christian Gierke <ch@gierke.de>
+# (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
+# (C) 2005, Christian Gierke
#
# This program is licensed under the GPLv2
binmode STDOUT, ':utf8';
my $cgi = new CGI;
-my $version = "260";
+my $version = "265";
my $my_url = $cgi->url();
my $my_uri = $cgi->url(-absolute => 1);
my $rss_link = "";
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
-<!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> -->
+<!-- git web interface v$version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="robots" content="index, nofollow"/>
<title>$title</title>
$rss_link
<style type="text/css">
-body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
+body {
+ font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px;
+ margin:10px; background-color:#ffffff; color:#000000;
+}
a { color:#0000cc; }
a:hover, a:visited, a:active { color:#880000; }
div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
return $type;
}
+sub git_read_head {
+ my $project = shift;
+ my $oENV = $ENV{'GIT_DIR'};
+ my $retval = undef;
+ $ENV{'GIT_DIR'} = "$projectroot/$project";
+ if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") {
+ my $head = <$fd>;
+ close $fd;
+ if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
+ $retval = $1;
+ }
+ }
+ if (defined $oENV) {
+ $ENV{'GIT_DIR'} = $oENV;
+ }
+ return $retval;
+}
+
sub git_read_hash {
my $path = shift;
};
foreach my $title (@commit_lines) {
+ $title =~ s/^ //;
if ($title ne "") {
$co{'title'} = chop_str($title, 80, 5);
# remove leading stuff of merges to make the interesting part visible
}
my $owner = $gcos;
$owner =~ s/[,;].*$//;
- return $owner;
+ return decode("utf8", $owner, Encode::FB_DEFAULT);
}
sub git_read_projects {
if (-e "$projectroot/$path/HEAD") {
my $pr = {
path => $path,
- owner => $owner,
+ owner => decode("utf8", $owner, Encode::FB_DEFAULT),
};
push @list, $pr
}
die_error(undef, "No project found.");
}
foreach my $pr (@list) {
- my $head = git_read_hash("$pr->{'path'}/HEAD");
+ my $head = git_read_head($pr->{'path'});
if (!defined $head) {
next;
}
# c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
open my $fd, "$projectroot/$project/info/refs" or return;
while (my $line = <$fd>) {
+ chomp($line);
if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\^]+)/) {
if (defined $refs{$1}) {
$refs{$1} .= " / $2";
sub git_summary {
my $descr = git_read_description($project) || "none";
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
my %co = git_read_commit($head);
my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
$pr = unescape($pr);
$ow = unescape($ow);
if ($pr eq $project) {
- $owner = $ow;
+ $owner = decode("utf8", $ow, Encode::FB_DEFAULT);
last;
}
}
"<tr><td>owner</td><td>$owner</td></tr>\n" .
"<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
"</table>\n";
- open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
+ open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_head($project) or die_error(undef, "Open failed.");
my (@revlist) = map { chomp; $_ } <$fd>;
close $fd;
print "<div>\n" .
}
sub git_tag {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
git_header_html();
print "<div class=\"page_nav\">\n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
}
sub git_tags {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
git_header_html();
print "<div class=\"page_nav\">\n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
}
sub git_heads {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
git_header_html();
print "<div class=\"page_nav\">\n" .
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
sub git_blob {
if (!defined $hash && defined $file_name) {
- my $base = $hash_base || git_read_hash("$project/HEAD");
+ my $base = $hash_base || git_read_head($project);
$hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
}
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
sub git_tree {
if (!defined $hash) {
- $hash = git_read_hash("$project/HEAD");
+ $hash = git_read_head($project);
if (defined $file_name) {
- my $base = $hash_base || git_read_hash("$project/HEAD");
+ my $base = $hash_base || $hash;
$hash = git_get_hash_by_path($base, $file_name, "tree");
}
if (!defined $hash_base) {
- $hash_base = git_read_hash("$project/HEAD");
+ $hash_base = $hash;
}
}
$/ = "\0";
sub git_rss {
# http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
- open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed.");
+ open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_head($project) or die_error(undef, "Open failed.");
my (@revlist) = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading rev-list failed.");
print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
foreach my $pr (@list) {
my %proj = %$pr;
- my $head = git_read_hash("$proj{'path'}/HEAD");
+ my $head = git_read_head($proj{'path'});
if (!defined $head) {
next;
}
}
sub git_log {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
if (!defined $hash) {
$hash = $head;
}
}
my $refs = read_info_ref();
my $ref = "";
- if (defined $refs->{$hash}) {
- $ref = " <span class=\"tag\">" . esc_html($refs->{$hash}) . "</span>";
+ if (defined $refs->{$co{'id'}}) {
+ $ref = " <span class=\"tag\">" . esc_html($refs->{$co{'id'}}) . "</span>";
}
git_header_html(undef, $expires);
print "<div class=\"page_nav\">\n" .
}
my $refs = read_info_ref();
my $ref = "";
- if (defined $refs->{$hash}) {
- $ref = " <span class=\"tag\">" . esc_html($refs->{$hash}) . "</span>";
+ if (defined $refs->{$co{'id'}}) {
+ $ref = " <span class=\"tag\">" . esc_html($refs->{$co{'id'}}) . "</span>";
}
git_header_html(undef, $expires);
print "<div class=\"page_nav\">\n" .
"\n";
foreach my $line (@$comment) {;
- print " $line\n";
+ print "$line\n";
}
print "---\n\n";
sub git_history {
if (!defined $hash) {
- $hash = git_read_hash("$project/HEAD");
+ $hash = git_read_head($project);
}
my %co = git_read_commit($hash);
if (!%co) {
die_error("", "Text field empty.");
}
if (!defined $hash) {
- $hash = git_read_hash("$project/HEAD");
+ $hash = git_read_head($project);
}
my %co = git_read_commit($hash);
if (!%co) {
}
sub git_shortlog {
- my $head = git_read_hash("$project/HEAD");
+ my $head = git_read_head($project);
if (!defined $hash) {
$hash = $head;
}