From 161332a521fe10c41979bcd493d95e2ac562b7ff Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:49:46 +0200 Subject: [PATCH 001/148] first working version --- gitweb.pl | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100755 gitweb.pl diff --git a/gitweb.pl b/gitweb.pl new file mode 100755 index 00000000000..ab4623db355 --- /dev/null +++ b/gitweb.pl @@ -0,0 +1,320 @@ +#!/usr/bin/perl + +# This file is licensed under the GPL v2, or a later version +# (C) 2005, Kay Sievers <kay.sievers@vrfy.org> +# (C) 2005, Christian Gierke <ch@gierke.de> + +use strict; +use warnings; +use CGI qw(:standard :escapeHTML); +use CGI::Carp qw(fatalsToBrowser); + +my $cgi = new CGI; +my $gitbin = "/home/kay/bin"; +my $gitroot = "/home/kay/public_html"; +my $gittmp = "/tmp"; +my $myself = $cgi->url(-relative => 1); + +my $project = $cgi->param("project") || ""; +my $action = $cgi->param("action") || ""; +my $hash = $cgi->param("hash") || ""; +my $parent = $cgi->param("parent") || ""; +my $view_back = $cgi->param("view_back") || 60*60*24*2; +my $projectroot = "$gitroot/$project"; +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; + +$hash =~ s/[^0-9a-fA-F]//g; +$parent =~ s/[^0-9a-fA-F]//g; +$project =~ s/[^0-9a-zA-Z\-\._]//g; + +sub header { + print $cgi->header(-type => 'text/html; charset: utf-8'); +print <<EOF; +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html> +<head> + <title>GIT</title> + <style type="text/css"> + body { font-family: sans-serif; font-size: 12px; margin:25px; } + div.main { border-width:1px; border-style:solid; border-color:#D9D8D1; } + div.head1 { font-size:20px; padding:8px; background-color: #D9D8D1; font-weight:bold; } + div.head2 { padding:8px; } + td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; } + td.head1 { background-color: #D9D8D1; font-weight:bold; } + td.head2 { background-color: #EDECE6; font-family: monospace; font-size:12px; } + table.log { padding:0px; margin:0px; width:100%; } + tr { vertical-align:top; } + a { color:#0000cc; } + a:hover { color:#880000; } + a:visited { color:#880000; } + a:active { color:#880000; } + </style> +</head> +<body> +EOF + if ($project ne "") { + print "<div class=\"main\">\n"; + print "<div class=\"head1\">" . $project . "</div>\n"; + print "<div class=\"head2\">\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_tree"}, "Browse Project") . "<br/>\n"; + print "Show Log "; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24}, "day") . "\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*7}, "week") . "\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*30}, "month") . "\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*365}, "year") . "<br/>\n"; + print "</div>\n"; + print "<br/><br/>\n"; + } +} + +sub footer { + print "</div>"; + print $cgi->end_html(); +} + +if ($project eq "") { + open my $fd, "-|", "ls", "-1", $gitroot; + my (@path) = map { chomp; $_ } <$fd>; + close $fd; + header(); + print "Projects:<br/><br/>\n"; + foreach my $line (@path) { + if (-e "$gitroot/$line/.git/HEAD") { + print $cgi->a({-href => "$myself?project=$line"}, $line) . "<br/>\n"; + } + } + footer(); + exit; +} + +if ($action eq "") { + print $cgi->redirect("$myself?project=$project&action=show_log&view_back=$view_back"); + exit; +} + +if ($action eq "show_file") { + header(); + print "<pre>\n"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; + my $nr; + while (my $line = <$fd>) { + $nr++; + print "$nr\t" . escapeHTML($line);; + } + close $fd; + print "</pre>\n"; + footer(); +} elsif ($action eq "show_tree") { + if ($hash eq "") { + open my $fd, "$projectroot/.git/HEAD"; + my $head = <$fd>; + chomp $head; + close $fd; + + open $fd, "-|", "$gitbin/cat-file", "commit", $head; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + $hash = $tree; + } + open my $fd, "-|", "$gitbin/ls-tree", $hash; + my (@entries) = map { chomp; $_ } <$fd>; + close $fd; + header(); + print "<pre>\n"; + foreach my $line (@entries) { + $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; + my $t_type = $2; + my $t_hash = $3; + my $t_name = $4; + if ($t_type eq "blob") { + print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$3"}, $4) . "\n"; + } elsif ($t_type eq "tree") { + print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=show_tree&hash=$3"}, $4) . "\n"; + } + } + print "</pre>\n"; + footer(); +} elsif ($action eq "show_log") { + open my $fd, "$projectroot/.git/HEAD"; + my $head = <$fd>; + chomp $head; + close $fd; + open my $fd, "-|", "$gitbin/rev-tree", $head; + my (@revtree) = map { chomp; $_ } <$fd>; + close $fd; + header(); + print "<table cellspacing=\"0\" class=\"log\">\n"; + foreach my $rev (reverse sort @revtree) { + if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { + last; + } + my $time = $1; + my $commit = $2; + my $parent = $3; + my @parents; + my $author; + my $author_name; + my $author_time; + my $author_timezone; + my $committer; + my $committer_time; + my $committer_timezone; + my $tree; + my $comment; + my $shortlog; + open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + while (my $line = <$fd>) { + chomp($line); + if ($line eq "") { + last; + } + if ($line =~ m/^tree (.*)$/) { + $tree = $1; + } elsif ($line =~ m/^parent (.*)$/) { + push @parents, $1; + } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { + $committer = $1; + $committer_time = $2; + $committer_timezone = $3; + } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { + $author = $1; + $author_time = $2; + $author_timezone = $3; + $author =~ m/^(.*) </; + $author_name = $1; + } + } + $shortlog = <$fd>; + $shortlog = escapeHTML($shortlog); + $comment = $shortlog . "<br/>"; + while (my $line = <$fd>) { + chomp($line); + $comment .= escapeHTML($line) . "<br/>\n"; + } + close $fd; + my $age = time-$author_time; + if ($view_back > 0 && $age > $view_back) { + last; + } + + my $age_string; + if ($age > 60*60*24*365*2) { + $age_string = int $age/60/60/24/365; + $age_string .= " years ago"; + } elsif ($age > 60*60*24*365/12*2) { + $age_string = int $age/60/60/24/365/12; + $age_string .= " months ago"; + } elsif ($age > 60*60*24*7*2) { + $age_string = int $age/60/60/24/7; + $age_string .= " weeks ago"; + } elsif ($age > 60*60*24*2) { + $age_string = int $age/60/60/24; + $age_string .= " days ago"; + } elsif ($age > 60*60*2) { + $age_string = int $age/60/60; + $age_string .= " hours ago"; + } elsif ($age > 60*2) { + $age_string = int $age/60; + $age_string .= " minutes ago"; + } + print "<tr>\n"; + print "<td class=\"head1\">" . $age_string . "</td>\n"; + print "<td class=\"head1\"><a href=\"$myself?project=$project&action=show_cset&hash=$commit&parent=$parent\">" . $shortlog . "</a></td>"; + print "</tr>\n"; + print "<tr>\n"; + print "<td class=\"head2\"></td>\n"; + print "<td class=\"head2\">\n"; + print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; + print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]<br/>\n"; + print "commit <a href=\"$myself?project=$project&action=show_cset&hash=$commit&parent=$parent\">$commit</a><br/>\n"; + print "tree <a href=\"$myself?project=$project&action=show_tree&hash=$tree\">$tree</a><br/>\n"; + foreach my $par (@parents) { + print "parent $par<br/>\n"; + } + print "</td>"; + print "</tr>\n"; + print "<tr>\n"; + print "<td></td>\n"; + print "<td>\n"; + print "$comment<br/><br/>\n"; + print "</td>"; + print "</tr>\n"; + } + print "</table>\n"; + footer(); +} elsif ($action eq "show_cset") { + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + + open my $fd, "-|", "$gitbin/cat-file", "commit", $parent; + my $parent_tree = <$fd>; + chomp $parent_tree; + $parent_tree =~ s/tree //; + close $fd; + + open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd; + + header(); + print "<pre>\n"; + foreach my $line (@difftree) { + $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; + my $op = $1; + my $mode = $2; + my $type = $3; + my $id = $4; + my $file = $5; + if ($type eq "blob") { + if ($op eq "+") { + print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n"; + } elsif ($op eq "-") { + print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n"; + } elsif ($op eq "*") { + $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; + my $old = $1; + my $new = $2; + print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=show_diff&hash=$old&parent=$new"}, $file) . "\n"; + } + } + } + print "</pre>\n"; + footer(); +} elsif ($action eq "show_diff") { + open my $fd2, "> $gittmp/$hash"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + + open my $fd2, "> $gittmp/$parent"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $parent; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + + header(); + print "<pre>\n"; + open my $fd, "-|", "/usr/bin/diff", "-L", "$hash", "-L", "$parent", "-u", "-p", "$gittmp/$hash", "$gittmp/$parent"; + while (my $line = <$fd>) { + print escapeHTML($line); + } + close $fd; + unlink("$gittmp/$hash"); + unlink("$gittmp/$parent"); + print "</pre>\n"; + footer(); +} else { + header(); + print "unknown action\n"; + footer(); +} From 4c02e3c56f95858f9e75fd102dbdf311431a6d10 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:52:52 +0200 Subject: [PATCH 002/148] v000 --- gitweb.pl | 263 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 184 insertions(+), 79 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index ab4623db355..e1ca3f8c6bb 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -19,7 +19,7 @@ my $project = $cgi->param("project") || ""; my $action = $cgi->param("action") || ""; my $hash = $cgi->param("hash") || ""; my $parent = $cgi->param("parent") || ""; -my $view_back = $cgi->param("view_back") || 60*60*24*2; +my $view_back = $cgi->param("view_back") || 60*60*24; my $projectroot = "$gitroot/$project"; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; @@ -27,7 +27,7 @@ $hash =~ s/[^0-9a-fA-F]//g; $parent =~ s/[^0-9a-fA-F]//g; $project =~ s/[^0-9a-zA-Z\-\._]//g; -sub header { +sub git_header { print $cgi->header(-type => 'text/html; charset: utf-8'); print <<EOF; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> @@ -36,64 +36,127 @@ print <<EOF; <title>GIT</title> <style type="text/css"> body { font-family: sans-serif; font-size: 12px; margin:25px; } - div.main { border-width:1px; border-style:solid; border-color:#D9D8D1; } + div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; } div.head1 { font-size:20px; padding:8px; background-color: #D9D8D1; font-weight:bold; } - div.head2 { padding:8px; } + div.head1 a:visited { color:#0000cc; } + div.head1 a:hover { color:#880000; } + div.head1 a:active { color:#880000; } + div.head2 { padding:8px; } + div.head2 a:visited { color:#0000cc; } + div.head2 a:hover { color:#880000; } + div.head2 a:active { color:#880000; } + div.main { padding:8px; font-family: sans-serif; font-size: 12px; } + table { padding:0px; margin:0px; width:100%; } + tr { vertical-align:top; } td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; } td.head1 { background-color: #D9D8D1; font-weight:bold; } + td.head1 a { color:#000000; text-decoration:none; } + td.head1 a:hover { color:#880000; text-decoration:underline; } + td.head1 a:visited { color:#000000; } td.head2 { background-color: #EDECE6; font-family: monospace; font-size:12px; } - table.log { padding:0px; margin:0px; width:100%; } - tr { vertical-align:top; } - a { color:#0000cc; } - a:hover { color:#880000; } - a:visited { color:#880000; } - a:active { color:#880000; } + td.head3 { background-color: #EDECE6; font-size:10px; } + div.add { color: #008800; } + div.subtract { color: #CC0000; } + div.diff_head { color: #990099; } + a { color:#0000cc; } + a:hover { color:#880000; } + a:visited { color:#880000; } + a:active { color:#880000; } </style> </head> <body> EOF + print "<div class=\"body\">\n"; + print "<div class=\"head1\">"; + print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"git_logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; + print $cgi->a({-href => "$myself"}, "projects"); if ($project ne "") { - print "<div class=\"main\">\n"; - print "<div class=\"head1\">" . $project . "</div>\n"; - print "<div class=\"head2\">\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_tree"}, "Browse Project") . "<br/>\n"; - print "Show Log "; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24}, "day") . "\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*7}, "week") . "\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*30}, "month") . "\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*365}, "year") . "<br/>\n"; - print "</div>\n"; - print "<br/><br/>\n"; + print " / " . $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, $project); } + if ($action ne "") { + print " / " . $action . " " . $hash; + } + print "</div>\n"; } -sub footer { +sub git_footer { print "</div>"; print $cgi->end_html(); } +sub git_diff { + my $old_name = shift; + my $new_name = shift; + my $old = shift; + my $new = shift; + + my $label_old = "/dev/null"; + my $label_new = "/dev/null"; + my $tmp_old = "/dev/null"; + my $tmp_new = "/dev/null"; + + if ($old ne "") { + open my $fd2, "> $gittmp/$old"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $old; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + $tmp_old = "$gittmp/$old"; + $label_old = "a/$old_name"; + } + + if ($new ne "") { + open my $fd2, "> $gittmp/$new"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $new; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + $tmp_new = "$gittmp/$new"; + $label_new = "b/$new_name"; + } + + open my $fd, "-|", "/usr/bin/diff", "-L", $label_old, "-L", $label_new, "-u", "-p", $tmp_old, $tmp_new; + while (my $line = <$fd>) { + my $char = substr($line,0,1); + print '<div class="add">' if $char eq '+'; + print '<div class="subtract">' if $char eq '-'; + print '<div class="diff_head">' if $char eq '@'; + print escapeHTML($line); + print '</div>' if $char eq '+' or $char eq '-' or $char eq '@'; + } + close $fd; + #unlink("$gittmp/$new"); + #unlink("$gittmp/$old"); +} + if ($project eq "") { open my $fd, "-|", "ls", "-1", $gitroot; my (@path) = map { chomp; $_ } <$fd>; close $fd; - header(); - print "Projects:<br/><br/>\n"; + git_header(); + print "<br/><br/><div class=\"main\">\n"; foreach my $line (@path) { if (-e "$gitroot/$line/.git/HEAD") { print $cgi->a({-href => "$myself?project=$line"}, $line) . "<br/>\n"; } } - footer(); + print "<br/></div>"; + git_footer(); exit; } if ($action eq "") { - print $cgi->redirect("$myself?project=$project&action=show_log&view_back=$view_back"); + print $cgi->redirect("$myself?project=$project&action=log&view_back=$view_back"); exit; } -if ($action eq "show_file") { - header(); +if ($action eq "file") { + git_header(); + print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; my $nr; @@ -103,14 +166,14 @@ if ($action eq "show_file") { } close $fd; print "</pre>\n"; - footer(); -} elsif ($action eq "show_tree") { + print "<br/></div>"; + git_footer(); +} elsif ($action eq "tree") { if ($hash eq "") { open my $fd, "$projectroot/.git/HEAD"; my $head = <$fd>; chomp $head; close $fd; - open $fd, "-|", "$gitbin/cat-file", "commit", $head; my $tree = <$fd>; chomp $tree; @@ -121,7 +184,8 @@ if ($action eq "show_file") { open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@entries) { $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -129,22 +193,32 @@ if ($action eq "show_file") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$3"}, $4) . "\n"; + print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$3"}, $4) . "\n"; } elsif ($t_type eq "tree") { - print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=show_tree&hash=$3"}, $4) . "\n"; + print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=tree&hash=$3"}, $4) . "\n"; } } print "</pre>\n"; - footer(); -} elsif ($action eq "show_log") { + print "<br/></div>"; + git_footer(); +} elsif ($action eq "log" || $action eq "show_log" ) { open my $fd, "$projectroot/.git/HEAD"; my $head = <$fd>; chomp $head; close $fd; - open my $fd, "-|", "$gitbin/rev-tree", $head; + open $fd, "-|", "$gitbin/rev-tree", $head; my (@revtree) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "<div class=\"head2\">\n"; + print "view "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, "last day") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*7}, "week") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*30}, "month") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*365}, "year") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=-1"}, "all") . "<br/>\n"; + print "<br/><br/>\n"; + print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; foreach my $rev (reverse sort @revtree) { if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { @@ -221,15 +295,19 @@ if ($action eq "show_file") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\"><a href=\"$myself?project=$project&action=show_cset&hash=$commit&parent=$parent\">" . $shortlog . "</a></td>"; + print "<td class=\"head1\"><a href=\"$myself?project=$project&action=commit&hash=$commit&parent=$parent\">" . $shortlog . "</a></td>"; print "</tr>\n"; print "<tr>\n"; - print "<td class=\"head2\"></td>\n"; + print "<td class=\"head3\">"; + print $cgi->a({-href => "$myself?project=$project&action=diffs&hash=$commit&parent=$parent"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project&action=commit&hash=$commit&parent=$parent"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project&action=tree&hash=$tree"}, "view tree") . "<br/>\n"; + print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]<br/>\n"; - print "commit <a href=\"$myself?project=$project&action=show_cset&hash=$commit&parent=$parent\">$commit</a><br/>\n"; - print "tree <a href=\"$myself?project=$project&action=show_tree&hash=$tree\">$tree</a><br/>\n"; + print "commit $commit<br/>\n"; + print "tree $tree<br/>\n"; foreach my $par (@parents) { print "parent $par<br/>\n"; } @@ -243,25 +321,26 @@ if ($action eq "show_file") { print "</tr>\n"; } print "</table>\n"; - footer(); -} elsif ($action eq "show_cset") { + git_footer(); +} elsif ($action eq "commit") { open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; my $tree = <$fd>; chomp $tree; $tree =~ s/tree //; close $fd; - open my $fd, "-|", "$gitbin/cat-file", "commit", $parent; + open $fd, "-|", "$gitbin/cat-file", "commit", $parent; my $parent_tree = <$fd>; chomp $parent_tree; $parent_tree =~ s/tree //; close $fd; - open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@difftree) { $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; @@ -272,49 +351,75 @@ if ($action eq "show_file") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n"; + print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n"; + print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=show_diff&hash=$old&parent=$new"}, $file) . "\n"; + print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=diff&hash=$old&parent=$new"}, $file) . "\n"; } } } print "</pre>\n"; - footer(); -} elsif ($action eq "show_diff") { - open my $fd2, "> $gittmp/$hash"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; - while (my $line = <$fd>) { - print $fd2 $line; - } - close $fd2; - close $fd; - - open my $fd2, "> $gittmp/$parent"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $parent; - while (my $line = <$fd>) { - print $fd2 $line; - } - close $fd2; - close $fd; - - header(); + print "<br/></div>"; + git_footer(); +} elsif ($action eq "diff") { + git_header(); + print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; - open my $fd, "-|", "/usr/bin/diff", "-L", "$hash", "-L", "$parent", "-u", "-p", "$gittmp/$hash", "$gittmp/$parent"; - while (my $line = <$fd>) { - print escapeHTML($line); - } - close $fd; - unlink("$gittmp/$hash"); - unlink("$gittmp/$parent"); + git_diff($hash, $parent, $hash, $parent); print "</pre>\n"; - footer(); + print "<br/></div>"; + git_footer(); +} elsif ($action eq "diffs") { + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/cat-file", "commit", $parent; + my $parent_tree = <$fd>; + chomp $parent_tree; + $parent_tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd; + + git_header(); + print "<br/><br/><div class=\"main\">\n"; + print "<pre>\n"; + foreach my $line (@difftree) { + $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; + my $op = $1; + my $mode = $2; + my $type = $3; + my $id = $4; + my $file = $5; + if ($type eq "blob") { + if ($op eq "+") { + git_diff("", $file, "", $id); + } elsif ($op eq "-") { + git_diff($file, "", $id, ""); + } elsif ($op eq "*") { + $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; + git_diff($file, $file, $1, $2); + } + } + print "<br/>\n"; + } + print "</pre>\n"; + print "<br/></div>"; + print "<br/></div>"; + git_footer(); } else { - header(); + git_header(); + print "<br/><br/><div class=\"main\">\n"; print "unknown action\n"; - footer(); + print "<br/></div>"; + git_footer(); } From ecb378f5b57b3b8eaa3cbccfb81f29bab8f4a1b7 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:53:54 +0200 Subject: [PATCH 003/148] v000 --- gitweb.pl | 140 ++++++++++++++++++++++++------------------------------ 1 file changed, 63 insertions(+), 77 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index e1ca3f8c6bb..fe44b188cae 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -10,7 +10,7 @@ use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $gitbin = "/home/kay/bin"; +my $gitbin = "/home/kay/bin/git"; my $gitroot = "/home/kay/public_html"; my $gittmp = "/tmp"; my $myself = $cgi->url(-relative => 1); @@ -33,7 +33,7 @@ print <<EOF; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> - <title>GIT</title> + <title>git - $project $action</title> <style type="text/css"> body { font-family: sans-serif; font-size: 12px; margin:25px; } div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; } @@ -57,7 +57,9 @@ print <<EOF; td.head3 { background-color: #EDECE6; font-size:10px; } div.add { color: #008800; } div.subtract { color: #CC0000; } - div.diff_head { color: #990099; } + div.diff_head { color: #000099; } + div.diff_head a:visited { color:#0000cc; } + div.diff_line { color: #990099; } a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } @@ -71,10 +73,10 @@ EOF print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"git_logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => "$myself"}, "projects"); if ($project ne "") { - print " / " . $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, $project); + print " / " . $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, $project); } if ($action ne "") { - print " / " . $action . " " . $hash; + print " / $action"; } print "</div>\n"; } @@ -85,16 +87,17 @@ sub git_footer { } sub git_diff { - my $old_name = shift; - my $new_name = shift; + my $old_name = shift || "/dev/null"; + my $new_name = shift || "/dev/null"; my $old = shift; my $new = shift; - my $label_old = "/dev/null"; - my $label_new = "/dev/null"; my $tmp_old = "/dev/null"; my $tmp_new = "/dev/null"; + my $old_label = "/dev/null"; + my $new_label = "/dev/null"; + # create temp from-file if ($old ne "") { open my $fd2, "> $gittmp/$old"; open my $fd, "-|", "$gitbin/cat-file", "blob", $old; @@ -104,9 +107,10 @@ sub git_diff { close $fd2; close $fd; $tmp_old = "$gittmp/$old"; - $label_old = "a/$old_name"; + $old_label = "a/$old_name"; } + # create tmp to-file if ($new ne "") { open my $fd2, "> $gittmp/$new"; open my $fd, "-|", "$gitbin/cat-file", "blob", $new; @@ -116,21 +120,34 @@ sub git_diff { close $fd2; close $fd; $tmp_new = "$gittmp/$new"; - $label_new = "b/$new_name"; + $new_label = "a/$new_name"; } - open my $fd, "-|", "/usr/bin/diff", "-L", $label_old, "-L", $label_new, "-u", "-p", $tmp_old, $tmp_new; + open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; + print '<div class="diff_head">===== '; + if ($old ne "") { + print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$old"}, $old); + } else { + print $old_name; + } + print " vs "; + if ($new ne "") { + print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$new"}, $new); + } else { + print $new_name; + } + print ' =====</div>'; while (my $line = <$fd>) { my $char = substr($line,0,1); print '<div class="add">' if $char eq '+'; print '<div class="subtract">' if $char eq '-'; - print '<div class="diff_head">' if $char eq '@'; + print '<div class="diff_line">' if $char eq '@'; print escapeHTML($line); print '</div>' if $char eq '+' or $char eq '-' or $char eq '@'; } close $fd; - #unlink("$gittmp/$new"); - #unlink("$gittmp/$old"); + unlink("$gittmp/$new"); + unlink("$gittmp/$old"); } if ($project eq "") { @@ -150,11 +167,11 @@ if ($project eq "") { } if ($action eq "") { - print $cgi->redirect("$myself?project=$project&action=log&view_back=$view_back"); + print $cgi->redirect("$myself?project=$project;action=log;view_back=$view_back"); exit; } -if ($action eq "file") { +if ($action eq "blob") { git_header(); print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; @@ -174,12 +191,7 @@ if ($action eq "file") { my $head = <$fd>; chomp $head; close $fd; - open $fd, "-|", "$gitbin/cat-file", "commit", $head; - my $tree = <$fd>; - chomp $tree; - $tree =~ s/tree //; - close $fd; - $hash = $tree; + $hash = $head; } open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; @@ -188,14 +200,15 @@ if ($action eq "file") { print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@entries) { + #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; my $t_type = $2; my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$3"}, $4) . "\n"; + print "BLOB\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$3"}, $4) . "\n"; } elsif ($t_type eq "tree") { - print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=tree&hash=$3"}, $4) . "\n"; + print "TREE\t" . $cgi->a({-href => "$myself?project=$project;action=tree;hash=$3"}, $4) . "\n"; } } print "</pre>\n"; @@ -212,18 +225,16 @@ if ($action eq "file") { git_header(); print "<div class=\"head2\">\n"; print "view "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, "last day") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*7}, "week") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*30}, "month") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*365}, "year") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=-1"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, "last day") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*7}, "week") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*30}, "month") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*365}, "year") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=-1"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; foreach my $rev (reverse sort @revtree) { - if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { - last; - } + last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; my $commit = $2; my $parent = $3; @@ -241,9 +252,7 @@ if ($action eq "file") { open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; while (my $line = <$fd>) { chomp($line); - if ($line eq "") { - last; - } + last if $line eq ""; if ($line =~ m/^tree (.*)$/) { $tree = $1; } elsif ($line =~ m/^parent (.*)$/) { @@ -268,10 +277,8 @@ if ($action eq "file") { $comment .= escapeHTML($line) . "<br/>\n"; } close $fd; - my $age = time-$author_time; - if ($view_back > 0 && $age > $view_back) { - last; - } + my $age = time-$committer_time; + last if ($view_back > 0 && $age > $view_back); my $age_string; if ($age > 60*60*24*365*2) { @@ -295,13 +302,13 @@ if ($action eq "file") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\"><a href=\"$myself?project=$project&action=commit&hash=$commit&parent=$parent\">" . $shortlog . "</a></td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, $shortlog) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself?project=$project&action=diffs&hash=$commit&parent=$parent"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project&action=commit&hash=$commit&parent=$parent"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project&action=tree&hash=$tree"}, "view tree") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; @@ -323,26 +330,17 @@ if ($action eq "file") { print "</table>\n"; git_footer(); } elsif ($action eq "commit") { - open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; - my $tree = <$fd>; - chomp $tree; - $tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/cat-file", "commit", $parent; - my $parent_tree = <$fd>; - chomp $parent_tree; - $parent_tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<div class=\"head2\">\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { + # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' + # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; @@ -351,14 +349,14 @@ if ($action eq "file") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$id"}, $file) . "\n"; + print "NEW\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$id"}, $file) . "\n"; + print "DEL\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=diff&hash=$old&parent=$new"}, $file) . "\n"; + print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project;action=diff;hash=$old;parent=$new"}, $file) . "\n"; } } } @@ -374,26 +372,16 @@ if ($action eq "file") { print "<br/></div>"; git_footer(); } elsif ($action eq "diffs") { - open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; - my $tree = <$fd>; - chomp $tree; - $tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/cat-file", "commit", $parent; - my $parent_tree = <$fd>; - chomp $parent_tree; - $parent_tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<div class=\"head2\">\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$hash;parent=$parent"}, "commit") . "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { + # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; @@ -410,11 +398,9 @@ if ($action eq "file") { git_diff($file, $file, $1, $2); } } - print "<br/>\n"; } print "</pre>\n"; print "<br/></div>"; - print "<br/></div>"; git_footer(); } else { git_header(); From e0389bd7f23cd49f46c82bb764fdc898b91fadc5 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:54:31 +0200 Subject: [PATCH 004/148] v001 --- gitweb.pl | 132 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 59 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index fe44b188cae..fd038355d95 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -57,9 +57,7 @@ print <<EOF; td.head3 { background-color: #EDECE6; font-size:10px; } div.add { color: #008800; } div.subtract { color: #CC0000; } - div.diff_head { color: #000099; } - div.diff_head a:visited { color:#0000cc; } - div.diff_line { color: #990099; } + div.diff_head { color: #990099; } a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } @@ -73,7 +71,7 @@ EOF print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"git_logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => "$myself"}, "projects"); if ($project ne "") { - print " / " . $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, $project); + print " / " . $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, $project); } if ($action ne "") { print " / $action"; @@ -87,17 +85,16 @@ sub git_footer { } sub git_diff { - my $old_name = shift || "/dev/null"; - my $new_name = shift || "/dev/null"; + my $old_name = shift; + my $new_name = shift; my $old = shift; my $new = shift; + my $label_old = "/dev/null"; + my $label_new = "/dev/null"; my $tmp_old = "/dev/null"; my $tmp_new = "/dev/null"; - my $old_label = "/dev/null"; - my $new_label = "/dev/null"; - # create temp from-file if ($old ne "") { open my $fd2, "> $gittmp/$old"; open my $fd, "-|", "$gitbin/cat-file", "blob", $old; @@ -107,10 +104,9 @@ sub git_diff { close $fd2; close $fd; $tmp_old = "$gittmp/$old"; - $old_label = "a/$old_name"; + $label_old = "a/$old_name"; } - # create tmp to-file if ($new ne "") { open my $fd2, "> $gittmp/$new"; open my $fd, "-|", "$gitbin/cat-file", "blob", $new; @@ -120,34 +116,21 @@ sub git_diff { close $fd2; close $fd; $tmp_new = "$gittmp/$new"; - $new_label = "a/$new_name"; + $label_new = "b/$new_name"; } - open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; - print '<div class="diff_head">===== '; - if ($old ne "") { - print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$old"}, $old); - } else { - print $old_name; - } - print " vs "; - if ($new ne "") { - print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$new"}, $new); - } else { - print $new_name; - } - print ' =====</div>'; + open my $fd, "-|", "/usr/bin/diff", "-L", $label_old, "-L", $label_new, "-u", "-p", $tmp_old, $tmp_new; while (my $line = <$fd>) { my $char = substr($line,0,1); print '<div class="add">' if $char eq '+'; print '<div class="subtract">' if $char eq '-'; - print '<div class="diff_line">' if $char eq '@'; + print '<div class="diff_head">' if $char eq '@'; print escapeHTML($line); print '</div>' if $char eq '+' or $char eq '-' or $char eq '@'; } close $fd; - unlink("$gittmp/$new"); - unlink("$gittmp/$old"); + #unlink("$gittmp/$new"); + #unlink("$gittmp/$old"); } if ($project eq "") { @@ -167,7 +150,7 @@ if ($project eq "") { } if ($action eq "") { - print $cgi->redirect("$myself?project=$project;action=log;view_back=$view_back"); + print $cgi->redirect("$myself?project=$project&action=log&view_back=$view_back"); exit; } @@ -191,7 +174,12 @@ if ($action eq "blob") { my $head = <$fd>; chomp $head; close $fd; - $hash = $head; + open $fd, "-|", "$gitbin/cat-file", "commit", $head; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + $hash = $tree; } open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; @@ -200,15 +188,14 @@ if ($action eq "blob") { print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@entries) { - #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; my $t_type = $2; my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "BLOB\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$3"}, $4) . "\n"; + print "BLOB\t" . $cgi->a({-href => "$myself?project=$project&action=blob&hash=$3"}, $4) . "\n"; } elsif ($t_type eq "tree") { - print "TREE\t" . $cgi->a({-href => "$myself?project=$project;action=tree;hash=$3"}, $4) . "\n"; + print "TREE\t" . $cgi->a({-href => "$myself?project=$project&action=tree&hash=$3"}, $4) . "\n"; } } print "</pre>\n"; @@ -225,16 +212,18 @@ if ($action eq "blob") { git_header(); print "<div class=\"head2\">\n"; print "view "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, "last day") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*7}, "week") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*30}, "month") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*365}, "year") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=-1"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, "last day") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*7}, "week") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*30}, "month") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*365}, "year") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=-1"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; foreach my $rev (reverse sort @revtree) { - last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); + if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { + last; + } my $time = $1; my $commit = $2; my $parent = $3; @@ -252,7 +241,9 @@ if ($action eq "blob") { open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; while (my $line = <$fd>) { chomp($line); - last if $line eq ""; + if ($line eq "") { + last; + } if ($line =~ m/^tree (.*)$/) { $tree = $1; } elsif ($line =~ m/^parent (.*)$/) { @@ -277,8 +268,10 @@ if ($action eq "blob") { $comment .= escapeHTML($line) . "<br/>\n"; } close $fd; - my $age = time-$committer_time; - last if ($view_back > 0 && $age > $view_back); + my $age = time-$author_time; + if ($view_back > 0 && $age > $view_back) { + last; + } my $age_string; if ($age > 60*60*24*365*2) { @@ -302,13 +295,13 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, $shortlog) . "</td>"; + print "<td class=\"head1\"><a href=\"$myself?project=$project&action=commit&hash=$commit&parent=$parent\">" . $shortlog . "</a></td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project&action=diffs&hash=$commit&parent=$parent"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project&action=commit&hash=$commit&parent=$parent"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project&action=tree&hash=$tree"}, "view tree") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; @@ -330,17 +323,26 @@ if ($action eq "blob") { print "</table>\n"; git_footer(); } elsif ($action eq "commit") { - open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/cat-file", "commit", $parent; + my $parent_tree = <$fd>; + chomp $parent_tree; + $parent_tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n"; + print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@difftree) { - # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' - # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; @@ -349,14 +351,14 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "NEW\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; + print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=blob&hash=$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "DEL\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; + print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=blob&hash=$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project;action=diff;hash=$old;parent=$new"}, $file) . "\n"; + print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project&action=diff&hash=$old&parent=$new"}, $file) . "\n"; } } } @@ -372,16 +374,26 @@ if ($action eq "blob") { print "<br/></div>"; git_footer(); } elsif ($action eq "diffs") { - open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/cat-file", "commit", $parent; + my $parent_tree = <$fd>; + chomp $parent_tree; + $parent_tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$hash;parent=$parent"}, "commit") . "<br/><br/>\n"; + print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@difftree) { - # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; @@ -398,9 +410,11 @@ if ($action eq "blob") { git_diff($file, $file, $1, $2); } } + print "<br/>\n"; } print "</pre>\n"; print "<br/></div>"; + print "<br/></div>"; git_footer(); } else { git_header(); From b531daf3a17b7787e631a713a42a58a25dd537df Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:55:05 +0200 Subject: [PATCH 005/148] v002 --- gitweb.pl | 51 +++++++++------------------------------------------ 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index fd038355d95..b13f75c21a1 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -95,6 +95,7 @@ sub git_diff { my $tmp_old = "/dev/null"; my $tmp_new = "/dev/null"; + # create temp from-file if ($old ne "") { open my $fd2, "> $gittmp/$old"; open my $fd, "-|", "$gitbin/cat-file", "blob", $old; @@ -107,6 +108,7 @@ sub git_diff { $label_old = "a/$old_name"; } + # create tmp to-file if ($new ne "") { open my $fd2, "> $gittmp/$new"; open my $fd, "-|", "$gitbin/cat-file", "blob", $new; @@ -174,12 +176,7 @@ if ($action eq "blob") { my $head = <$fd>; chomp $head; close $fd; - open $fd, "-|", "$gitbin/cat-file", "commit", $head; - my $tree = <$fd>; - chomp $tree; - $tree =~ s/tree //; - close $fd; - $hash = $tree; + $hash = $head; } open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; @@ -221,9 +218,7 @@ if ($action eq "blob") { print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; foreach my $rev (reverse sort @revtree) { - if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { - last; - } + last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; my $commit = $2; my $parent = $3; @@ -241,9 +236,7 @@ if ($action eq "blob") { open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; while (my $line = <$fd>) { chomp($line); - if ($line eq "") { - last; - } + last if $line eq ""; if ($line =~ m/^tree (.*)$/) { $tree = $1; } elsif ($line =~ m/^parent (.*)$/) { @@ -268,10 +261,8 @@ if ($action eq "blob") { $comment .= escapeHTML($line) . "<br/>\n"; } close $fd; - my $age = time-$author_time; - if ($view_back > 0 && $age > $view_back) { - last; - } + my $age = time-$committer_time; + last if ($view_back > 0 && $age > $view_back); my $age_string; if ($age > 60*60*24*365*2) { @@ -323,19 +314,7 @@ if ($action eq "blob") { print "</table>\n"; git_footer(); } elsif ($action eq "commit") { - open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; - my $tree = <$fd>; - chomp $tree; - $tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/cat-file", "commit", $parent; - my $parent_tree = <$fd>; - chomp $parent_tree; - $parent_tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -374,19 +353,7 @@ if ($action eq "blob") { print "<br/></div>"; git_footer(); } elsif ($action eq "diffs") { - open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; - my $tree = <$fd>; - chomp $tree; - $tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/cat-file", "commit", $parent; - my $parent_tree = <$fd>; - chomp $parent_tree; - $parent_tree =~ s/tree //; - close $fd; - - open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; From c068cff1f95c68f29cb514d5be7b9ddcbd28d824 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:56:10 +0200 Subject: [PATCH 006/148] v003 --- gitweb.pl | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index b13f75c21a1..b0efd7cdac7 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -57,7 +57,9 @@ print <<EOF; td.head3 { background-color: #EDECE6; font-size:10px; } div.add { color: #008800; } div.subtract { color: #CC0000; } - div.diff_head { color: #990099; } + div.diff_head { color: #000099; } + div.diff_head a:visited { color:#0000cc; } + div.diff_line { color: #990099; } a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } @@ -85,15 +87,15 @@ sub git_footer { } sub git_diff { - my $old_name = shift; - my $new_name = shift; + my $old_name = shift || "/dev/null"; + my $new_name = shift || "/dev/null"; my $old = shift; my $new = shift; - my $label_old = "/dev/null"; - my $label_new = "/dev/null"; my $tmp_old = "/dev/null"; my $tmp_new = "/dev/null"; + my $old_label = "/dev/null"; + my $new_label = "/dev/null"; # create temp from-file if ($old ne "") { @@ -105,7 +107,7 @@ sub git_diff { close $fd2; close $fd; $tmp_old = "$gittmp/$old"; - $label_old = "a/$old_name"; + $old_label = "a/$old_name"; } # create tmp to-file @@ -118,21 +120,34 @@ sub git_diff { close $fd2; close $fd; $tmp_new = "$gittmp/$new"; - $label_new = "b/$new_name"; + $new_label = "a/$new_name"; } - open my $fd, "-|", "/usr/bin/diff", "-L", $label_old, "-L", $label_new, "-u", "-p", $tmp_old, $tmp_new; + open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; + print '<div class="diff_head">===== '; + if ($old ne "") { + print $cgi->a({-href => "$myself?project=$project&action=blob&hash=$old"}, $old); + } else { + print $old_name; + } + print " vs "; + if ($new ne "") { + print $cgi->a({-href => "$myself?project=$project&action=blob&hash=$new"}, $new); + } else { + print $new_name; + } + print ' =====</div>'; while (my $line = <$fd>) { my $char = substr($line,0,1); print '<div class="add">' if $char eq '+'; print '<div class="subtract">' if $char eq '-'; - print '<div class="diff_head">' if $char eq '@'; + print '<div class="diff_line">' if $char eq '@'; print escapeHTML($line); print '</div>' if $char eq '+' or $char eq '-' or $char eq '@'; } close $fd; - #unlink("$gittmp/$new"); - #unlink("$gittmp/$old"); + unlink("$gittmp/$new"); + unlink("$gittmp/$old"); } if ($project eq "") { @@ -185,6 +200,7 @@ if ($action eq "blob") { print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@entries) { + #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; my $t_type = $2; my $t_hash = $3; @@ -322,6 +338,8 @@ if ($action eq "blob") { print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@difftree) { + # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' + # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; @@ -361,6 +379,7 @@ if ($action eq "blob") { print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; foreach my $line (@difftree) { + # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; @@ -377,7 +396,6 @@ if ($action eq "blob") { git_diff($file, $file, $1, $2); } } - print "<br/>\n"; } print "</pre>\n"; print "<br/></div>"; From adf3ee8e48fd4f3a75d4ee9a2e3209bd087c6417 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:56:44 +0200 Subject: [PATCH 007/148] v003 --- gitweb.pl | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index b0efd7cdac7..dafd687e8da 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -73,7 +73,7 @@ EOF print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"git_logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => "$myself"}, "projects"); if ($project ne "") { - print " / " . $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, $project); + print " / " . $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, $project); } if ($action ne "") { print " / $action"; @@ -120,19 +120,19 @@ sub git_diff { close $fd2; close $fd; $tmp_new = "$gittmp/$new"; - $new_label = "a/$new_name"; + $new_label = "b/$new_name"; } open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; print '<div class="diff_head">===== '; if ($old ne "") { - print $cgi->a({-href => "$myself?project=$project&action=blob&hash=$old"}, $old); + print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$old"}, $old); } else { print $old_name; } print " vs "; if ($new ne "") { - print $cgi->a({-href => "$myself?project=$project&action=blob&hash=$new"}, $new); + print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$new"}, $new); } else { print $new_name; } @@ -167,7 +167,7 @@ if ($project eq "") { } if ($action eq "") { - print $cgi->redirect("$myself?project=$project&action=log&view_back=$view_back"); + print $cgi->redirect("$myself?project=$project;action=log;view_back=$view_back"); exit; } @@ -206,9 +206,9 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "BLOB\t" . $cgi->a({-href => "$myself?project=$project&action=blob&hash=$3"}, $4) . "\n"; + print "BLOB\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$3"}, $4) . "\n"; } elsif ($t_type eq "tree") { - print "TREE\t" . $cgi->a({-href => "$myself?project=$project&action=tree&hash=$3"}, $4) . "\n"; + print "TREE\t" . $cgi->a({-href => "$myself?project=$project;action=tree;hash=$3"}, $4) . "\n"; } } print "</pre>\n"; @@ -225,11 +225,11 @@ if ($action eq "blob") { git_header(); print "<div class=\"head2\">\n"; print "view "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, "last day") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*7}, "week") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*30}, "month") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*365}, "year") . " | "; - print $cgi->a({-href => "$myself?project=$project&action=log&view_back=-1"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, "last day") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*7}, "week") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*30}, "month") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*365}, "year") . " | "; + print $cgi->a({-href => "$myself?project=$project;action=log;view_back=-1"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; @@ -302,13 +302,13 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\"><a href=\"$myself?project=$project&action=commit&hash=$commit&parent=$parent\">" . $shortlog . "</a></td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, $shortlog) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself?project=$project&action=diffs&hash=$commit&parent=$parent"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project&action=commit&hash=$commit&parent=$parent"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project&action=tree&hash=$tree"}, "view tree") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; @@ -335,7 +335,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<div class=\"head2\">\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -348,14 +349,14 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=blob&hash=$id"}, $file) . "\n"; + print "NEW\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=blob&hash=$id"}, $file) . "\n"; + print "DEL\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project&action=diff&hash=$old&parent=$new"}, $file) . "\n"; + print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project;action=diff;hash=$old;parent=$new"}, $file) . "\n"; } } } @@ -376,7 +377,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<div class=\"head2\">\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$hash;parent=$parent"}, "commit") . "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' @@ -399,7 +401,6 @@ if ($action eq "blob") { } print "</pre>\n"; print "<br/></div>"; - print "<br/></div>"; git_footer(); } else { git_header(); From 22fafb99e37d5b8b4f8ef57b9d09f233a7efa40a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:56:59 +0200 Subject: [PATCH 008/148] v004 --- gitweb.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dafd687e8da..09e0eca70ae 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -1,5 +1,9 @@ #!/usr/bin/perl +# gitweb.pl - simple web interface to track changes in git repositories +# +# Version 004 +# # This file is licensed under the GPL v2, or a later version # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -234,6 +238,7 @@ if ($action eq "blob") { print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; foreach my $rev (reverse sort @revtree) { + # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; my $commit = $2; @@ -306,7 +311,7 @@ if ($action eq "blob") { print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n"; print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, "view commit") . "<br/>\n"; print $cgi->a({-href => "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n"; print "</td>\n"; @@ -336,7 +341,7 @@ if ($action eq "blob") { git_header(); print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=diffs;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -371,7 +376,7 @@ if ($action eq "blob") { print "</pre>\n"; print "<br/></div>"; git_footer(); -} elsif ($action eq "diffs") { +} elsif ($action eq "treediff") { open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; From 823d5dc81f7452395725cf771e5710b113c7b27c Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:57:58 +0200 Subject: [PATCH 009/148] v005 --- gitweb.pl | 63 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 09e0eca70ae..25bd65e5f27 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,11 +2,12 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 004 +# Version 005 # -# This file is licensed under the GPL v2, or a later version # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> +# +# This file is licensed under the GPL v2, or a later version use strict; use warnings; @@ -22,15 +23,15 @@ my $myself = $cgi->url(-relative => 1); my $project = $cgi->param("project") || ""; my $action = $cgi->param("action") || ""; my $hash = $cgi->param("hash") || ""; -my $parent = $cgi->param("parent") || ""; +my $hash_parent = $cgi->param("hash_parent") || ""; my $view_back = $cgi->param("view_back") || 60*60*24; my $projectroot = "$gitroot/$project"; -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; - $hash =~ s/[^0-9a-fA-F]//g; -$parent =~ s/[^0-9a-fA-F]//g; +$hash_parent =~ s/[^0-9a-fA-F]//g; $project =~ s/[^0-9a-zA-Z\-\._]//g; +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; + sub git_header { print $cgi->header(-type => 'text/html; charset: utf-8'); print <<EOF; @@ -307,12 +308,12 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, $shortlog) . "</td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit"}, $shortlog) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$commit;parent=$parent"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit;parent=$parent"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$commit"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit"}, "view commit") . "<br/>\n"; print $cgi->a({-href => "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; @@ -335,13 +336,27 @@ if ($action eq "blob") { print "</table>\n"; git_footer(); } elsif ($action eq "commit") { - open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; + my $parent = ""; + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + while (my $line = <$fd>) { + chomp($line); + last if $line eq ""; + if ($line =~ m/^parent (.*)$/ && $parent eq "") { + $parent = $1; + } + } + my $shortlog = <$fd>; + $shortlog = escapeHTML($shortlog); + close $fd; + + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$hash;parent=$parent"}, "diff") . "<br/><br/>\n"; + print "<div class=\"main\">\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$hash"}, "diff") . "<br/><br/><br/>\n"; + print "$shortlog<br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -361,7 +376,7 @@ if ($action eq "blob") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project;action=diff;hash=$old;parent=$new"}, $file) . "\n"; + print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project;action=diff;hash=$old;hash_parent=$new"}, $file) . "\n"; } } } @@ -372,18 +387,32 @@ if ($action eq "blob") { git_header(); print "<br/><br/><div class=\"main\">\n"; print "<pre>\n"; - git_diff($hash, $parent, $hash, $parent); + git_diff($hash, $hash_parent, $hash, $hash_parent); print "</pre>\n"; print "<br/></div>"; git_footer(); } elsif ($action eq "treediff") { - open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; + my $parent = ""; + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + while (my $line = <$fd>) { + chomp($line); + last if $line eq ""; + if ($line =~ m/^parent (.*)$/ && $parent eq "") { + $parent = $1; + } + } + my $shortlog = <$fd>; + $shortlog = escapeHTML($shortlog); + close $fd; + + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$hash;parent=$parent"}, "commit") . "<br/><br/>\n"; + print "<div class=\"main\">\n"; + print "view " . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$hash"}, "commit") . "<br/><br/><br/>\n"; + print "$shortlog<br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' From 52ccdd40923bc189fbaf5eab9c515d3d27025773 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:58:12 +0200 Subject: [PATCH 010/148] v006 --- gitweb.pl | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 25bd65e5f27..8bd8127343b 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 005 +# Version 006 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -19,13 +19,38 @@ my $gitbin = "/home/kay/bin/git"; my $gitroot = "/home/kay/public_html"; my $gittmp = "/tmp"; my $myself = $cgi->url(-relative => 1); +my $url_path = $cgi->url(-path => 1); my $project = $cgi->param("project") || ""; my $action = $cgi->param("action") || ""; my $hash = $cgi->param("hash") || ""; my $hash_parent = $cgi->param("hash_parent") || ""; my $view_back = $cgi->param("view_back") || 60*60*24; + +if ($url_path =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { + $project = $1; + $action = "commit"; + $hash = $2; +} elsif ($url_path =~ m#/([^/]+)/treediff/([0-9a-fA-F]+)$#) { + $project = $1; + $action = "treediff"; + $hash = $2; +} elsif ($url_path =~ m#/([^/]+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { + $project = $1; + $action = "treediff"; + $hash = $2; + $hash_parent = $3; +} elsif ($url_path =~ m#/([^/]+)/log/([0-9]+)$#) { + $project = $1; + $action = "log"; + $view_back = $2; +} elsif ($url_path =~ m#/([^/]+)/log#) { + $project = $1; + $action = "log"; + $view_back = 60*60*24; +} my $projectroot = "$gitroot/$project"; + $hash =~ s/[^0-9a-fA-F]//g; $hash_parent =~ s/[^0-9a-fA-F]//g; $project =~ s/[^0-9a-zA-Z\-\._]//g; @@ -271,8 +296,6 @@ if ($action eq "blob") { $author = $1; $author_time = $2; $author_timezone = $3; - $author =~ m/^(.*) </; - $author_name = $1; } } $shortlog = <$fd>; From 44ad2978e69dd69956ca8eadf542789f484dba17 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:59:24 +0200 Subject: [PATCH 011/148] v014 --- gitweb.pl | 119 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 49 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 8bd8127343b..e04712537d1 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 006 +# Version 014 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -14,19 +14,20 @@ use warnings; use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); +my $gitbin = "/home/kay/bin/git"; # path to the git executables +my $gitroot = "/home/kay/public_html"; # path to the git repositories +my $gittmp = "/tmp"; # temporary files location + my $cgi = new CGI; -my $gitbin = "/home/kay/bin/git"; -my $gitroot = "/home/kay/public_html"; -my $gittmp = "/tmp"; -my $myself = $cgi->url(-relative => 1); +my $project = ""; +my $action = ""; +my $hash = ""; +my $hash_parent = ""; +my $view_back; +my $myself = $cgi->url(-absolute => 1); my $url_path = $cgi->url(-path => 1); -my $project = $cgi->param("project") || ""; -my $action = $cgi->param("action") || ""; -my $hash = $cgi->param("hash") || ""; -my $hash_parent = $cgi->param("hash_parent") || ""; -my $view_back = $cgi->param("view_back") || 60*60*24; - +# get values from url if ($url_path =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; @@ -37,24 +38,49 @@ if ($url_path =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { $hash = $2; } elsif ($url_path =~ m#/([^/]+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; - $action = "treediff"; + $action = "diff"; $hash = $2; $hash_parent = $3; +} elsif ($url_path =~ m#/([^/]+)/blob/([0-9a-fA-F]+)$#) { + $project = $1; + $action = "blob"; + $hash = $2; +} elsif ($url_path =~ m#/([^/]+)/tree/([0-9a-fA-F]+)$#) { + $project = $1; + $action = "tree"; + $hash = $2; } elsif ($url_path =~ m#/([^/]+)/log/([0-9]+)$#) { $project = $1; $action = "log"; $view_back = $2; -} elsif ($url_path =~ m#/([^/]+)/log#) { +} elsif ($url_path =~ m#/([^/]+)/log$#) { $project = $1; $action = "log"; - $view_back = 60*60*24; + $view_back = 1; +} elsif ($url_path =~ m#/git-logo.png$#) { + print $cgi->header(-type => 'image/png'); + print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". + "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". + "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". + "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367". + "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143". + "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010". + "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261". + "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052". + "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030". + "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202". + "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006". + "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". + "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; + exit; } -my $projectroot = "$gitroot/$project"; +# sanitize input $hash =~ s/[^0-9a-fA-F]//g; $hash_parent =~ s/[^0-9a-fA-F]//g; $project =~ s/[^0-9a-zA-Z\-\._]//g; +my $projectroot = "$gitroot/$project"; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; sub git_header { @@ -100,10 +126,10 @@ print <<EOF; EOF print "<div class=\"body\">\n"; print "<div class=\"head1\">"; - print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"git_logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; + print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"$myself/git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => "$myself"}, "projects"); if ($project ne "") { - print " / " . $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, $project); + print " / " . $cgi->a({-href => "$myself/$project/log"}, $project); } if ($action ne "") { print " / $action"; @@ -156,13 +182,13 @@ sub git_diff { open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; print '<div class="diff_head">===== '; if ($old ne "") { - print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$old"}, $old); + print $cgi->a({-href => "$myself/$project/blob/$old"}, $old); } else { print $old_name; } print " vs "; if ($new ne "") { - print $cgi->a({-href => "$myself?project=$project;action=blob;hash=$new"}, $new); + print $cgi->a({-href => "$myself/$project/blob/$new"}, $new); } else { print $new_name; } @@ -181,14 +207,14 @@ sub git_diff { } if ($project eq "") { - open my $fd, "-|", "ls", "-1", $gitroot; - my (@path) = map { chomp; $_ } <$fd>; - close $fd; + opendir(my $fd, $gitroot); + my (@path) = grep(!/^\./, readdir($fd)); + closedir($fd); git_header(); print "<br/><br/><div class=\"main\">\n"; foreach my $line (@path) { if (-e "$gitroot/$line/.git/HEAD") { - print $cgi->a({-href => "$myself?project=$line"}, $line) . "<br/>\n"; + print $cgi->a({-href => "$myself/$line/log"}, $line) . "<br/>\n"; } } print "<br/></div>"; @@ -197,7 +223,7 @@ if ($project eq "") { } if ($action eq "") { - print $cgi->redirect("$myself?project=$project;action=log;view_back=$view_back"); + print $cgi->redirect("$myself/$project/log/$view_back"); exit; } @@ -236,15 +262,15 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "BLOB\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$3"}, $4) . "\n"; + print "BLOB\t" . $cgi->a({-href => "$myself/$project/blob/$3"}, $4) . "\n"; } elsif ($t_type eq "tree") { - print "TREE\t" . $cgi->a({-href => "$myself?project=$project;action=tree;hash=$3"}, $4) . "\n"; + print "TREE\t" . $cgi->a({-href => "$myself/$project/tree/$3"}, $4) . "\n"; } } print "</pre>\n"; print "<br/></div>"; git_footer(); -} elsif ($action eq "log" || $action eq "show_log" ) { +} elsif ($action eq "log") { open my $fd, "$projectroot/.git/HEAD"; my $head = <$fd>; chomp $head; @@ -255,11 +281,11 @@ if ($action eq "blob") { git_header(); print "<div class=\"head2\">\n"; print "view "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24}, "last day") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*7}, "week") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*30}, "month") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=" . 60*60*24*365}, "year") . " | "; - print $cgi->a({-href => "$myself?project=$project;action=log;view_back=-1"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; + print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; + print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; + print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; + print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; @@ -270,13 +296,8 @@ if ($action eq "blob") { my $commit = $2; my $parent = $3; my @parents; - my $author; - my $author_name; - my $author_time; - my $author_timezone; - my $committer; - my $committer_time; - my $committer_timezone; + my ($author, $author_time, $author_timezone); + my ($committer, $committer_time, $committer_timezone); my $tree; my $comment; my $shortlog; @@ -307,7 +328,7 @@ if ($action eq "blob") { } close $fd; my $age = time-$committer_time; - last if ($view_back > 0 && $age > $view_back); + last if ($view_back > 0 && $age > $view_back*60*60*24); my $age_string; if ($age > 60*60*24*365*2) { @@ -331,13 +352,13 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit"}, $shortlog) . "</td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$commit"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project;action=commit;hash=$commit"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself?project=$project;action=tree;hash=$tree"}, "view tree") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/treediff/$commit"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; @@ -378,7 +399,7 @@ if ($action eq "blob") { git_header(); print "<div class=\"main\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=treediff;hash=$hash"}, "diff") . "<br/><br/><br/>\n"; + print "view " . $cgi->a({-href => "$myself/$project/treediff/$hash"}, "diff") . "<br/><br/><br/>\n"; print "$shortlog<br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { @@ -392,14 +413,14 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "NEW\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; + print "NEW\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "DEL\t" . $cgi->a({-href => "$myself?project=$project;action=blob;hash=$id"}, $file) . "\n"; + print "DEL\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "CHANGED\t" . $cgi->a({-href => "$myself?project=$project;action=diff;hash=$old;hash_parent=$new"}, $file) . "\n"; + print "CHANGED\t" . $cgi->a({-href => "$myself/$project/diff/$old/$new"}, $file) . "\n"; } } } @@ -434,7 +455,7 @@ if ($action eq "blob") { git_header(); print "<div class=\"main\">\n"; - print "view " . $cgi->a({-href => "$myself?project=$project;action=commit;hash=$hash"}, "commit") . "<br/><br/><br/>\n"; + print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "<br/><br/><br/>\n"; print "$shortlog<br/>\n"; print "<pre>\n"; foreach my $line (@difftree) { From 1b1433800ec2cf5961eaa5a924b2799f6b05ae10 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 19:59:41 +0200 Subject: [PATCH 012/148] v016 --- gitweb.pl | 60 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index e04712537d1..b1a9b661fb0 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 014 +# Version 016 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -25,39 +25,40 @@ my $hash = ""; my $hash_parent = ""; my $view_back; my $myself = $cgi->url(-absolute => 1); -my $url_path = $cgi->url(-path => 1); +my $url_parm = $cgi->url(-path => 1); +$url_parm =~ s/.*$myself//; # get values from url -if ($url_path =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { +if ($url_parm =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($url_path =~ m#/([^/]+)/treediff/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/([^/]+)/treediff/([0-9a-fA-F]+)$#) { $project = $1; $action = "treediff"; $hash = $2; -} elsif ($url_path =~ m#/([^/]+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/([^/]+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; $action = "diff"; $hash = $2; $hash_parent = $3; -} elsif ($url_path =~ m#/([^/]+)/blob/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/([^/]+)/blob/([0-9a-fA-F]+)$#) { $project = $1; $action = "blob"; $hash = $2; -} elsif ($url_path =~ m#/([^/]+)/tree/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/([^/]+)/tree/([0-9a-fA-F]+)$#) { $project = $1; $action = "tree"; $hash = $2; -} elsif ($url_path =~ m#/([^/]+)/log/([0-9]+)$#) { +} elsif ($url_parm =~ m#/([^/]+)/log/([0-9]+)$#) { $project = $1; $action = "log"; $view_back = $2; -} elsif ($url_path =~ m#/([^/]+)/log$#) { +} elsif ($url_parm =~ m#/([^/]+)/log$#) { $project = $1; $action = "log"; $view_back = 1; -} elsif ($url_path =~ m#/git-logo.png$#) { +} elsif ($url_parm =~ m#/git-logo.png$#) { print $cgi->header(-type => 'image/png'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". @@ -73,6 +74,10 @@ if ($url_path =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; exit; +} elsif ($url_parm =~ m#/([^/]+)$#) { + $project = $1; + $action = "log"; + $view_back = 1; } # sanitize input @@ -102,6 +107,7 @@ print <<EOF; div.head2 a:hover { color:#880000; } div.head2 a:active { color:#880000; } div.main { padding:8px; font-family: sans-serif; font-size: 12px; } + div.shortlog { padding:8px; background-color: #D9D8D1; font-weight:bold; } table { padding:0px; margin:0px; width:100%; } tr { vertical-align:top; } td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; } @@ -111,11 +117,7 @@ print <<EOF; td.head1 a:visited { color:#000000; } td.head2 { background-color: #EDECE6; font-family: monospace; font-size:12px; } td.head3 { background-color: #EDECE6; font-size:10px; } - div.add { color: #008800; } - div.subtract { color: #CC0000; } - div.diff_head { color: #000099; } - div.diff_head a:visited { color:#0000cc; } - div.diff_line { color: #990099; } + div.signed_off { color: #a9a8a1; } a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } @@ -180,7 +182,7 @@ sub git_diff { } open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; - print '<div class="diff_head">===== '; + print "<span style =\"color: #000099;\">===== "; if ($old ne "") { print $cgi->a({-href => "$myself/$project/blob/$old"}, $old); } else { @@ -192,14 +194,14 @@ sub git_diff { } else { print $new_name; } - print ' =====</div>'; + print " =====</span>\n"; while (my $line = <$fd>) { my $char = substr($line,0,1); - print '<div class="add">' if $char eq '+'; - print '<div class="subtract">' if $char eq '-'; - print '<div class="diff_line">' if $char eq '@'; + print '<span style ="color: #008800;">' if $char eq '+'; + print '<span style ="color: #CC0000;">' if $char eq '-'; + print '<span style ="color: #990099;">' if $char eq '@'; print escapeHTML($line); - print '</div>' if $char eq '+' or $char eq '-' or $char eq '@'; + print '</span>' if $char eq '+' or $char eq '-' or $char eq '@'; } close $fd; unlink("$gittmp/$new"); @@ -324,7 +326,11 @@ if ($action eq "blob") { $comment = $shortlog . "<br/>"; while (my $line = <$fd>) { chomp($line); - $comment .= escapeHTML($line) . "<br/>\n"; + if ($line =~ m/signed-off-by:/i) { + $comment .= '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; + } else { + $comment .= escapeHTML($line) . "<br/>\n"; + } } close $fd; my $age = time-$committer_time; @@ -400,7 +406,7 @@ if ($action eq "blob") { git_header(); print "<div class=\"main\">\n"; print "view " . $cgi->a({-href => "$myself/$project/treediff/$hash"}, "diff") . "<br/><br/><br/>\n"; - print "$shortlog<br/>\n"; + print "<div class=\"shortlog\">$shortlog<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -413,14 +419,14 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "NEW\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; + print "added\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "DEL\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; + print "removed\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "CHANGED\t" . $cgi->a({-href => "$myself/$project/diff/$old/$new"}, $file) . "\n"; + print "changed\t" . $cgi->a({-href => "$myself/$project/diff/$old/$new"}, $file) . "\n"; } } } @@ -456,7 +462,7 @@ if ($action eq "blob") { git_header(); print "<div class=\"main\">\n"; print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "<br/><br/><br/>\n"; - print "$shortlog<br/>\n"; + print "<div class=\"shortlog\">$shortlog<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' From a7e09a96a8b92913bebd89a45e43367c28a49072 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:00:05 +0200 Subject: [PATCH 013/148] v020 --- gitweb.pl | 70 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index b1a9b661fb0..85a5f530cc8 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 016 +# Version 020 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -14,9 +14,10 @@ use warnings; use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); -my $gitbin = "/home/kay/bin/git"; # path to the git executables -my $gitroot = "/home/kay/public_html"; # path to the git repositories -my $gittmp = "/tmp"; # temporary files location +my $projectroot = "/home/kay/public_html"; +my $defaultprojects = "."; +my $gitbin = "/home/kay/bin/git"; +my $gittmp = "/tmp"; my $cgi = new CGI; my $project = ""; @@ -29,32 +30,32 @@ my $url_parm = $cgi->url(-path => 1); $url_parm =~ s/.*$myself//; # get values from url -if ($url_parm =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { +if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($url_parm =~ m#/([^/]+)/treediff/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/treediff/([0-9a-fA-F]+)$#) { $project = $1; $action = "treediff"; $hash = $2; -} elsif ($url_parm =~ m#/([^/]+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; $action = "diff"; $hash = $2; $hash_parent = $3; -} elsif ($url_parm =~ m#/([^/]+)/blob/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { $project = $1; $action = "blob"; $hash = $2; -} elsif ($url_parm =~ m#/([^/]+)/tree/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) { $project = $1; $action = "tree"; $hash = $2; -} elsif ($url_parm =~ m#/([^/]+)/log/([0-9]+)$#) { +} elsif ($url_parm =~ m#/(.+)/log/([0-9]+)$#) { $project = $1; $action = "log"; $view_back = $2; -} elsif ($url_parm =~ m#/([^/]+)/log$#) { +} elsif ($url_parm =~ m#/(.+)/log$#) { $project = $1; $action = "log"; $view_back = 1; @@ -74,19 +75,16 @@ if ($url_parm =~ m#/([^/]+)/commit/([0-9a-fA-F]+)$#) { "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; exit; -} elsif ($url_parm =~ m#/([^/]+)$#) { +} elsif ($url_parm =~ m#/(.+)$#) { $project = $1; $action = "log"; $view_back = 1; } # sanitize input -$hash =~ s/[^0-9a-fA-F]//g; -$hash_parent =~ s/[^0-9a-fA-F]//g; -$project =~ s/[^0-9a-zA-Z\-\._]//g; +$project =~ s#\/\.+##g; -my $projectroot = "$gitroot/$project"; -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; sub git_header { print $cgi->header(-type => 'text/html; charset: utf-8'); @@ -129,9 +127,11 @@ EOF print "<div class=\"body\">\n"; print "<div class=\"head1\">"; print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"$myself/git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; - print $cgi->a({-href => "$myself"}, "projects"); + if ($defaultprojects ne "") { + print $cgi->a({-href => "$myself"}, "projects") . " / "; + } if ($project ne "") { - print " / " . $cgi->a({-href => "$myself/$project/log"}, $project); + print $cgi->a({-href => "$myself/$project/log"}, $project); } if ($action ne "") { print " / $action"; @@ -209,14 +209,14 @@ sub git_diff { } if ($project eq "") { - opendir(my $fd, $gitroot); + opendir(my $fd, "$projectroot/$defaultprojects"); my (@path) = grep(!/^\./, readdir($fd)); closedir($fd); git_header(); print "<br/><br/><div class=\"main\">\n"; foreach my $line (@path) { - if (-e "$gitroot/$line/.git/HEAD") { - print $cgi->a({-href => "$myself/$line/log"}, $line) . "<br/>\n"; + if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { + print $cgi->a({-href => "$myself/$defaultprojects/$line/log"}, $line) . "<br/>\n"; } } print "<br/></div>"; @@ -224,11 +224,6 @@ if ($project eq "") { exit; } -if ($action eq "") { - print $cgi->redirect("$myself/$project/log/$view_back"); - exit; -} - if ($action eq "blob") { git_header(); print "<br/><br/><div class=\"main\">\n"; @@ -245,7 +240,7 @@ if ($action eq "blob") { git_footer(); } elsif ($action eq "tree") { if ($hash eq "") { - open my $fd, "$projectroot/.git/HEAD"; + open my $fd, "$projectroot/$project/.git/HEAD"; my $head = <$fd>; chomp $head; close $fd; @@ -273,12 +268,12 @@ if ($action eq "blob") { print "<br/></div>"; git_footer(); } elsif ($action eq "log") { - open my $fd, "$projectroot/.git/HEAD"; + open my $fd, "$projectroot/$project/.git/HEAD"; my $head = <$fd>; chomp $head; close $fd; open $fd, "-|", "$gitbin/rev-tree", $head; - my (@revtree) = map { chomp; $_ } <$fd>; + my (@revtree) = reverse sort map { chomp; $_ } <$fd>; close $fd; git_header(); print "<div class=\"head2\">\n"; @@ -291,7 +286,9 @@ if ($action eq "blob") { print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; - foreach my $rev (reverse sort @revtree) { + for (my $i = 0; $i <= $#revtree; $i++) { + my $rev = $revtree[$i]; + #foreach my $rev (@revtree) { # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; @@ -333,9 +330,8 @@ if ($action eq "blob") { } } close $fd; - my $age = time-$committer_time; - last if ($view_back > 0 && $age > $view_back*60*60*24); + my $age = time-$committer_time; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -356,6 +352,14 @@ if ($action eq "blob") { $age_string = int $age/60; $age_string .= " minutes ago"; } + if ($view_back > 0 && $age > $view_back*60*60*24) { + if ($i == 0) { + print "<tr>\n"; + print "<td class=\"head1\"> Last change $age_string. </td>\n"; + print "</tr>\n"; + } + last; + } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "</td>"; From e334d18cfd28697912806e20130287ae7252c106 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:02:33 +0200 Subject: [PATCH 014/148] v021 --- gitweb.pl | 178 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 102 insertions(+), 76 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 85a5f530cc8..dd487c3d889 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 020 +# Version 021 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -34,13 +34,13 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/treediff/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { $project = $1; - $action = "treediff"; + $action = "commitdiff"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; - $action = "diff"; + $action = "blobdiff"; $hash = $2; $hash_parent = $3; } elsif ($url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { @@ -59,6 +59,10 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "log"; $view_back = 1; +} elsif ($url_parm =~ m#/(.+)/rss$#) { + $project = $1; + $action = "rss"; + $view_back = 1; } elsif ($url_parm =~ m#/git-logo.png$#) { print $cgi->header(-type => 'image/png'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". @@ -93,6 +97,7 @@ print <<EOF; <html> <head> <title>git - $project $action</title> + <link rel="alternate" title="$project log" href="$myself/$project/rss" type="application/rss+xml"> <style type="text/css"> body { font-family: sans-serif; font-size: 12px; margin:25px; } div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; } @@ -104,7 +109,6 @@ print <<EOF; div.head2 a:visited { color:#0000cc; } div.head2 a:hover { color:#880000; } div.head2 a:active { color:#880000; } - div.main { padding:8px; font-family: sans-serif; font-size: 12px; } div.shortlog { padding:8px; background-color: #D9D8D1; font-weight:bold; } table { padding:0px; margin:0px; width:100%; } tr { vertical-align:top; } @@ -120,6 +124,7 @@ print <<EOF; a:hover { color:#880000; } a:visited { color:#880000; } a:active { color:#880000; } + pre { padding:8px; } </style> </head> <body> @@ -213,20 +218,21 @@ if ($project eq "") { my (@path) = grep(!/^\./, readdir($fd)); closedir($fd); git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<div class=\"head2\">\n"; + print "<br/><br/>\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { print $cgi->a({-href => "$myself/$defaultprojects/$line/log"}, $line) . "<br/>\n"; } } - print "<br/></div>"; + print "</div><br/>"; git_footer(); exit; } if ($action eq "blob") { git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<br/><br/>\n"; print "<pre>\n"; open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; my $nr; @@ -236,7 +242,7 @@ if ($action eq "blob") { } close $fd; print "</pre>\n"; - print "<br/></div>"; + print "<br/>"; git_footer(); } elsif ($action eq "tree") { if ($hash eq "") { @@ -250,7 +256,7 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' @@ -265,9 +271,9 @@ if ($action eq "blob") { } } print "</pre>\n"; - print "<br/></div>"; + print "<br/>"; git_footer(); -} elsif ($action eq "log") { +} elsif ($action eq "log" || $action eq "rss") { open my $fd, "$projectroot/$project/.git/HEAD"; my $head = <$fd>; chomp $head; @@ -275,20 +281,33 @@ if ($action eq "blob") { open $fd, "-|", "$gitbin/rev-tree", $head; my (@revtree) = reverse sort map { chomp; $_ } <$fd>; close $fd; - git_header(); - print "<div class=\"head2\">\n"; - print "view "; - print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; - print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; - print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; - print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; - print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "<br/>\n"; - print "<br/><br/>\n"; - print "</div>\n"; - print "<table cellspacing=\"0\" class=\"log\">\n"; + + if ($action eq "log") { + git_header(); + print "<div class=\"head2\">\n"; + print "view "; + print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; + print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; + print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; + print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; + print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "<br/>\n"; + print "<br/><br/>\n"; + print "</div>\n"; + print "<table cellspacing=\"0\" class=\"log\">\n"; + } elsif ($action eq "rss") { + print $cgi->header(-type => 'text/xml; charset: utf-8'); + print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". + "<rss version=\"0.91\">\n"; + print "<channel>\n"; + print "<title>$project</title>\n". + "<link> " . $cgi->url() . "/$project/log</link>\n". + "<description>$project log</description>\n". + "<language>en</language>\n"; + } + for (my $i = 0; $i <= $#revtree; $i++) { my $rev = $revtree[$i]; - #foreach my $rev (@revtree) { + #foreach my $rev (@revtree) { # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; @@ -319,6 +338,7 @@ if ($action eq "blob") { } } $shortlog = <$fd>; + chomp($shortlog); $shortlog = escapeHTML($shortlog); $comment = $shortlog . "<br/>"; while (my $line = <$fd>) { @@ -352,43 +372,55 @@ if ($action eq "blob") { $age_string = int $age/60; $age_string .= " minutes ago"; } - if ($view_back > 0 && $age > $view_back*60*60*24) { - if ($i == 0) { - print "<tr>\n"; - print "<td class=\"head1\"> Last change $age_string. </td>\n"; - print "</tr>\n"; + if ($action eq "log") { + if ($view_back > 0 && $age > $view_back*60*60*24) { + if ($i == 0) { + print "<tr>\n"; + print "<td class=\"head1\"> Last change $age_string. </td>\n"; + print "</tr>\n"; + } + last; + } + print "<tr>\n"; + print "<td class=\"head1\">" . $age_string . "</td>\n"; + print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "</td>"; + print "</tr>\n"; + print "<tr>\n"; + print "<td class=\"head3\">"; + print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "<br/>\n"; + print "</td>\n"; + print "<td class=\"head2\">\n"; + print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; + print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]<br/>\n"; + print "commit $commit<br/>\n"; + print "tree $tree<br/>\n"; + foreach my $par (@parents) { + print "parent $par<br/>\n"; + } + print "</td>"; + print "</tr>\n"; + print "<tr>\n"; + print "<td></td>\n"; + print "<td>\n"; + print "$comment<br/><br/>\n"; + print "</td>"; + print "</tr>\n"; + } elsif ($action eq "rss") { + if ($i < 12) { + print "<item>\n\t<title>$age_string: $shortlog</title>\n"; + print "\t<link> " . $cgi->url() . "/$project/commit/$commit</link>\n"; + print "</item>\n"; } - last; } - print "<tr>\n"; - print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "</td>"; - print "</tr>\n"; - print "<tr>\n"; - print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself/$project/treediff/$commit"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "<br/>\n"; - print "</td>\n"; - print "<td class=\"head2\">\n"; - print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; - print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]<br/>\n"; - print "commit $commit<br/>\n"; - print "tree $tree<br/>\n"; - foreach my $par (@parents) { - print "parent $par<br/>\n"; - } - print "</td>"; - print "</tr>\n"; - print "<tr>\n"; - print "<td></td>\n"; - print "<td>\n"; - print "$comment<br/><br/>\n"; - print "</td>"; - print "</tr>\n"; } - print "</table>\n"; - git_footer(); + if ($action eq "log") { + print "</table>\n"; + git_footer(); + } elsif ($action eq "rss") { + print "</channel></rss>"; + } } elsif ($action eq "commit") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; @@ -408,8 +440,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "<div class=\"main\">\n"; - print "view " . $cgi->a({-href => "$myself/$project/treediff/$hash"}, "diff") . "<br/><br/><br/>\n"; + print "<div class=\"head2\">\n"; + print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "</div><br/><br/>\n"; print "<div class=\"shortlog\">$shortlog<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { @@ -430,22 +462,22 @@ if ($action eq "blob") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "changed\t" . $cgi->a({-href => "$myself/$project/diff/$old/$new"}, $file) . "\n"; + print "changed\t" . $cgi->a({-href => "$myself/$project/blobdiff/$old/$new"}, $file) . "\n"; } } } print "</pre>\n"; - print "<br/></div>"; + print "<br/>"; git_footer(); -} elsif ($action eq "diff") { +} elsif ($action eq "blobdiff") { git_header(); - print "<br/><br/><div class=\"main\">\n"; + print "<br/><br/>\n"; print "<pre>\n"; git_diff($hash, $hash_parent, $hash, $hash_parent); print "</pre>\n"; - print "<br/></div>"; + print "<br/>"; git_footer(); -} elsif ($action eq "treediff") { +} elsif ($action eq "commitdiff") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; while (my $line = <$fd>) { @@ -464,8 +496,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "<div class=\"main\">\n"; - print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "<br/><br/><br/>\n"; + print "<div class=\"head2\">\n"; + print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "</div><br/><br/>\n"; print "<div class=\"shortlog\">$shortlog<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { @@ -488,12 +520,6 @@ if ($action eq "blob") { } } print "</pre>\n"; - print "<br/></div>"; - git_footer(); -} else { - git_header(); - print "<br/><br/><div class=\"main\">\n"; - print "unknown action\n"; - print "<br/></div>"; + print "<br/>"; git_footer(); } From 12a88f2f031d10a1a7b46a913e629e90531b08b6 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:02:47 +0200 Subject: [PATCH 015/148] v021 --- gitweb.pl | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dd487c3d889..dd5fbdc2a8a 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -90,7 +90,7 @@ $project =~ s#\/\.+##g; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; -sub git_header { +sub git_header_html { print $cgi->header(-type => 'text/html; charset: utf-8'); print <<EOF; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> @@ -144,11 +144,19 @@ EOF print "</div>\n"; } -sub git_footer { +sub git_footer_html { print "</div>"; print $cgi->end_html(); } +sub git_head { + open my $fd, "$projectroot/$project/.git/HEAD"; + my $head = <$fd>; + close $fd; + chomp $head; + return $head; +} + sub git_diff { my $old_name = shift || "/dev/null"; my $new_name = shift || "/dev/null"; @@ -217,7 +225,7 @@ if ($project eq "") { opendir(my $fd, "$projectroot/$defaultprojects"); my (@path) = grep(!/^\./, readdir($fd)); closedir($fd); - git_header(); + git_header_html(); print "<div class=\"head2\">\n"; print "<br/><br/>\n"; foreach my $line (@path) { @@ -226,12 +234,12 @@ if ($project eq "") { } } print "</div><br/>"; - git_footer(); + git_footer_html(); exit; } if ($action eq "blob") { - git_header(); + git_header_html(); print "<br/><br/>\n"; print "<pre>\n"; open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; @@ -243,19 +251,15 @@ if ($action eq "blob") { close $fd; print "</pre>\n"; print "<br/>"; - git_footer(); + git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { - open my $fd, "$projectroot/$project/.git/HEAD"; - my $head = <$fd>; - chomp $head; - close $fd; - $hash = $head; + $hash = git_head(); } open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; close $fd; - git_header(); + git_header_html(); print "<br/><br/>\n"; print "<pre>\n"; foreach my $line (@entries) { @@ -272,18 +276,14 @@ if ($action eq "blob") { } print "</pre>\n"; print "<br/>"; - git_footer(); + git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "$projectroot/$project/.git/HEAD"; - my $head = <$fd>; - chomp $head; - close $fd; - open $fd, "-|", "$gitbin/rev-tree", $head; + open my $fd, "-|", "$gitbin/rev-tree", git_head(); my (@revtree) = reverse sort map { chomp; $_ } <$fd>; close $fd; if ($action eq "log") { - git_header(); + git_header_html(); print "<div class=\"head2\">\n"; print "view "; print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; @@ -417,7 +417,7 @@ if ($action eq "blob") { } if ($action eq "log") { print "</table>\n"; - git_footer(); + git_footer_html(); } elsif ($action eq "rss") { print "</channel></rss>"; } @@ -439,7 +439,7 @@ if ($action eq "blob") { my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - git_header(); + git_header_html(); print "<div class=\"head2\">\n"; print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "</div><br/><br/>\n"; print "<div class=\"shortlog\">$shortlog<br/></div>\n"; @@ -468,15 +468,15 @@ if ($action eq "blob") { } print "</pre>\n"; print "<br/>"; - git_footer(); + git_footer_html(); } elsif ($action eq "blobdiff") { - git_header(); + git_header_html(); print "<br/><br/>\n"; print "<pre>\n"; git_diff($hash, $hash_parent, $hash, $hash_parent); print "</pre>\n"; print "<br/>"; - git_footer(); + git_footer_html(); } elsif ($action eq "commitdiff") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; @@ -495,7 +495,7 @@ if ($action eq "blob") { my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - git_header(); + git_header_html(); print "<div class=\"head2\">\n"; print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "</div><br/><br/>\n"; print "<div class=\"shortlog\">$shortlog<br/></div>\n"; @@ -521,5 +521,5 @@ if ($action eq "blob") { } print "</pre>\n"; print "<br/>"; - git_footer(); + git_footer_html(); } From 703ac7102fb66f748f9a636f57852909b4425496 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:03:14 +0200 Subject: [PATCH 016/148] v021 --- gitweb.pl | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dd5fbdc2a8a..6d604d732e1 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -157,6 +157,47 @@ sub git_head { return $head; } +sub git_commit { + my $commit = shift; + my %co; + my @parents; + + open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + while (my $line = <$fd>) { + chomp($line); + last if $line eq ""; + if ($line =~ m/^tree (.*)$/) { + $co{'tree'} = $1; + } elsif ($line =~ m/^parent (.*)$/) { + push @parents, $1; + } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { + $co{'committer'} = $1; + $co{'committer_time'} = $2; + $co{'committer_timezone'} = $3; + } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { + $co{'$author'} = $1; + $co{'$author_time'} = $2; + $co{'$author_timezone'} = $3; + } + } + my $shortlog = <$fd>; + chomp($shortlog); + $co{'shortlog'} = escapeHTML($shortlog); + my $comment = $shortlog . "<br/>"; + while (my $line = <$fd>) { + chomp($line); + if ($line =~ m/signed-off-by:/i) { + $comment .= '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; + } else { + $comment .= escapeHTML($line) . "<br/>\n"; + } + } + $co{'comment'} = $comment; + close $fd; + + return %co; +} + sub git_diff { my $old_name = shift || "/dev/null"; my $new_name = shift || "/dev/null"; @@ -408,11 +449,10 @@ if ($action eq "blob") { print "</td>"; print "</tr>\n"; } elsif ($action eq "rss") { - if ($i < 12) { - print "<item>\n\t<title>$age_string: $shortlog</title>\n"; - print "\t<link> " . $cgi->url() . "/$project/commit/$commit</link>\n"; - print "</item>\n"; - } + last if ($i >= 12); + print "<item>\n\t<title>$age_string: $shortlog</title>\n"; + print "\t<link> " . $cgi->url() . "/$project/commit/$commit</link>\n"; + print "</item>\n"; } } if ($action eq "log") { From 3f714537ae72948a35db827d87363226200af646 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:03:52 +0200 Subject: [PATCH 017/148] v021 --- gitweb.pl | 103 +++++++++++++++++------------------------------------- 1 file changed, 33 insertions(+), 70 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 6d604d732e1..284a1588ea4 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -109,7 +109,7 @@ print <<EOF; div.head2 a:visited { color:#0000cc; } div.head2 a:hover { color:#880000; } div.head2 a:active { color:#880000; } - div.shortlog { padding:8px; background-color: #D9D8D1; font-weight:bold; } + div.title { padding:8px; background-color: #D9D8D1; font-weight:bold; } table { padding:0px; margin:0px; width:100%; } tr { vertical-align:top; } td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; } @@ -175,26 +175,16 @@ sub git_commit { $co{'committer_time'} = $2; $co{'committer_timezone'} = $3; } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { - $co{'$author'} = $1; - $co{'$author_time'} = $2; - $co{'$author_timezone'} = $3; + $co{'author'} = $1; + $co{'author_time'} = $2; + $co{'author_timezone'} = $3; } } - my $shortlog = <$fd>; - chomp($shortlog); - $co{'shortlog'} = escapeHTML($shortlog); - my $comment = $shortlog . "<br/>"; - while (my $line = <$fd>) { - chomp($line); - if ($line =~ m/signed-off-by:/i) { - $comment .= '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; - } else { - $comment .= escapeHTML($line) . "<br/>\n"; - } - } - $co{'comment'} = $comment; + $co{'parents'} = \@parents; + my (@comment) = map { chomp; $_ } <$fd>; + $co{'comment'} = \@comment; + $co{'title'} = $comment[0]; close $fd; - return %co; } @@ -354,45 +344,9 @@ if ($action eq "blob") { my $time = $1; my $commit = $2; my $parent = $3; - my @parents; - my ($author, $author_time, $author_timezone); - my ($committer, $committer_time, $committer_timezone); - my $tree; - my $comment; - my $shortlog; - open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; - while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; - if ($line =~ m/^tree (.*)$/) { - $tree = $1; - } elsif ($line =~ m/^parent (.*)$/) { - push @parents, $1; - } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { - $committer = $1; - $committer_time = $2; - $committer_timezone = $3; - } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { - $author = $1; - $author_time = $2; - $author_timezone = $3; - } - } - $shortlog = <$fd>; - chomp($shortlog); - $shortlog = escapeHTML($shortlog); - $comment = $shortlog . "<br/>"; - while (my $line = <$fd>) { - chomp($line); - if ($line =~ m/signed-off-by:/i) { - $comment .= '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; - } else { - $comment .= escapeHTML($line) . "<br/>\n"; - } - } - close $fd; - my $age = time-$committer_time; + my %co = git_commit($commit); + my $age = time - $co{'committer_time'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -424,20 +378,21 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "</td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $co{'title'}) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "<br/>\n"; print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "<br/>\n"; + print $cgi->a({-href => "$myself/$project/tree/$co{'tree'}"}, "view tree") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; - print "author " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]<br/>\n"; - print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]<br/>\n"; + print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]<br/>\n"; print "commit $commit<br/>\n"; - print "tree $tree<br/>\n"; - foreach my $par (@parents) { + print "tree $co{'tree'}<br/>\n"; + my $parents = $co{'parents'}; + foreach my $par (@$parents) { print "parent $par<br/>\n"; } print "</td>"; @@ -445,12 +400,20 @@ if ($action eq "blob") { print "<tr>\n"; print "<td></td>\n"; print "<td>\n"; - print "$comment<br/><br/>\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/signed-off-by:/i) { + print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; + } else { + print escapeHTML($line) . "<br/>\n"; + } + } + print "<br/><br/>\n"; print "</td>"; print "</tr>\n"; } elsif ($action eq "rss") { last if ($i >= 12); - print "<item>\n\t<title>$age_string: $shortlog</title>\n"; + print "<item>\n\t<title>$age_string: " . escapeHTML($co{'title'}) . "</title>\n"; print "\t<link> " . $cgi->url() . "/$project/commit/$commit</link>\n"; print "</item>\n"; } @@ -471,8 +434,8 @@ if ($action eq "blob") { $parent = $1; } } - my $shortlog = <$fd>; - $shortlog = escapeHTML($shortlog); + my $title = <$fd>; + $title = escapeHTML($title); close $fd; open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; @@ -482,7 +445,7 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"head2\">\n"; print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "</div><br/><br/>\n"; - print "<div class=\"shortlog\">$shortlog<br/></div>\n"; + print "<div class=\"title\">$title<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -527,8 +490,8 @@ if ($action eq "blob") { $parent = $1; } } - my $shortlog = <$fd>; - $shortlog = escapeHTML($shortlog); + my $title = <$fd>; + $title = escapeHTML($title); close $fd; open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; @@ -538,7 +501,7 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"head2\">\n"; print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "</div><br/><br/>\n"; - print "<div class=\"shortlog\">$shortlog<br/></div>\n"; + print "<div class=\"title\">$title<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' From 3e029299d8c6608298c3a2fc1f02af6b2cef0f29 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:05:15 +0200 Subject: [PATCH 018/148] v025 --- gitweb.pl | 187 +++++++++++++++++++++++++++++------------------------- 1 file changed, 102 insertions(+), 85 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 284a1588ea4..a2ec30db108 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 021 +# Version 025 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -14,57 +14,59 @@ use warnings; use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); +my $cgi = new CGI; + my $projectroot = "/home/kay/public_html"; my $defaultprojects = "."; my $gitbin = "/home/kay/bin/git"; my $gittmp = "/tmp"; +my $my_url = $cgi->url(); +my $my_uri = $cgi->url(-absolute => 1); +my $my_url_parm = $cgi->url(-path => 1); +$my_url_parm =~ s/.*$my_uri//; -my $cgi = new CGI; my $project = ""; my $action = ""; my $hash = ""; my $hash_parent = ""; -my $view_back; -my $myself = $cgi->url(-absolute => 1); -my $url_parm = $cgi->url(-path => 1); -$url_parm =~ s/.*$myself//; +my $view_back = 1; # get values from url -if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { +if ($my_url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { $project = $1; $action = "commitdiff"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; $action = "blobdiff"; $hash = $2; $hash_parent = $3; -} elsif ($url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { $project = $1; $action = "blob"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) { $project = $1; $action = "tree"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/log/([0-9]+)$#) { +} elsif ($my_url_parm =~ m#/(.+)/log/([0-9]+)$#) { $project = $1; $action = "log"; $view_back = $2; -} elsif ($url_parm =~ m#/(.+)/log$#) { +} elsif ($my_url_parm =~ m#/(.+)/log$#) { $project = $1; $action = "log"; $view_back = 1; -} elsif ($url_parm =~ m#/(.+)/rss$#) { +} elsif ($my_url_parm =~ m#/(.+)/rss$#) { $project = $1; $action = "rss"; $view_back = 1; -} elsif ($url_parm =~ m#/git-logo.png$#) { - print $cgi->header(-type => 'image/png'); +} elsif ($my_url_parm =~ m#/git-logo.png$#) { + print $cgi->header(-type => 'image/png', -expires => '+1d'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". @@ -79,7 +81,7 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; exit; -} elsif ($url_parm =~ m#/(.+)$#) { +} elsif ($my_url_parm =~ m#/(.+)$#) { $project = $1; $action = "log"; $view_back = 1; @@ -91,13 +93,13 @@ $project =~ s#\/\.+##g; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; sub git_header_html { - print $cgi->header(-type => 'text/html; charset: utf-8'); + print $cgi->header(-type => 'text/html', -charset => 'utf-8'); print <<EOF; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>git - $project $action</title> - <link rel="alternate" title="$project log" href="$myself/$project/rss" type="application/rss+xml"> + <link rel="alternate" title="$project log" href="$my_uri/$project/rss" type="application/rss+xml"/> <style type="text/css"> body { font-family: sans-serif; font-size: 12px; margin:25px; } div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; } @@ -110,6 +112,9 @@ print <<EOF; div.head2 a:hover { color:#880000; } div.head2 a:active { color:#880000; } div.title { padding:8px; background-color: #D9D8D1; font-weight:bold; } + div.title a { color:#000000; text-decoration:none; } + div.title a:hover { color:#880000; text-decoration:underline; } + div.title a:visited { color:#000000; } table { padding:0px; margin:0px; width:100%; } tr { vertical-align:top; } td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; } @@ -131,12 +136,13 @@ print <<EOF; EOF print "<div class=\"body\">\n"; print "<div class=\"head1\">"; - print "<a href=\"http://kernel.org/pub/software/scm/git/\"><img src=\"$myself/git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; + print "<a href=\"http://kernel.org/pub/software/scm/git/\">" . + "<img src=\"$my_uri/git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { - print $cgi->a({-href => "$myself"}, "projects") . " / "; + print $cgi->a({-href => "$my_uri"}, "projects") . " / "; } if ($project ne "") { - print $cgi->a({-href => "$myself/$project/log"}, $project); + print $cgi->a({-href => "$my_uri/$project/log"}, $project); } if ($action ne "") { print " / $action"; @@ -181,6 +187,7 @@ sub git_commit { } } $co{'parents'} = \@parents; + $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; $co{'title'} = $comment[0]; @@ -228,13 +235,13 @@ sub git_diff { open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; print "<span style =\"color: #000099;\">===== "; if ($old ne "") { - print $cgi->a({-href => "$myself/$project/blob/$old"}, $old); + print $cgi->a({-href => "$my_uri/$project/blob/$old"}, $old); } else { print $old_name; } print " vs "; if ($new ne "") { - print $cgi->a({-href => "$myself/$project/blob/$new"}, $new); + print $cgi->a({-href => "$my_uri/$project/blob/$new"}, $new); } else { print $new_name; } @@ -261,7 +268,7 @@ if ($project eq "") { print "<br/><br/>\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { - print $cgi->a({-href => "$myself/$defaultprojects/$line/log"}, $line) . "<br/>\n"; + print $cgi->a({-href => "$my_uri/$defaultprojects/$line/log"}, $line) . "<br/>\n"; } } print "</div><br/>"; @@ -300,9 +307,9 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "BLOB\t" . $cgi->a({-href => "$myself/$project/blob/$3"}, $4) . "\n"; + print "BLOB\t" . $cgi->a({-href => "$my_uri/$project/blob/$3"}, $4) . "\n"; } elsif ($t_type eq "tree") { - print "TREE\t" . $cgi->a({-href => "$myself/$project/tree/$3"}, $4) . "\n"; + print "TREE\t" . $cgi->a({-href => "$my_uri/$project/tree/$3"}, $4) . "\n"; } } print "</pre>\n"; @@ -317,28 +324,27 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"head2\">\n"; print "view "; - print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; - print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; - print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; - print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; - print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$my_uri/$project/log"}, "last day") . " | "; + print $cgi->a({-href => "$my_uri/$project/log/7"}, "week") . " | "; + print $cgi->a({-href => "$my_uri/$project/log/31"}, "month") . " | "; + print $cgi->a({-href => "$my_uri/$project/log/365"}, "year") . " | "; + print $cgi->a({-href => "$my_uri/$project/log/0"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; } elsif ($action eq "rss") { - print $cgi->header(-type => 'text/xml; charset: utf-8'); + print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". "<rss version=\"0.91\">\n"; print "<channel>\n"; print "<title>$project</title>\n". - "<link> " . $cgi->url() . "/$project/log</link>\n". + "<link> " . $my_url . "/$project/log</link>\n". "<description>$project log</description>\n". "<language>en</language>\n"; } for (my $i = 0; $i <= $#revtree; $i++) { my $rev = $revtree[$i]; - #foreach my $rev (@revtree) { # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; @@ -378,23 +384,16 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $co{'title'}) . "</td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$my_uri/$project/commit/$commit"}, $co{'title'}) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "<br/>\n"; - print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$myself/$project/tree/$co{'tree'}"}, "view tree") . "<br/>\n"; + print $cgi->a({-href => "$my_uri/$project/commit/$commit"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$my_uri/$project/commitdiff/$commit"}, "view diff") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]<br/>\n"; - print "commit $commit<br/>\n"; - print "tree $co{'tree'}<br/>\n"; - my $parents = $co{'parents'}; - foreach my $par (@$parents) { - print "parent $par<br/>\n"; - } print "</td>"; print "</tr>\n"; print "<tr>\n"; @@ -412,9 +411,19 @@ if ($action eq "blob") { print "</td>"; print "</tr>\n"; } elsif ($action eq "rss") { - last if ($i >= 12); - print "<item>\n\t<title>$age_string: " . escapeHTML($co{'title'}) . "</title>\n"; - print "\t<link> " . $cgi->url() . "/$project/commit/$commit</link>\n"; + last if ($i >= 20); + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($co{'author_time'}); + my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); + print "<item>\n\t<title>"; + printf("%s %02d, %02d:%02d - ", $months[$mon], $mday, $hour, $min); + print escapeHTML($co{'title'}) . "</title>\n"; + print "\t<link> " . $my_url . "/$project/commit/$commit</link>\n"; + print "\t<description>"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + print escapeHTML($line) . "\n"; + } + print "\t</description>\n"; print "</item>\n"; } } @@ -425,27 +434,45 @@ if ($action eq "blob") { print "</channel></rss>"; } } elsif ($action eq "commit") { - my $parent = ""; - open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; - while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; - if ($line =~ m/^parent (.*)$/ && $parent eq "") { - $parent = $1; - } - } - my $title = <$fd>; - $title = escapeHTML($title); - close $fd; - - open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; + my %co = git_commit($hash); + open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "</div><br/><br/>\n"; - print "<div class=\"title\">$title<br/></div>\n"; + print "<div class=\"head2\"> view\n"; + print $cgi->a({-href => "$my_uri/$project/commit/$hash"}, "commit") . " | "; + print $cgi->a({-href => "$my_uri/$project/commitdiff/$hash"}, "diff"); + print "</div><br/><br/>\n"; + print "<div class=\"title\">" . $cgi->a({-href => "$my_uri/$project/commitdiff/$hash"}, $co{'title'}) . "<br/></div>\n"; + print "<table cellspacing=\"0\" class=\"log\">\n"; + print "<tr>\n"; + print "<td class=\"head2\">"; + print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]<br/>\n"; + print "commit $hash<br/>\n"; + print "tree " . $cgi->a({-href => "$my_uri/$project/tree/$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; + my $parents = $co{'parents'}; + foreach my $par (@$parents) { + print "parent " . $cgi->a({-href => "$my_uri/$project/tree/$par"}, $par) . "<br/>\n"; + } + print "</td>"; + print "</tr>\n"; + print "<tr>\n"; + print "<td>\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/signed-off-by:/i) { + print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; + } else { + print escapeHTML($line) . "<br/>\n"; + } + } + print "<br/><br/>\n"; + print "</td>"; + print "</tr>\n"; + print "</table>"; + print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -458,14 +485,14 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "added\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; + print "added\t" . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "removed\t" . $cgi->a({-href => "$myself/$project/blob/$id"}, $file) . "\n"; + print "removed\t" . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "changed\t" . $cgi->a({-href => "$myself/$project/blobdiff/$old/$new"}, $file) . "\n"; + print "changed\t" . $cgi->a({-href => "$my_uri/$project/blobdiff/$old/$new"}, $file) . "\n"; } } } @@ -481,27 +508,17 @@ if ($action eq "blob") { print "<br/>"; git_footer_html(); } elsif ($action eq "commitdiff") { - my $parent = ""; - open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; - while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; - if ($line =~ m/^parent (.*)$/ && $parent eq "") { - $parent = $1; - } - } - my $title = <$fd>; - $title = escapeHTML($title); - close $fd; - - open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; + my %co = git_commit($hash); + open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "<div class=\"head2\">\n"; - print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "</div><br/><br/>\n"; - print "<div class=\"title\">$title<br/></div>\n"; + print "<div class=\"head2\"> view\n"; + print $cgi->a({-href => "$my_uri/$project/commit/$hash"}, "commit") . " | "; + print $cgi->a({-href => "$my_uri/$project/commitdiff/$hash"}, "diff"); + print "</div><br/><br/>\n"; + print "<div class=\"title\">" . $cgi->a({-href => "$my_uri/$project/commit/$hash"}, $co{'title'}) . "<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' From 959c6a1efcd54558cf6b1899f7b6068655a6fbf4 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:05:32 +0200 Subject: [PATCH 019/148] v026 --- gitweb.pl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index a2ec30db108..72b08a14f3f 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 025 +# Version 026 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -316,8 +316,8 @@ if ($action eq "blob") { print "<br/>"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-tree", git_head(); - my (@revtree) = reverse sort map { chomp; $_ } <$fd>; + open my $fd, "-|", "$gitbin/rev-list", git_head(); + my (@revtree) = map { chomp; $_ } <$fd>; close $fd; if ($action eq "log") { @@ -344,12 +344,7 @@ if ($action eq "blob") { } for (my $i = 0; $i <= $#revtree; $i++) { - my $rev = $revtree[$i]; - # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' - last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); - my $time = $1; - my $commit = $2; - my $parent = $3; + my $commit = $revtree[$i]; my %co = git_commit($commit); my $age = time - $co{'committer_time'}; From 8ed23e1bfb9233303898e2d5a9f240467bf89495 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:05:44 +0200 Subject: [PATCH 020/148] v027 --- gitweb.pl | 82 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 72b08a14f3f..1975c50f3cc 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 026 +# Version 027 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -195,55 +195,54 @@ sub git_commit { return %co; } -sub git_diff { - my $old_name = shift || "/dev/null"; - my $new_name = shift || "/dev/null"; - my $old = shift; - my $new = shift; +sub git_diff_html { + my $from_name = shift || "/dev/null"; + my $to_name = shift || "/dev/null"; + my $from = shift; + my $to = shift; - my $tmp_old = "/dev/null"; - my $tmp_new = "/dev/null"; - my $old_label = "/dev/null"; - my $new_label = "/dev/null"; + my $from_tmp = "/dev/null"; + my $to_tmp = "/dev/null"; + my $from_label = "/dev/null"; + my $to_label = "/dev/null"; + my $pid = $$; # create temp from-file - if ($old ne "") { - open my $fd2, "> $gittmp/$old"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $old; - while (my $line = <$fd>) { - print $fd2 $line; - } + if ($from ne "") { + $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; + open my $fd2, "> $from_tmp"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $from; + my @file = <$fd>; + print $fd2 @file; close $fd2; close $fd; - $tmp_old = "$gittmp/$old"; - $old_label = "a/$old_name"; + $from_label = "a/$from_name"; } # create tmp to-file - if ($new ne "") { - open my $fd2, "> $gittmp/$new"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $new; - while (my $line = <$fd>) { - print $fd2 $line; - } + if ($to ne "") { + $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; + open my $fd2, "> $to_tmp"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $to; + my @file = <$fd>; + print $fd2 @file; close $fd2; close $fd; - $tmp_new = "$gittmp/$new"; - $new_label = "b/$new_name"; + $to_label = "b/$to_name"; } - open my $fd, "-|", "/usr/bin/diff", "-L", $old_label, "-L", $new_label, "-u", "-p", $tmp_old, $tmp_new; + open my $fd, "-|", "/usr/bin/diff", "-L", $from_label, "-L", $to_label, "-u", "-p", $from_tmp, $to_tmp; print "<span style =\"color: #000099;\">===== "; - if ($old ne "") { - print $cgi->a({-href => "$my_uri/$project/blob/$old"}, $old); + if ($from ne "") { + print $cgi->a({-href => "$my_uri/$project/blob/$from"}, $from); } else { - print $old_name; + print $from_name; } print " vs "; - if ($new ne "") { - print $cgi->a({-href => "$my_uri/$project/blob/$new"}, $new); + if ($to ne "") { + print $cgi->a({-href => "$my_uri/$project/blob/$to"}, $to); } else { - print $new_name; + print $to_name; } print " =====</span>\n"; while (my $line = <$fd>) { @@ -255,8 +254,13 @@ sub git_diff { print '</span>' if $char eq '+' or $char eq '-' or $char eq '@'; } close $fd; - unlink("$gittmp/$new"); - unlink("$gittmp/$old"); + + if ($from ne "") { + unlink("$from_tmp"); + } + if ($to ne "") { + unlink("$to_tmp"); + } } if ($project eq "") { @@ -498,7 +502,7 @@ if ($action eq "blob") { git_header_html(); print "<br/><br/>\n"; print "<pre>\n"; - git_diff($hash, $hash_parent, $hash, $hash_parent); + git_diff_html($hash, $hash_parent, $hash, $hash_parent); print "</pre>\n"; print "<br/>"; git_footer_html(); @@ -525,12 +529,12 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - git_diff("", $file, "", $id); + git_diff_html("", $file, "", $id); } elsif ($op eq "-") { - git_diff($file, "", $id, ""); + git_diff_html($file, "", $id, ""); } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - git_diff($file, $file, $1, $2); + git_diff_html($file, $file, $1, $2); } } } From d767d59c8a194dfe4c56040540df63f4d64ce5e0 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:05:55 +0200 Subject: [PATCH 021/148] v031 --- gitweb.pl | 55 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 1975c50f3cc..2dca8618325 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 027 +# Version 031 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -32,40 +32,40 @@ my $hash_parent = ""; my $view_back = 1; # get values from url -if ($my_url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { +if ($my_url_parm =~ m#/+(.+)/+commit/+([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($my_url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/+(.+)/+commitdiff/+([0-9a-fA-F]+)$#) { $project = $1; $action = "commitdiff"; $hash = $2; -} elsif ($my_url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/+(.+)/+blobdiff/+([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; $action = "blobdiff"; $hash = $2; $hash_parent = $3; -} elsif ($my_url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/+(.+)/+blob/+([0-9a-fA-F]+)$#) { $project = $1; $action = "blob"; $hash = $2; -} elsif ($my_url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) { +} elsif ($my_url_parm =~ m#/+(.+)/+tree/+([0-9a-fA-F]+)$#) { $project = $1; $action = "tree"; $hash = $2; -} elsif ($my_url_parm =~ m#/(.+)/log/([0-9]+)$#) { +} elsif ($my_url_parm =~ m#/+(.+)/+log/+([0-9]+)$#) { $project = $1; $action = "log"; $view_back = $2; -} elsif ($my_url_parm =~ m#/(.+)/log$#) { +} elsif ($my_url_parm =~ m#/+(.+)/+log$#) { $project = $1; $action = "log"; $view_back = 1; -} elsif ($my_url_parm =~ m#/(.+)/rss$#) { +} elsif ($my_url_parm =~ m#/+(.+)/rss$#) { $project = $1; $action = "rss"; $view_back = 1; -} elsif ($my_url_parm =~ m#/git-logo.png$#) { +} elsif ($my_url_parm =~ m#/+git-logo.png$#) { print $cgi->header(-type => 'image/png', -expires => '+1d'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". @@ -151,8 +151,8 @@ EOF } sub git_footer_html { - print "</div>"; - print $cgi->end_html(); + print "</div>\n"; + print "</body>\n</html>"; } sub git_head { @@ -263,6 +263,20 @@ sub git_diff_html { } } +sub mode_str { + my $perms = oct shift; + my $modestr; + if ($perms & 040000) { $modestr .= 'd' } else { $modestr .= '-' }; + for (my $i = 0; $i < 3; $i++) { + if ($perms & 0400) { $modestr .= 'r' } else { $modestr .= '-' }; + if ($perms & 0200) { $modestr .= 'w' } else { $modestr .= '-' }; + if ($perms & 0100) { $modestr .= 'x' } else { $modestr .= '-' }; + $perms <<= 3; + } + return $modestr; +} + +# show list of default projects if ($project eq "") { opendir(my $fd, "$projectroot/$defaultprojects"); my (@path) = grep(!/^\./, readdir($fd)); @@ -307,13 +321,14 @@ if ($action eq "blob") { foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; + my $t_mode = $1; my $t_type = $2; my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print "BLOB\t" . $cgi->a({-href => "$my_uri/$project/blob/$3"}, $4) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri/$project/blob/$t_hash"}, $t_name) . "\n"; } elsif ($t_type eq "tree") { - print "TREE\t" . $cgi->a({-href => "$my_uri/$project/tree/$3"}, $4) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri/$project/tree/$t_hash"}, $t_name) . "\n"; } } print "</pre>\n"; @@ -400,7 +415,7 @@ if ($action eq "blob") { print "<td>\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { - if ($line =~ m/signed-off-by:/i) { + if ($line =~ m/^(signed-off|acked)-by:/i) { print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; } else { print escapeHTML($line) . "<br/>\n"; @@ -461,7 +476,7 @@ if ($action eq "blob") { print "<td>\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { - if ($line =~ m/signed-off-by:/i) { + if ($line =~ m/(signed-off|acked)-by:/i) { print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; } else { print escapeHTML($line) . "<br/>\n"; @@ -482,16 +497,18 @@ if ($action eq "blob") { my $type = $3; my $id = $4; my $file = $5; + $mode =~ m/^([0-7]{6})/; + my $modestr = mode_str($1); if ($type eq "blob") { if ($op eq "+") { - print "added\t" . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; + print "added\t$modestr " . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "removed\t" . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; + print "removed\t$modestr " . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "changed\t" . $cgi->a({-href => "$my_uri/$project/blobdiff/$old/$new"}, $file) . "\n"; + print "changed\t$modestr " . $cgi->a({-href => "$my_uri/$project/blobdiff/$old/$new"}, $file) . "\n"; } } } From 022be3d0f105afbf55092056d242406685ccdb7e Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:06:09 +0200 Subject: [PATCH 022/148] v035 --- gitweb.pl | 169 ++++++++++++++++++++++-------------------------------- 1 file changed, 69 insertions(+), 100 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 2dca8618325..6452f33efe6 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 031 +# Version 035 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -16,81 +16,27 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $projectroot = "/home/kay/public_html"; -my $defaultprojects = "."; +my $projectroot = "/"; +my $defaultprojects = "home/kay/public_html"; my $gitbin = "/home/kay/bin/git"; my $gittmp = "/tmp"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -my $my_url_parm = $cgi->url(-path => 1); -$my_url_parm =~ s/.*$my_uri//; -my $project = ""; -my $action = ""; -my $hash = ""; -my $hash_parent = ""; -my $view_back = 1; - -# get values from url -if ($my_url_parm =~ m#/+(.+)/+commit/+([0-9a-fA-F]+)$#) { - $project = $1; - $action = "commit"; - $hash = $2; -} elsif ($my_url_parm =~ m#/+(.+)/+commitdiff/+([0-9a-fA-F]+)$#) { - $project = $1; - $action = "commitdiff"; - $hash = $2; -} elsif ($my_url_parm =~ m#/+(.+)/+blobdiff/+([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { - $project = $1; - $action = "blobdiff"; - $hash = $2; - $hash_parent = $3; -} elsif ($my_url_parm =~ m#/+(.+)/+blob/+([0-9a-fA-F]+)$#) { - $project = $1; - $action = "blob"; - $hash = $2; -} elsif ($my_url_parm =~ m#/+(.+)/+tree/+([0-9a-fA-F]+)$#) { - $project = $1; - $action = "tree"; - $hash = $2; -} elsif ($my_url_parm =~ m#/+(.+)/+log/+([0-9]+)$#) { - $project = $1; - $action = "log"; - $view_back = $2; -} elsif ($my_url_parm =~ m#/+(.+)/+log$#) { - $project = $1; - $action = "log"; - $view_back = 1; -} elsif ($my_url_parm =~ m#/+(.+)/rss$#) { - $project = $1; - $action = "rss"; - $view_back = 1; -} elsif ($my_url_parm =~ m#/+git-logo.png$#) { - print $cgi->header(-type => 'image/png', -expires => '+1d'); - print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". - "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". - "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". - "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367". - "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143". - "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010". - "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261". - "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052". - "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030". - "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202". - "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006". - "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". - "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; - exit; -} elsif ($my_url_parm =~ m#/(.+)$#) { - $project = $1; - $action = "log"; - $view_back = 1; -} +my $project = $cgi->param('p'); +my $action = $cgi->param('a'); +my $hash = $cgi->param('h'); +my $hash_parent = $cgi->param('hp'); +my $time_back = $cgi->param('t'); +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; # sanitize input -$project =~ s#\/\.+##g; - -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; +$action =~ s/[^0-9a-zA-Z\.\-]//g; +$project =~ s/\/\.//g; +$project =~ s/|//g; +$hash =~ s/[^0-9a-fA-F]//g; +$hash_parent =~ s/[^0-9a-fA-F]//g; +$time_back =~ s/[^0-9]+//g; sub git_header_html { print $cgi->header(-type => 'text/html', -charset => 'utf-8'); @@ -137,12 +83,12 @@ EOF print "<div class=\"body\">\n"; print "<div class=\"head1\">"; print "<a href=\"http://kernel.org/pub/software/scm/git/\">" . - "<img src=\"$my_uri/git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; + "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; } if ($project ne "") { - print $cgi->a({-href => "$my_uri/$project/log"}, $project); + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); } if ($action ne "") { print " / $action"; @@ -176,11 +122,11 @@ sub git_commit { $co{'tree'} = $1; } elsif ($line =~ m/^parent (.*)$/) { push @parents, $1; - } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { + } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { $co{'committer'} = $1; $co{'committer_time'} = $2; $co{'committer_timezone'} = $3; - } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { + } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; $co{'author_time'} = $2; $co{'author_timezone'} = $3; @@ -234,13 +180,13 @@ sub git_diff_html { open my $fd, "-|", "/usr/bin/diff", "-L", $from_label, "-L", $to_label, "-u", "-p", $from_tmp, $to_tmp; print "<span style =\"color: #000099;\">===== "; if ($from ne "") { - print $cgi->a({-href => "$my_uri/$project/blob/$from"}, $from); + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); } else { print $from_name; } print " vs "; if ($to ne "") { - print $cgi->a({-href => "$my_uri/$project/blob/$to"}, $to); + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to); } else { print $to_name; } @@ -276,6 +222,24 @@ sub mode_str { return $modestr; } +if ($action eq "git-logo.png") { + print $cgi->header(-type => 'image/png', -expires => '+1d'); + print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". + "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". + "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". + "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367". + "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143". + "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010". + "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261". + "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052". + "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030". + "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202". + "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006". + "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". + "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; + exit; +} + # show list of default projects if ($project eq "") { opendir(my $fd, "$projectroot/$defaultprojects"); @@ -286,7 +250,7 @@ if ($project eq "") { print "<br/><br/>\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { - print $cgi->a({-href => "$my_uri/$defaultprojects/$line/log"}, $line) . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "<br/>\n"; } } print "</div><br/>"; @@ -302,7 +266,7 @@ if ($action eq "blob") { my $nr; while (my $line = <$fd>) { $nr++; - print "$nr\t" . escapeHTML($line);; + printf "<span style =\"color: #999999;\">%3i\t</span>%s", $nr, escapeHTML($line);; } close $fd; print "</pre>\n"; @@ -326,9 +290,9 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri/$project/blob/$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri/$project/tree/$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; } } print "</pre>\n"; @@ -343,11 +307,11 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"head2\">\n"; print "view "; - print $cgi->a({-href => "$my_uri/$project/log"}, "last day") . " | "; - print $cgi->a({-href => "$my_uri/$project/log/7"}, "week") . " | "; - print $cgi->a({-href => "$my_uri/$project/log/31"}, "month") . " | "; - print $cgi->a({-href => "$my_uri/$project/log/365"}, "year") . " | "; - print $cgi->a({-href => "$my_uri/$project/log/0"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; @@ -364,7 +328,6 @@ if ($action eq "blob") { for (my $i = 0; $i <= $#revtree; $i++) { my $commit = $revtree[$i]; - my %co = git_commit($commit); my $age = time - $co{'committer_time'}; my $age_string; @@ -388,7 +351,7 @@ if ($action eq "blob") { $age_string .= " minutes ago"; } if ($action eq "log") { - if ($view_back > 0 && $age > $view_back*60*60*24) { + if ($time_back > 0 && $age > $time_back*60*60*24) { if ($i == 0) { print "<tr>\n"; print "<td class=\"head1\"> Last change $age_string. </td>\n"; @@ -398,12 +361,12 @@ if ($action eq "blob") { } print "<tr>\n"; print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$my_uri/$project/commit/$commit"}, $co{'title'}) . "</td>"; + print "<td class=\"head1\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, $co{'title'}) . "</td>"; print "</tr>\n"; print "<tr>\n"; print "<td class=\"head3\">"; - print $cgi->a({-href => "$my_uri/$project/commit/$commit"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$my_uri/$project/commitdiff/$commit"}, "view diff") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; @@ -455,20 +418,20 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"head2\"> view\n"; - print $cgi->a({-href => "$my_uri/$project/commit/$hash"}, "commit") . " | "; - print $cgi->a({-href => "$my_uri/$project/commitdiff/$hash"}, "diff"); + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); print "</div><br/><br/>\n"; - print "<div class=\"title\">" . $cgi->a({-href => "$my_uri/$project/commitdiff/$hash"}, $co{'title'}) . "<br/></div>\n"; + print "<div class=\"title\">" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, $co{'title'}) . "<br/></div>\n"; print "<table cellspacing=\"0\" class=\"log\">\n"; print "<tr>\n"; print "<td class=\"head2\">"; print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]<br/>\n"; print "commit $hash<br/>\n"; - print "tree " . $cgi->a({-href => "$my_uri/$project/tree/$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; + print "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent " . $cgi->a({-href => "$my_uri/$project/tree/$par"}, $par) . "<br/>\n"; + print "parent " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$par"}, $par) . "<br/>\n"; } print "</td>"; print "</tr>\n"; @@ -501,14 +464,14 @@ if ($action eq "blob") { my $modestr = mode_str($1); if ($type eq "blob") { if ($op eq "+") { - print "added\t$modestr " . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; + print "added\t$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $file) . "\n"; } elsif ($op eq "-") { - print "removed\t$modestr " . $cgi->a({-href => "$my_uri/$project/blob/$id"}, $file) . "\n"; + print "removed\t$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $file) . "\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $old = $1; my $new = $2; - print "changed\t$modestr " . $cgi->a({-href => "$my_uri/$project/blobdiff/$old/$new"}, $file) . "\n"; + print "changed\t$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$old;hp=$new"}, $file) . "\n"; } } } @@ -531,10 +494,10 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"head2\"> view\n"; - print $cgi->a({-href => "$my_uri/$project/commit/$hash"}, "commit") . " | "; - print $cgi->a({-href => "$my_uri/$project/commitdiff/$hash"}, "diff"); + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); print "</div><br/><br/>\n"; - print "<div class=\"title\">" . $cgi->a({-href => "$my_uri/$project/commit/$hash"}, $co{'title'}) . "<br/></div>\n"; + print "<div class=\"title\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, $co{'title'}) . "<br/></div>\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' @@ -558,4 +521,10 @@ if ($action eq "blob") { print "</pre>\n"; print "<br/>"; git_footer_html(); +} else { + git_header_html(); + print "<div class=\"head2\">\n"; + print "unknown action"; + print "</div><br/><br/>\n"; + git_footer_html(); } From 54b0a43c3f64b02ecd30aceb5ad58842e4a6a4b2 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:08:03 +0200 Subject: [PATCH 023/148] v041 --- gitweb.pl | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 6452f33efe6..86c3b79813b 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 035 +# Version 041 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -27,12 +27,14 @@ my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); -my $time_back = $cgi->param('t'); +my $time_back = $cgi->param('t') || 1; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; # sanitize input $action =~ s/[^0-9a-zA-Z\.\-]//g; $project =~ s/\/\.//g; +$project =~ s/^\/+//g; +$project =~ s/\/+$//g; $project =~ s/|//g; $hash =~ s/[^0-9a-fA-F]//g; $hash_parent =~ s/[^0-9a-fA-F]//g; @@ -45,11 +47,11 @@ print <<EOF; <html> <head> <title>git - $project $action</title> - <link rel="alternate" title="$project log" href="$my_uri/$project/rss" type="application/rss+xml"/> + <link rel="alternate" title="$project log" href="$my_uri?p=$project;a=rss" type="application/rss+xml"/> <style type="text/css"> body { font-family: sans-serif; font-size: 12px; margin:25px; } div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; } - div.head1 { font-size:20px; padding:8px; background-color: #D9D8D1; font-weight:bold; } + div.head1 { font-size:18px; padding:8px; background-color: #D9D8D1; font-weight:bold; } div.head1 a:visited { color:#0000cc; } div.head1 a:hover { color:#880000; } div.head1 a:active { color:#880000; } @@ -102,7 +104,8 @@ sub git_footer_html { } sub git_head { - open my $fd, "$projectroot/$project/.git/HEAD"; + my $path = shift; + open my $fd, "$projectroot/$path/.git/HEAD"; my $head = <$fd>; close $fd; chomp $head; @@ -178,7 +181,7 @@ sub git_diff_html { } open my $fd, "-|", "/usr/bin/diff", "-L", $from_label, "-L", $to_label, "-u", "-p", $from_tmp, $to_tmp; - print "<span style =\"color: #000099;\">===== "; + print "<span style=\"color: #000099;\">===== "; if ($from ne "") { print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); } else { @@ -193,9 +196,9 @@ sub git_diff_html { print " =====</span>\n"; while (my $line = <$fd>) { my $char = substr($line,0,1); - print '<span style ="color: #008800;">' if $char eq '+'; - print '<span style ="color: #CC0000;">' if $char eq '-'; - print '<span style ="color: #990099;">' if $char eq '@'; + print '<span style="color: #008800;">' if $char eq '+'; + print '<span style="color: #CC0000;">' if $char eq '-'; + print '<span style="color: #990099;">' if $char eq '@'; print escapeHTML($line); print '</span>' if $char eq '+' or $char eq '-' or $char eq '@'; } @@ -209,15 +212,18 @@ sub git_diff_html { } } +# git cares only about the executable bit sub mode_str { my $perms = oct shift; my $modestr; - if ($perms & 040000) { $modestr .= 'd' } else { $modestr .= '-' }; - for (my $i = 0; $i < 3; $i++) { - if ($perms & 0400) { $modestr .= 'r' } else { $modestr .= '-' }; - if ($perms & 0200) { $modestr .= 'w' } else { $modestr .= '-' }; - if ($perms & 0100) { $modestr .= 'x' } else { $modestr .= '-' }; - $perms <<= 3; + if ($perms & 040000) { + $modestr .= 'drwxrwxr-x'; + } else { + if ($perms & 0100) { + $modestr .= '-rwxrwxr-x'; + } else { + $modestr .= '-rw-rw-r--'; + }; } return $modestr; } @@ -243,7 +249,7 @@ if ($action eq "git-logo.png") { # show list of default projects if ($project eq "") { opendir(my $fd, "$projectroot/$defaultprojects"); - my (@path) = grep(!/^\./, readdir($fd)); + my (@path) = sort grep(!/^\./, readdir($fd)); closedir($fd); git_header_html(); print "<div class=\"head2\">\n"; @@ -274,7 +280,7 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { - $hash = git_head(); + $hash = git_head($project); } open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; @@ -299,7 +305,7 @@ if ($action eq "blob") { print "<br/>"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list", git_head(); + open my $fd, "-|", "$gitbin/rev-list", git_head($project); my (@revtree) = map { chomp; $_ } <$fd>; close $fd; @@ -464,14 +470,14 @@ if ($action eq "blob") { my $modestr = mode_str($1); if ($type eq "blob") { if ($op eq "+") { - print "added\t$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $file) . "\n"; + print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n"; } elsif ($op eq "-") { - print "removed\t$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $file) . "\n"; + print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - my $old = $1; - my $new = $2; - print "changed\t$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$old;hp=$new"}, $file) . "\n"; + my $from = $1; + my $to = $2; + print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n"; } } } @@ -482,7 +488,7 @@ if ($action eq "blob") { git_header_html(); print "<br/><br/>\n"; print "<pre>\n"; - git_diff_html($hash, $hash_parent, $hash, $hash_parent); + git_diff_html($hash_parent, $hash, $hash_parent, $hash); print "</pre>\n"; print "<br/>"; git_footer_html(); From 86eed32d36e65dbce8572f86f8bb5087ba556ed2 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:08:29 +0200 Subject: [PATCH 024/148] v041 --- gitweb.pl | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 86c3b79813b..3897d4b5473 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -125,14 +125,18 @@ sub git_commit { $co{'tree'} = $1; } elsif ($line =~ m/^parent (.*)$/) { push @parents, $1; - } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { - $co{'committer'} = $1; - $co{'committer_time'} = $2; - $co{'committer_timezone'} = $3; } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; - $co{'author_time'} = $2; + $co{'author_time_utc'} = $2; $co{'author_timezone'} = $3; + $co{'author_timezone'} =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; + $co{'author_time_local'} = $co{'author_time_utc'} + (($1 + ($2/60)) * 3600); + } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { + $co{'committer'} = $1; + $co{'committer_time_utc'} = $2; + $co{'committer_timezone'} = $3; + $co{'committer_timezone'} =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; + $co{'committer_time_local'} = $co{'committer_time_utc'} + (($1 + ($2/60)) * 3600); } } $co{'parents'} = \@parents; @@ -228,6 +232,20 @@ sub mode_str { return $modestr; } +sub date_str { + my $date_utc = shift; + my $format = shift || "date-time"; + + my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); + my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($date_utc); + if ($format eq "date-time") { + return sprintf "%s, %d %s %4d %02d:%02d:%02d", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; + } elsif ($format eq "day-time") { + return sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; + } +} + if ($action eq "git-logo.png") { print $cgi->header(-type => 'image/png', -expires => '+1d'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". @@ -335,7 +353,7 @@ if ($action eq "blob") { for (my $i = 0; $i <= $#revtree; $i++) { my $commit = $revtree[$i]; my %co = git_commit($commit); - my $age = time - $co{'committer_time'}; + my $age = time - $co{'committer_time_utc'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -375,8 +393,8 @@ if ($action eq "blob") { print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; - print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; - print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]<br/>\n"; + print "author " . escapeHTML($co{'author'}) . " [" . date_str($co{'author_time_utc'}) . "]<br/>\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . date_str($co{'committer_time_utc'}) . "]<br/>\n"; print "</td>"; print "</tr>\n"; print "<tr>\n"; @@ -395,11 +413,7 @@ if ($action eq "blob") { print "</tr>\n"; } elsif ($action eq "rss") { last if ($i >= 20); - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($co{'author_time'}); - my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); - print "<item>\n\t<title>"; - printf("%s %02d, %02d:%02d - ", $months[$mon], $mday, $hour, $min); - print escapeHTML($co{'title'}) . "</title>\n"; + print "<item>\n\t<title>" . date_str($co{'author_time_utc'}, "day-time") . " - " . escapeHTML($co{'title'}) . "</title>\n"; print "\t<link> " . $my_url . "/$project/commit/$commit</link>\n"; print "\t<description>"; my $comment = $co{'comment'}; @@ -431,8 +445,14 @@ if ($action eq "blob") { print "<table cellspacing=\"0\" class=\"log\">\n"; print "<tr>\n"; print "<td class=\"head2\">"; - print "author " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]<br/>\n"; - print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]<br/>\n"; + print "author " . escapeHTML($co{'author'}) . " [" . date_str($co{'author_time_utc'}) . "]<br/>\n"; + + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'author_time_local'}); + if ($hour < 7 ) { print "<span style=\"color: #990000;\">"; } + print "localtime " . date_str($co{'author_time_local'}) . " " . $co{'author_timezone'} . "<br/>\n"; + if ($hour < 7 ) { print "</span>"; } + print "committer " . escapeHTML($co{'committer'}) . " [" . date_str($co{'committer_time_utc'}) . "]<br/>\n"; + print "localtime " . date_str($co{'committer_time_local'}) . " " . $co{'committer_timezone'} . "<br/>\n"; print "commit $hash<br/>\n"; print "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; my $parents = $co{'parents'}; From 991910a9ff03fa4032449d8f75a657d17fa84d86 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:09:33 +0200 Subject: [PATCH 025/148] v042 --- gitweb.pl | 60 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 3897d4b5473..dd4f963fa64 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 041 +# Version 042 # # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> @@ -127,16 +127,16 @@ sub git_commit { push @parents, $1; } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; - $co{'author_time_utc'} = $2; + $co{'author_time_epoch'} = $2; $co{'author_timezone'} = $3; - $co{'author_timezone'} =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; - $co{'author_time_local'} = $co{'author_time_utc'} + (($1 + ($2/60)) * 3600); + $co{'author_name'} = $co{'author'}; + $co{'author_name'} =~ s/ <.*//; } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { $co{'committer'} = $1; - $co{'committer_time_utc'} = $2; + $co{'committer_time_epoch'} = $2; $co{'committer_timezone'} = $3; - $co{'committer_timezone'} =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; - $co{'committer_time_local'} = $co{'committer_time_utc'} + (($1 + ($2/60)) * 3600); + $co{'committer_name'} = $co{'committer'}; + $co{'committer_name'} =~ s/ <.*//; } } $co{'parents'} = \@parents; @@ -216,13 +216,13 @@ sub git_diff_html { } } -# git cares only about the executable bit sub mode_str { my $perms = oct shift; my $modestr; if ($perms & 040000) { $modestr .= 'drwxrwxr-x'; } else { + # git cares only about the executable bit if ($perms & 0100) { $modestr .= '-rwxrwxr-x'; } else { @@ -233,17 +233,22 @@ sub mode_str { } sub date_str { - my $date_utc = shift; - my $format = shift || "date-time"; + my $epoch = shift; + my $tz = shift || "-0000"; + my %date; my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($date_utc); - if ($format eq "date-time") { - return sprintf "%s, %d %s %4d %02d:%02d:%02d", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; - } elsif ($format eq "day-time") { - return sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; - } + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch); + $date{'hour'} = $hour; + $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; + $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; + + $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; + my $local = $epoch + (($1 + ($2/60)) * 3600); + ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); + $date{'rfc2822_local'} = sprintf "%s, %d %s %4d %02d:%02d:%02d %s", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec, $tz; + return %date; } if ($action eq "git-logo.png") { @@ -353,7 +358,8 @@ if ($action eq "blob") { for (my $i = 0; $i <= $#revtree; $i++) { my $commit = $revtree[$i]; my %co = git_commit($commit); - my $age = time - $co{'committer_time_utc'}; + my %ad = date_str($co{'author_time_epoch'}); + my $age = time - $co{'committer_time_epoch'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -393,8 +399,7 @@ if ($action eq "blob") { print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n"; print "</td>\n"; print "<td class=\"head2\">\n"; - print "author " . escapeHTML($co{'author'}) . " [" . date_str($co{'author_time_utc'}) . "]<br/>\n"; - print "committer " . escapeHTML($co{'committer'}) . " [" . date_str($co{'committer_time_utc'}) . "]<br/>\n"; + print escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; print "</td>"; print "</tr>\n"; print "<tr>\n"; @@ -413,7 +418,7 @@ if ($action eq "blob") { print "</tr>\n"; } elsif ($action eq "rss") { last if ($i >= 20); - print "<item>\n\t<title>" . date_str($co{'author_time_utc'}, "day-time") . " - " . escapeHTML($co{'title'}) . "</title>\n"; + print "<item>\n\t<title>" . $ad{'mday-time'} . " - " . escapeHTML($co{'title'}) . "</title>\n"; print "\t<link> " . $my_url . "/$project/commit/$commit</link>\n"; print "\t<description>"; my $comment = $co{'comment'}; @@ -432,6 +437,8 @@ if ($action eq "blob") { } } elsif ($action eq "commit") { my %co = git_commit($hash); + my %ad = date_str($co{'author_time_epoch'}, $co{'author_time_zone'}); + my %cd = date_str($co{'committer_time_epoch'}, $co{'committer_time_zone'}); open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -445,14 +452,11 @@ if ($action eq "blob") { print "<table cellspacing=\"0\" class=\"log\">\n"; print "<tr>\n"; print "<td class=\"head2\">"; - print "author " . escapeHTML($co{'author'}) . " [" . date_str($co{'author_time_utc'}) . "]<br/>\n"; - - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'author_time_local'}); - if ($hour < 7 ) { print "<span style=\"color: #990000;\">"; } - print "localtime " . date_str($co{'author_time_local'}) . " " . $co{'author_timezone'} . "<br/>\n"; - if ($hour < 7 ) { print "</span>"; } - print "committer " . escapeHTML($co{'committer'}) . " [" . date_str($co{'committer_time_utc'}) . "]<br/>\n"; - print "localtime " . date_str($co{'committer_time_local'}) . " " . $co{'committer_timezone'} . "<br/>\n"; + print "author " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; + if ($ad{'hour'} < 7 ) { print "<span style=\"color: #990000;\">"; } + print "localtime " . $ad{'rfc2822_local'} . "<br/>\n"; + if ($ad{'hour'} < 7 ) { print "</span>"; } + print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]<br/>\n"; print "commit $hash<br/>\n"; print "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; my $parents = $co{'parents'}; From fbb592a91ed2e2d7216d162831aeaea1ed12a6cf Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:12:11 +0200 Subject: [PATCH 026/148] v043 --- gitweb.pl | 143 ++++++++++++++++++++++-------------------------------- 1 file changed, 59 insertions(+), 84 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dd4f963fa64..cdf0e3d7523 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,8 +2,6 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 042 -# # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> # @@ -16,6 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; +my $version = "043"; my $projectroot = "/"; my $defaultprojects = "home/kay/public_html"; my $gitbin = "/home/kay/bin/git"; @@ -49,41 +48,30 @@ print <<EOF; <title>git - $project $action</title> <link rel="alternate" title="$project log" href="$my_uri?p=$project;a=rss" type="application/rss+xml"/> <style type="text/css"> - body { font-family: sans-serif; font-size: 12px; margin:25px; } - div.body { border-width:1px; border-style:solid; border-color:#D9D8D1; } - div.head1 { font-size:18px; padding:8px; background-color: #D9D8D1; font-weight:bold; } - div.head1 a:visited { color:#0000cc; } - div.head1 a:hover { color:#880000; } - div.head1 a:active { color:#880000; } - div.head2 { padding:8px; } - div.head2 a:visited { color:#0000cc; } - div.head2 a:hover { color:#880000; } - div.head2 a:active { color:#880000; } - div.title { padding:8px; background-color: #D9D8D1; font-weight:bold; } - div.title a { color:#000000; text-decoration:none; } - div.title a:hover { color:#880000; text-decoration:underline; } - div.title a:visited { color:#000000; } - table { padding:0px; margin:0px; width:100%; } - tr { vertical-align:top; } - td { padding:8px; margin:0px; font-family: sans-serif; font-size: 12px; } - td.head1 { background-color: #D9D8D1; font-weight:bold; } - td.head1 a { color:#000000; text-decoration:none; } - td.head1 a:hover { color:#880000; text-decoration:underline; } - td.head1 a:visited { color:#000000; } - td.head2 { background-color: #EDECE6; font-family: monospace; font-size:12px; } - td.head3 { background-color: #EDECE6; font-size:10px; } - div.signed_off { color: #a9a8a1; } + body { font-family: sans-serif; font-size: 12px; margin:0px; } a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } a:active { color:#880000; } - pre { padding:8px; } + div.page_header { margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; clear:both; font-weight:bold; background-color: #D9D8D1; } + div.page_nav { margin:0px 25px; padding:8px; clear:both; border: solid #D9D8D1; border-width:0px 1px; } + div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; clear:both; background-color: #D9D8D1; } + div.page_footer_text { float:left; color:#888888; font-size:10px;} + div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #D9D8D1; border-width:0px 1px; } + a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #D9D8D1; text-decoration:none; color:#000000; } + a.log_title:hover { background-color: #c9c8c1; } + a.xml_logo { float:right; border:1px solid; border-color:#FCC7A5 #7D3302 #3E1A01 #FF954E; width:35px; color:#ffffff; background-color:#FF6600; font-weight:bold; font-family:sans-serif; text-align:center; font-size:11px; display:block; text-decoration:none; } + a.xml_logo:hover { background-color:#ee5500; } + div.log_head { margin:0px 25px; min-height: 30px; padding:8px; clear:both; border: solid #D9D8D1; border-width:0px 1px; font-family:monospace; background-color: #EDECE6; } + div.log_body { margin:0px 25px; padding:8px; padding-left:150px; clear:both; border: solid #D9D8D1; border-width:0px 1px; } + div.log_age { position:relative; float:left; width:142px; } + div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } + div.signed_off { color: #a9a8a1; } </style> </head> <body> EOF - print "<div class=\"body\">\n"; - print "<div class=\"head1\">"; + print "<div class=\"page_header\">"; print "<a href=\"http://kernel.org/pub/software/scm/git/\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { @@ -99,7 +87,12 @@ EOF } sub git_footer_html { - print "</div>\n"; + print "<div class=\"page_footer\">"; + print "<div class=\"page_footer_text\">version $version</div>"; + if ($project ne '') { + print "<a href=\"$my_uri?p=$project;a=rss\" class=\"xml_logo\">XML</a>"; + } + print "</div>"; print "</body>\n</html>"; } @@ -275,31 +268,30 @@ if ($project eq "") { my (@path) = sort grep(!/^\./, readdir($fd)); closedir($fd); git_header_html(); - print "<div class=\"head2\">\n"; + print "<div class=\"page_body\">\n"; print "<br/><br/>\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "<br/>\n"; } } - print "</div><br/>"; + print "<br/></div>"; git_footer_html(); exit; } if ($action eq "blob") { git_header_html(); - print "<br/><br/>\n"; - print "<pre>\n"; + print "<div class=\"page_body\"><pre><br/><br/>\n"; open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; my $nr; while (my $line = <$fd>) { $nr++; - printf "<span style =\"color: #999999;\">%3i\t</span>%s", $nr, escapeHTML($line);; + printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);; } close $fd; - print "</pre>\n"; - print "<br/>"; + print "<br/><br/></pre>\n"; + print "</div>"; git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { @@ -309,8 +301,8 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "<br/><br/>\n"; - print "<pre>\n"; + print "<div class=\"page_body\">\n"; + print "<br/><pre>\n"; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -325,7 +317,7 @@ if ($action eq "blob") { } } print "</pre>\n"; - print "<br/>"; + print "<br/></div>"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { open my $fd, "-|", "$gitbin/rev-list", git_head($project); @@ -334,7 +326,7 @@ if ($action eq "blob") { if ($action eq "log") { git_header_html(); - print "<div class=\"head2\">\n"; + print "<div class=\"page_nav\">\n"; print "view "; print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | "; print $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | "; @@ -343,7 +335,6 @@ if ($action eq "blob") { print $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; print "<br/><br/>\n"; print "</div>\n"; - print "<table cellspacing=\"0\" class=\"log\">\n"; } elsif ($action eq "rss") { print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". @@ -383,28 +374,22 @@ if ($action eq "blob") { if ($action eq "log") { if ($time_back > 0 && $age > $time_back*60*60*24) { if ($i == 0) { - print "<tr>\n"; - print "<td class=\"head1\"> Last change $age_string. </td>\n"; - print "</tr>\n"; + print "<div class=\"page_body\"> Last change $age_string.<br/><br/></div>\n"; } last; } - print "<tr>\n"; - print "<td class=\"head1\">" . $age_string . "</td>\n"; - print "<td class=\"head1\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, $co{'title'}) . "</td>"; - print "</tr>\n"; - print "<tr>\n"; - print "<td class=\"head3\">"; + print "<a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">"; + print "<div class=\"log_age\">" . $age_string . "</div>\n"; + print $co{'title'}; + print "</a>\n"; + print "<div class=\"log_head\">\n"; + print "<div class=\"log_functions\">"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n"; - print "</td>\n"; - print "<td class=\"head2\">\n"; + print "</div>\n"; print escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; - print "</td>"; - print "</tr>\n"; - print "<tr>\n"; - print "<td></td>\n"; - print "<td>\n"; + print "</div>"; + print "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(signed-off|acked)-by:/i) { @@ -414,8 +399,7 @@ if ($action eq "blob") { } } print "<br/><br/>\n"; - print "</td>"; - print "</tr>\n"; + print "</div>"; } elsif ($action eq "rss") { last if ($i >= 20); print "<item>\n\t<title>" . $ad{'mday-time'} . " - " . escapeHTML($co{'title'}) . "</title>\n"; @@ -430,7 +414,6 @@ if ($action eq "blob") { } } if ($action eq "log") { - print "</table>\n"; git_footer_html(); } elsif ($action eq "rss") { print "</channel></rss>"; @@ -444,17 +427,14 @@ if ($action eq "blob") { close $fd; git_header_html(); - print "<div class=\"head2\"> view\n"; + print "<div class=\"page_nav\"> view\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "</div><br/><br/>\n"; - print "<div class=\"title\">" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, $co{'title'}) . "<br/></div>\n"; - print "<table cellspacing=\"0\" class=\"log\">\n"; - print "<tr>\n"; - print "<td class=\"head2\">"; + print "<br/><br/></div>\n"; + print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n"; + print "<div class=\"log_head\">"; print "author " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; if ($ad{'hour'} < 7 ) { print "<span style=\"color: #990000;\">"; } - print "localtime " . $ad{'rfc2822_local'} . "<br/>\n"; if ($ad{'hour'} < 7 ) { print "</span>"; } print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]<br/>\n"; print "commit $hash<br/>\n"; @@ -463,10 +443,8 @@ if ($action eq "blob") { foreach my $par (@$parents) { print "parent " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$par"}, $par) . "<br/>\n"; } - print "</td>"; - print "</tr>\n"; - print "<tr>\n"; - print "<td>\n"; + print "</div>"; + print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/(signed-off|acked)-by:/i) { @@ -476,10 +454,6 @@ if ($action eq "blob") { } } print "<br/><br/>\n"; - print "</td>"; - print "</tr>\n"; - print "</table>"; - print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' @@ -506,15 +480,15 @@ if ($action eq "blob") { } } print "</pre>\n"; - print "<br/>"; + print "<br/></div>"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); - print "<br/><br/>\n"; + print "<div class=\"page_body\"><br/><br/>\n"; print "<pre>\n"; git_diff_html($hash_parent, $hash, $hash_parent, $hash); print "</pre>\n"; - print "<br/>"; + print "<br/></div>"; git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); @@ -523,11 +497,12 @@ if ($action eq "blob") { close $fd; git_header_html(); - print "<div class=\"head2\"> view\n"; + print "<div class=\"page_nav\"> view\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "</div><br/><br/>\n"; - print "<div class=\"title\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, $co{'title'}) . "<br/></div>\n"; + print "<br/><br/></div>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; + print "<div class=\"page_body\">\n"; print "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' @@ -548,8 +523,8 @@ if ($action eq "blob") { } } } - print "</pre>\n"; - print "<br/>"; + print "<br/></pre>\n"; + print "</div>"; git_footer_html(); } else { git_header_html(); From ff7669a5b9922e86831e59398e89bad1372dc581 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:13:02 +0200 Subject: [PATCH 027/148] v048 --- gitweb.pl | 185 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 83 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index cdf0e3d7523..643787f1824 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "043"; +my $version = "048"; my $projectroot = "/"; my $defaultprojects = "home/kay/public_html"; my $gitbin = "/home/kay/bin/git"; @@ -26,7 +26,10 @@ my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); -my $time_back = $cgi->param('t') || 1; +my $time_back = $cgi->param('t'); +if (!(defined($time_back))) { + $time_back = 1; +} $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; # sanitize input @@ -53,26 +56,33 @@ print <<EOF; a:hover { color:#880000; } a:visited { color:#880000; } a:active { color:#880000; } - div.page_header { margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; clear:both; font-weight:bold; background-color: #D9D8D1; } - div.page_nav { margin:0px 25px; padding:8px; clear:both; border: solid #D9D8D1; border-width:0px 1px; } - div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; clear:both; background-color: #D9D8D1; } - div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #D9D8D1; border-width:0px 1px; } - a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #D9D8D1; text-decoration:none; color:#000000; } - a.log_title:hover { background-color: #c9c8c1; } - a.xml_logo { float:right; border:1px solid; border-color:#FCC7A5 #7D3302 #3E1A01 #FF954E; width:35px; color:#ffffff; background-color:#FF6600; font-weight:bold; font-family:sans-serif; text-align:center; font-size:11px; display:block; text-decoration:none; } - a.xml_logo:hover { background-color:#ee5500; } - div.log_head { margin:0px 25px; min-height: 30px; padding:8px; clear:both; border: solid #D9D8D1; border-width:0px 1px; font-family:monospace; background-color: #EDECE6; } - div.log_body { margin:0px 25px; padding:8px; padding-left:150px; clear:both; border: solid #D9D8D1; border-width:0px 1px; } - div.log_age { position:relative; float:left; width:142px; } - div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } + div.page_header { margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1; } + div.page_header a:visited { color:#0000cc; } + div.page_nav { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + div.page_nav a:visited { color:#0000cc; } + div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; clear:both; background-color: #d9d8d1; } + div.page_footer_text { float:left; color:#888888; font-size:10px;} + div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; } + a.log_title:hover { background-color: #c9c8c1; } + a.xml_logo { float:right; border:1px solid; + border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; text-align:center; font-size:11px; display:block; text-decoration:none; + } + a.xml_logo:hover { background-color:#ee5500; } + div.log_head { margin:0px 25px; min-height: 30px; padding:8px; clear:both; + border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6; + } + div.log_body { margin:0px 25px; padding:8px; padding-left:150px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + span.log_age { position:relative; float:left; width:142px; } + div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } div.signed_off { color: #a9a8a1; } </style> </head> <body> EOF - print "<div class=\"page_header\">"; - print "<a href=\"http://kernel.org/pub/software/scm/git/\">" . + print "<div class=\"page_header\">\n" . + "<a href=\"http://kernel.org/pub/software/scm/git/\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; @@ -89,9 +99,9 @@ EOF sub git_footer_html { print "<div class=\"page_footer\">"; print "<div class=\"page_footer_text\">version $version</div>"; - if ($project ne '') { - print "<a href=\"$my_uri?p=$project;a=rss\" class=\"xml_logo\">XML</a>"; - } + if ($project ne '') { + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; + } print "</div>"; print "</body>\n</html>"; } @@ -110,7 +120,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + open my $fd, "-|", "$gitbin/cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -153,11 +163,11 @@ sub git_diff_html { my $to_label = "/dev/null"; my $pid = $$; - # create temp from-file + # create tmp from-file if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open my $fd2, "> $from_tmp"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $from; + open my $fd, "-|", "$gitbin/cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -169,7 +179,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $to; + open my $fd, "-|", "$gitbin/cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -177,7 +187,7 @@ sub git_diff_html { $to_label = "b/$to_name"; } - open my $fd, "-|", "/usr/bin/diff", "-L", $from_label, "-L", $to_label, "-u", "-p", $from_tmp, $to_tmp; + open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp"; print "<span style=\"color: #000099;\">===== "; if ($from ne "") { print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); @@ -234,6 +244,10 @@ sub date_str { my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch); $date{'hour'} = $hour; + $date{'minute'} = $min; + $date{'mday'} = $mday; + $date{'day'} = $days[$wday]; + $date{'month'} = $months[$mon]; $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; @@ -280,10 +294,14 @@ if ($project eq "") { exit; } +if ($action eq "") { + $action = "log"; +} + if ($action eq "blob") { git_header_html(); print "<div class=\"page_body\"><pre><br/><br/>\n"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; + open my $fd, "-|", "$gitbin/cat-file blob $hash"; my $nr; while (my $line = <$fd>) { $nr++; @@ -297,7 +315,7 @@ if ($action eq "blob") { if ($hash eq "") { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/ls-tree", $hash; + open my $fd, "-|", "$gitbin/ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); @@ -320,7 +338,7 @@ if ($action eq "blob") { print "<br/></div>"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list", git_head($project); + open my $fd, "-|", "$gitbin/rev-list " . git_head($project); my (@revtree) = map { chomp; $_ } <$fd>; close $fd; @@ -328,13 +346,13 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\">\n"; print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; - print "<br/><br/>\n"; - print "</div>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; + print "<br/><br/>\n" . + "</div>\n"; } elsif ($action eq "rss") { print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". @@ -372,24 +390,23 @@ if ($action eq "blob") { $age_string .= " minutes ago"; } if ($action eq "log") { - if ($time_back > 0 && $age > $time_back*60*60*24) { + if ($time_back > 0 && $age > $time_back*60*60*24) { if ($i == 0) { print "<div class=\"page_body\"> Last change $age_string.<br/><br/></div>\n"; } last; } - print "<a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">"; - print "<div class=\"log_age\">" . $age_string . "</div>\n"; - print $co{'title'}; - print "</a>\n"; - print "<div class=\"log_head\">\n"; - print "<div class=\"log_functions\">"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n"; - print "</div>\n"; - print escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; - print "</div>"; - print "<div class=\"log_body\">\n"; + print "<div><a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">\n" . + "<span class=\"log_age\">" . $age_string . "</span>\n" . escapeHTML($co{'title'}) . "</a>\n" . + "</div>\n"; + print "<div class=\"log_head\">\n" . + "<div class=\"log_functions\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n" . + "</div>\n" . + escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n" . + "</div>\n" . + "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(signed-off|acked)-by:/i) { @@ -398,19 +415,20 @@ if ($action eq "blob") { print escapeHTML($line) . "<br/>\n"; } } - print "<br/><br/>\n"; - print "</div>"; + print "<br/><br/>\n" . + "</div>\n"; } elsif ($action eq "rss") { last if ($i >= 20); - print "<item>\n\t<title>" . $ad{'mday-time'} . " - " . escapeHTML($co{'title'}) . "</title>\n"; - print "\t<link> " . $my_url . "/$project/commit/$commit</link>\n"; - print "\t<description>"; + print "<item>\n" . + "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . + "\t<link> " . $my_url . "?p=$project;a==commit;h=$commit</link>\n" . + "\t<description>"; my $comment = $co{'comment'}; foreach my $line (@$comment) { print escapeHTML($line) . "\n"; } - print "\t</description>\n"; - print "</item>\n"; + print "\t</description>\n" . + "</item>\n"; } } if ($action eq "log") { @@ -422,28 +440,28 @@ if ($action eq "blob") { my %co = git_commit($hash); my %ad = date_str($co{'author_time_epoch'}, $co{'author_time_zone'}); my %cd = date_str($co{'committer_time_epoch'}, $co{'committer_time_zone'}); - open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "<div class=\"page_nav\"> view\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "<br/><br/></div>\n"; + print "<div class=\"page_nav\"> view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + "<br/><br/></div>\n"; print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n"; - print "<div class=\"log_head\">"; - print "author " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; + print "<div class=\"log_head\">" . + "author " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; if ($ad{'hour'} < 7 ) { print "<span style=\"color: #990000;\">"; } if ($ad{'hour'} < 7 ) { print "</span>"; } - print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]<br/>\n"; - print "commit $hash<br/>\n"; - print "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]<br/>\n" . + "commit $hash<br/>\n" . + "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$par"}, $par) . "<br/>\n"; + print "parent " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n"; } - print "</div>"; + print "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -479,31 +497,31 @@ if ($action eq "blob") { } } } - print "</pre>\n"; - print "<br/></div>"; + print "</pre>\n" . + "<br/></div>"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); - print "<div class=\"page_body\"><br/><br/>\n"; - print "<pre>\n"; + print "<div class=\"page_body\"><br/><br/>\n" . + "<pre>\n"; git_diff_html($hash_parent, $hash, $hash_parent, $hash); - print "</pre>\n"; - print "<br/></div>"; + print "</pre>\n" . + "<br/></div>"; git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); - open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "<div class=\"page_nav\"> view\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "<br/><br/></div>\n"; + print "<div class=\"page_nav\"> view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + "<br/><br/></div>\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; - print "<div class=\"page_body\">\n"; - print "<pre>\n"; + print "<div class=\"page_body\">\n" . + "<pre>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; @@ -528,8 +546,9 @@ if ($action eq "blob") { git_footer_html(); } else { git_header_html(); - print "<div class=\"head2\">\n"; - print "unknown action"; - print "</div><br/><br/>\n"; + print "<div class=\"page_body\">\n" . + "<br/><br/>\n"; + print "unknown action\n"; + print "<br/></div>\n"; git_footer_html(); } From 185f09e5ba4031f689659045a7f840a14b5ab909 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:13:11 +0200 Subject: [PATCH 028/148] v049 --- gitweb.pl | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 643787f1824..096786b932b 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "048"; +my $version = "049"; my $projectroot = "/"; my $defaultprojects = "home/kay/public_html"; my $gitbin = "/home/kay/bin/git"; @@ -130,14 +130,14 @@ sub git_commit { push @parents, $1; } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; - $co{'author_time_epoch'} = $2; - $co{'author_timezone'} = $3; + $co{'author_epoch'} = $2; + $co{'author_tz'} = $3; $co{'author_name'} = $co{'author'}; $co{'author_name'} =~ s/ <.*//; } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { $co{'committer'} = $1; - $co{'committer_time_epoch'} = $2; - $co{'committer_timezone'} = $3; + $co{'committer_epoch'} = $2; + $co{'committer_tz'} = $3; $co{'committer_name'} = $co{'committer'}; $co{'committer_name'} =~ s/ <.*//; } @@ -254,7 +254,9 @@ sub date_str { $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; my $local = $epoch + (($1 + ($2/60)) * 3600); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); - $date{'rfc2822_local'} = sprintf "%s, %d %s %4d %02d:%02d:%02d %s", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec, $tz; + $date{'hour_local'} = $hour; + $date{'minute_local'} = $min; + $date{'tz_local'} = $tz; return %date; } @@ -367,8 +369,8 @@ if ($action eq "blob") { for (my $i = 0; $i <= $#revtree; $i++) { my $commit = $revtree[$i]; my %co = git_commit($commit); - my %ad = date_str($co{'author_time_epoch'}); - my $age = time - $co{'committer_time_epoch'}; + my %ad = date_str($co{'author_epoch'}); + my $age = time - $co{'committer_epoch'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -438,8 +440,8 @@ if ($action eq "blob") { } } elsif ($action eq "commit") { my %co = git_commit($hash); - my %ad = date_str($co{'author_time_epoch'}, $co{'author_time_zone'}); - my %cd = date_str($co{'committer_time_epoch'}, $co{'committer_time_zone'}); + my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); + my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -450,16 +452,22 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . "<br/><br/></div>\n"; print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n"; - print "<div class=\"log_head\">" . - "author " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]<br/>\n"; - if ($ad{'hour'} < 7 ) { print "<span style=\"color: #990000;\">"; } - if ($ad{'hour'} < 7 ) { print "</span>"; } - print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]<br/>\n" . - "commit $hash<br/>\n" . - "tree " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; + print "<div class=\"log_head\">\n"; + print "author " . escapeHTML($co{'author'}) . "<br/>\n"; + print "author-time " . $ad{'rfc2822'}; + if ($ad{'hour_local'} < 6) { print "<span style=\"color: #cc0000;\">"; } + printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); + if ($ad{'hour_local'} < 6 ) { print "</span>"; } + print "<br/>\n"; + print "committer " . escapeHTML($co{'committer'}) . "<br/>\n"; + print "commit-time " . $ad{'rfc2822'}; + printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); + print "<br/>\n"; + print "commit   $hash<br/>\n"; + print "tree  " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n"; + print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n"; } print "</div>\n"; print "<div class=\"page_body\">\n"; From 2ad9331e15fba4476cb734f46b845638ee82222e Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:14:48 +0200 Subject: [PATCH 029/148] v053 rename gitweb.pl to gitweb.cgi --- gitweb.pl => gitweb.cgi | 113 +++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 43 deletions(-) rename gitweb.pl => gitweb.cgi (85%) diff --git a/gitweb.pl b/gitweb.cgi similarity index 85% rename from gitweb.pl rename to gitweb.cgi index 096786b932b..017664b8f44 100755 --- a/gitweb.pl +++ b/gitweb.cgi @@ -14,14 +14,17 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "049"; -my $projectroot = "/"; -my $defaultprojects = "home/kay/public_html"; -my $gitbin = "/home/kay/bin/git"; -my $gittmp = "/tmp"; +my $version = "053"; +my $projectroot = "/pub/scm"; +my $defaultprojects = "linux/kernel/git"; +my $gitbin = "/usr/bin"; +my $gittmp = "/tmp/gitweb"; +my $giturl = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +mkdir($gittmp, 0700); + my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); @@ -30,17 +33,19 @@ my $time_back = $cgi->param('t'); if (!(defined($time_back))) { $time_back = 1; } -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; # sanitize input $action =~ s/[^0-9a-zA-Z\.\-]//g; -$project =~ s/\/\.//g; -$project =~ s/^\/+//g; -$project =~ s/\/+$//g; -$project =~ s/|//g; $hash =~ s/[^0-9a-fA-F]//g; $hash_parent =~ s/[^0-9a-fA-F]//g; $time_back =~ s/[^0-9]+//g; +if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { + print $cgi->header(-type=>'text/plain', -status=>'403 Permission denied'); + print "Malformed query, file missing or permission denied\n"; + exit 0; +} +$project =~ s/|//g; sub git_header_html { print $cgi->header(-type => 'text/html', -charset => 'utf-8'); @@ -51,38 +56,55 @@ print <<EOF; <title>git - $project $action</title> <link rel="alternate" title="$project log" href="$my_uri?p=$project;a=rss" type="application/rss+xml"/> <style type="text/css"> - body { font-family: sans-serif; font-size: 12px; margin:0px; } - a { color:#0000cc; } - a:hover { color:#880000; } - a:visited { color:#880000; } - a:active { color:#880000; } - div.page_header { margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1; } - div.page_header a:visited { color:#0000cc; } - div.page_nav { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } - div.page_nav a:visited { color:#0000cc; } - div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; clear:both; background-color: #d9d8d1; } - div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } - a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; } - a.log_title:hover { background-color: #c9c8c1; } - a.xml_logo { float:right; border:1px solid; - border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; text-align:center; font-size:11px; display:block; text-decoration:none; - } - a.xml_logo:hover { background-color:#ee5500; } - div.log_head { margin:0px 25px; min-height: 30px; padding:8px; clear:both; - border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6; - } - div.log_body { margin:0px 25px; padding:8px; padding-left:150px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } - span.log_age { position:relative; float:left; width:142px; } - div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.signed_off { color: #a9a8a1; } + body { font-family: sans-serif; font-size: 12px; margin:0px; } + a { color:#0000cc; } + a:hover { color:#880000; } + a:visited { color:#880000; } + a:active { color:#880000; } + div.page_header { + margin:15px 25px 0px; height:25px; padding:8px; + font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1; + } + div.page_header a:visited { color:#0000cc; } + div.page_nav { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } + div.page_nav a:visited { color:#0000cc; } + div.page_footer { + margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; + clear:both; background-color: #d9d8d1; + } + div.page_footer_text { float:left; color:#888888; font-size:10px;} + div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + a.log_title { + display:block; margin:0px 25px; padding:8px; clear:both; + font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; + } + a.log_title:hover { background-color: #c9c8c1; } + a.xml_logo { float:right; border:1px solid; + line-height:15px; + border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; + color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; text-align:center; + font-size:11px; display:block; text-decoration:none; + } + a.xml_logo:hover { background-color:#ee5500; } + div.log_head { + margin:0px 25px; min-height: 30px; padding:8px; clear:both; + border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; + background-color: #edece6; + } + div.log_body { + margin:0px 25px; padding:8px; padding-left:150px; clear:both; + border:solid #d9d8d1; border-width:0px 1px; + } + span.log_age { position:relative; float:left; width:142px; } + div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } + div.signed_off { color: #a9a8a1; } </style> </head> <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"http://kernel.org/pub/software/scm/git/\">" . + "<a href=\"$giturl\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; @@ -108,7 +130,7 @@ sub git_footer_html { sub git_head { my $path = shift; - open my $fd, "$projectroot/$path/.git/HEAD"; + open my $fd, "$projectroot/$path/HEAD"; my $head = <$fd>; close $fd; chomp $head; @@ -281,14 +303,19 @@ if ($action eq "git-logo.png") { # show list of default projects if ($project eq "") { opendir(my $fd, "$projectroot/$defaultprojects"); - my (@path) = sort grep(!/^\./, readdir($fd)); + my (@users) = sort grep(!/^\./, readdir($fd)); closedir($fd); git_header_html(); print "<div class=\"page_body\">\n"; print "<br/><br/>\n"; - foreach my $line (@path) { - if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { - print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "<br/>\n"; + foreach my $user (@users) { + opendir($fd, "$projectroot/$defaultprojects/$user"); + my (@repos) = sort grep(/\.git$/, readdir($fd)); + closedir($fd); + foreach my $repo (@repos) { + if (-e "$projectroot/$defaultprojects/$user/$repo/HEAD") { + print $cgi->a({-href => "$my_uri?p=$defaultprojects/$user/$repo;a=log"}, "$defaultprojects/$user/$repo") . "<br/>\n"; + } } } print "<br/></div>"; @@ -506,7 +533,7 @@ if ($action eq "blob") { } } print "</pre>\n" . - "<br/></div>"; + "<br/></div>\n"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); From a59d4afd69e497193ac63c8633431f9b32211b4d Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:15:44 +0200 Subject: [PATCH 030/148] v055 --- gitweb.cgi | 66 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 017664b8f44..8c46a3a04bb 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,42 +14,45 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "053"; -my $projectroot = "/pub/scm"; +my $version = "055"; +my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; -my $gitbin = "/usr/bin"; -my $gittmp = "/tmp/gitweb"; -my $giturl = "/pub/software/scm/cogito"; +my $gitbin = "/home/kay/bin/git"; +my $gittmp = "/tmp"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -mkdir($gittmp, 0700); - my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); my $time_back = $cgi->param('t'); -if (!(defined($time_back))) { - $time_back = 1; -} $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; -# sanitize input -$action =~ s/[^0-9a-zA-Z\.\-]//g; -$hash =~ s/[^0-9a-fA-F]//g; -$hash_parent =~ s/[^0-9a-fA-F]//g; -$time_back =~ s/[^0-9]+//g; +# validate input if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - print $cgi->header(-type=>'text/plain', -status=>'403 Permission denied'); - print "Malformed query, file missing or permission denied\n"; - exit 0; + error_page("403 Permission denied", "Invalid project parameter."); +} +if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { + error_page("403 Permission denied", "Invalid action parameter."); +} +if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { + error_page("403 Permission denied", "Invalid hash parameter."); +} +if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { + error_page("403 Permission denied", "Invalid parent hash parameter."); +} +if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { + error_page("403 Permission denied", "Invalid time parameter."); +} else { + $time_back = 1; } -$project =~ s/|//g; sub git_header_html { - print $cgi->header(-type => 'text/html', -charset => 'utf-8'); -print <<EOF; + my $status = shift || "200 OK"; + + print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); + print <<EOF; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> @@ -104,7 +107,7 @@ print <<EOF; <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"$giturl\">" . + "<a href=\"http://kernel.org/pub/software/scm/git/\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; @@ -128,6 +131,18 @@ sub git_footer_html { print "</body>\n</html>"; } +sub error_page { + my $status = shift || "403 Permission denied"; + my $error = shift || "Malformed query, file missing or permission denied"; + git_header_html($status); + print "<div class=\"page_body\">\n" . + "<br/><br/>\n"; + print "$error\n"; + print "<br/></div>\n"; + git_footer_html(); + exit 0; +} + sub git_head { my $path = shift; open my $fd, "$projectroot/$path/HEAD"; @@ -580,10 +595,5 @@ if ($action eq "blob") { print "</div>"; git_footer_html(); } else { - git_header_html(); - print "<div class=\"page_body\">\n" . - "<br/><br/>\n"; - print "unknown action\n"; - print "<br/></div>\n"; - git_footer_html(); + error_page("403 Forbidden", "unknown action"); } From 061cc7cdcfda9527f5afb986e0396e393ed0c9f5 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:15:57 +0200 Subject: [PATCH 031/148] v056 --- gitweb.cgi | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 8c46a3a04bb..c702c9a2ef3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "055"; +my $version = "056"; my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/home/kay/bin/git"; @@ -31,19 +31,19 @@ $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; # validate input if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - error_page("403 Permission denied", "Invalid project parameter."); + die_error("", "Invalid project parameter."); } if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { - error_page("403 Permission denied", "Invalid action parameter."); + die_error("", "Invalid action parameter."); } if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { - error_page("403 Permission denied", "Invalid hash parameter."); + die_error("", "Invalid hash parameter."); } if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { - error_page("403 Permission denied", "Invalid parent hash parameter."); + die_error("", "Invalid parent hash parameter."); } if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { - error_page("403 Permission denied", "Invalid time parameter."); + die_error("", "Invalid time parameter."); } else { $time_back = 1; } @@ -131,8 +131,8 @@ sub git_footer_html { print "</body>\n</html>"; } -sub error_page { - my $status = shift || "403 Permission denied"; +sub die_error { + my $status = shift || "403 Forbidden"; my $error = shift || "Malformed query, file missing or permission denied"; git_header_html($status); print "<div class=\"page_body\">\n" . @@ -145,7 +145,7 @@ sub error_page { sub git_head { my $path = shift; - open my $fd, "$projectroot/$path/HEAD"; + open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory.");; my $head = <$fd>; close $fd; chomp $head; @@ -179,6 +179,7 @@ sub git_commit { $co{'committer_name'} =~ s/ <.*//; } } + if (!defined($co{'tree'})) { die_error("", "Invalid commit object."); } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; @@ -203,7 +204,7 @@ sub git_diff_html { # create tmp from-file if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; - open my $fd2, "> $from_tmp"; + open(my $fd2, "> $from_tmp"); open my $fd, "-|", "$gitbin/cat-file blob $from"; my @file = <$fd>; print $fd2 @file; @@ -317,7 +318,7 @@ if ($action eq "git-logo.png") { # show list of default projects if ($project eq "") { - opendir(my $fd, "$projectroot/$defaultprojects"); + opendir(my $fd, "$projectroot/$defaultprojects") || die_error("", "No projects found."); my (@users) = sort grep(!/^\./, readdir($fd)); closedir($fd); git_header_html(); @@ -345,7 +346,7 @@ if ($action eq "") { if ($action eq "blob") { git_header_html(); print "<div class=\"page_body\"><pre><br/><br/>\n"; - open my $fd, "-|", "$gitbin/cat-file blob $hash"; + open(my $fd, "-|", "$gitbin/cat-file blob $hash"); my $nr; while (my $line = <$fd>) { $nr++; @@ -595,5 +596,5 @@ if ($action eq "blob") { print "</div>"; git_footer_html(); } else { - error_page("403 Forbidden", "unknown action"); + die_error("", "unknown action"); } From d51e902a09f96029b01141b41e297ec7774f55c0 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:16:07 +0200 Subject: [PATCH 032/148] v057 --- gitweb.cgi | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index c702c9a2ef3..89c3df736f9 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "056"; +my $version = "057"; my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/home/kay/bin/git"; @@ -26,6 +26,7 @@ my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); +my $file_name = $cgi->param('f'); my $time_back = $cgi->param('t'); $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; @@ -33,6 +34,9 @@ $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { die_error("", "Invalid project parameter."); } +if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { + die_error("", "Invalid file parameter."); +} if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { die_error("", "Invalid action parameter."); } @@ -44,8 +48,6 @@ if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { } if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { die_error("", "Invalid time parameter."); -} else { - $time_back = 1; } sub git_header_html { @@ -339,10 +341,14 @@ if ($project eq "") { exit; } -if ($action eq "") { +if (!defined($action)) { $action = "log"; } +if (!defined($time_back)) { + $time_back = 1; +} + if ($action eq "blob") { git_header_html(); print "<div class=\"page_body\"><pre><br/><br/>\n"; @@ -384,7 +390,7 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { open my $fd, "-|", "$gitbin/rev-list " . git_head($project); - my (@revtree) = map { chomp; $_ } <$fd>; + my (@revlist) = map { chomp; $_ } <$fd>; close $fd; if ($action eq "log") { @@ -409,8 +415,8 @@ if ($action eq "blob") { "<language>en</language>\n"; } - for (my $i = 0; $i <= $#revtree; $i++) { - my $commit = $revtree[$i]; + for (my $i = 0; $i <= $#revlist; $i++) { + my $commit = $revlist[$i]; my %co = git_commit($commit); my %ad = date_str($co{'author_epoch'}); my $age = time - $co{'committer_epoch'}; @@ -466,7 +472,7 @@ if ($action eq "blob") { last if ($i >= 20); print "<item>\n" . "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . - "\t<link> " . $my_url . "?p=$project;a==commit;h=$commit</link>\n" . + "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" . "\t<description>"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -544,7 +550,8 @@ if ($action eq "blob") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $from = $1; my $to = $2; - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n"; + print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . " (" . + $cgi->a({-href => "$my_uri?p=$project;a=filerevision;h=$hash;f=$file"}, "history") . ")\n"; } } } @@ -595,6 +602,35 @@ if ($action eq "blob") { print "<br/></pre>\n"; print "</div>"; git_footer_html(); +} elsif ($action eq "filerevision") { + open my $fd, "-|", "$gitbin/rev-list $hash"; + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + + git_header_html(); + print "<div class=\"page_body\">\n" . + "<pre>\n"; + foreach my $rev (@revlist) { + my %co = git_commit($rev); + my $parents = $co{'parents'}; + foreach my $parent (@$parents) { + open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd; + + foreach my $line (@difftree) { + $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; + my $file = $5; + if ($file eq $file_name) { + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, $rev) . " (" . $co{'title'} .")\n"; + last; + } + } + } + } + print "<br/></pre>\n"; + print "</div>"; + git_footer_html(); } else { die_error("", "unknown action"); } From 2ae100df543b8c287e72bcc470b3b3b1de70d3d7 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:17:00 +0200 Subject: [PATCH 033/148] v062 --- gitweb.cgi | 99 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 35 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 89c3df736f9..045384d53b4 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "057"; +my $version = "062"; my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/home/kay/bin/git"; @@ -79,6 +79,10 @@ sub git_header_html { } div.page_footer_text { float:left; color:#888888; font-size:10px;} div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + div.title { + display:block; margin:0px 25px; padding:8px; clear:both; + font-weight:bold; background-color: #d9d8d1; color:#000000; + } a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; @@ -188,6 +192,28 @@ sub git_commit { $co{'comment'} = \@comment; $co{'title'} = $comment[0]; close $fd; + + my $age = time - $co{'committer_epoch'}; + $co{'age'} = $age; + if ($age > 60*60*24*365*2) { + $co{'age_string'} = (int $age/60/60/24/365); + $co{'age_string'} .= " years ago"; + } elsif ($age > 60*60*24*365/12*2) { + $co{'age_string'} = int $age/60/60/24/365/12; + $co{'age_string'} .= " months ago"; + } elsif ($age > 60*60*24*7*2) { + $co{'age_string'} = int $age/60/60/24/7; + $co{'age_string'} .= " weeks ago"; + } elsif ($age > 60*60*24*2) { + $co{'age_string'} = int $age/60/60/24; + $co{'age_string'} .= " days ago"; + } elsif ($age > 60*60*2) { + $co{'age_string'} = int $age/60/60; + $co{'age_string'} .= " hours ago"; + } elsif ($age > 60*2) { + $co{'age_string'} = int $age/60; + $co{'age_string'} .= " minutes ago"; + } return %co; } @@ -351,6 +377,9 @@ if (!defined($time_back)) { if ($action eq "blob") { git_header_html(); + print "<div class=\"page_nav\">\n"; + print "<br/><br/></div>\n"; + print "<div class=\"title\">$hash</div>\n"; print "<div class=\"page_body\"><pre><br/><br/>\n"; open(my $fd, "-|", "$gitbin/cat-file blob $hash"); my $nr; @@ -370,6 +399,9 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); + print "<div class=\"page_nav\">\n"; + print "<br/><br/></div>\n"; + print "<div class=\"title\">$hash</div>\n"; print "<div class=\"page_body\">\n"; print "<br/><pre>\n"; foreach my $line (@entries) { @@ -380,9 +412,9 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, "view") . ")\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, "view") . ")\n"; } } print "</pre>\n"; @@ -419,36 +451,15 @@ if ($action eq "blob") { my $commit = $revlist[$i]; my %co = git_commit($commit); my %ad = date_str($co{'author_epoch'}); - my $age = time - $co{'committer_epoch'}; - my $age_string; - if ($age > 60*60*24*365*2) { - $age_string = int $age/60/60/24/365; - $age_string .= " years ago"; - } elsif ($age > 60*60*24*365/12*2) { - $age_string = int $age/60/60/24/365/12; - $age_string .= " months ago"; - } elsif ($age > 60*60*24*7*2) { - $age_string = int $age/60/60/24/7; - $age_string .= " weeks ago"; - } elsif ($age > 60*60*24*2) { - $age_string = int $age/60/60/24; - $age_string .= " days ago"; - } elsif ($age > 60*60*2) { - $age_string = int $age/60/60; - $age_string .= " hours ago"; - } elsif ($age > 60*2) { - $age_string = int $age/60; - $age_string .= " minutes ago"; - } if ($action eq "log") { - if ($time_back > 0 && $age > $time_back*60*60*24) { + if ($time_back > 0 && $co{'age'} > $time_back*60*60*24) { if ($i == 0) { - print "<div class=\"page_body\"> Last change $age_string.<br/><br/></div>\n"; + print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n"; } last; } print "<div><a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">\n" . - "<span class=\"log_age\">" . $age_string . "</span>\n" . escapeHTML($co{'title'}) . "</a>\n" . + "<span class=\"log_age\">" . $co{'age_string'} . "</span>\n" . escapeHTML($co{'title'}) . "</a>\n" . "</div>\n"; print "<div class=\"log_head\">\n" . "<div class=\"log_functions\">\n" . @@ -498,7 +509,7 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "<br/><br/></div>\n"; print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n"; print "<div class=\"log_head\">\n"; @@ -543,15 +554,19 @@ if ($action eq "blob") { my $modestr = mode_str($1); if ($type eq "blob") { if ($op eq "+") { - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n"; + print "$modestr $file" . "[new] " . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; } elsif ($op eq "-") { - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n"; + print "$modestr $file" . "[removed] " . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $from = $1; my $to = $2; - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . " (" . - $cgi->a({-href => "$my_uri?p=$project;a=filerevision;h=$hash;f=$file"}, "history") . ")\n"; + print "$modestr $file " . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, "view") . ")" . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, "diff") . ")" . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . ")\n"; } } } @@ -560,6 +575,9 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); + print "<div class=\"page_nav\">\n"; + print "<br/><br/></div>\n"; + print "<div class=\"title\">$hash vs $hash_parent</div>\n"; print "<div class=\"page_body\"><br/><br/>\n" . "<pre>\n"; git_diff_html($hash_parent, $hash, $hash_parent, $hash); @@ -575,7 +593,7 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "<br/><br/></div>\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; print "<div class=\"page_body\">\n" . @@ -602,17 +620,24 @@ if ($action eq "blob") { print "<br/></pre>\n"; print "</div>"; git_footer_html(); -} elsif ($action eq "filerevision") { +} elsif ($action eq "history") { + if (!(defined($hash))) { + $hash = git_head($project); + } open my $fd, "-|", "$gitbin/rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); + print "<div class=\"page_nav\">\n"; + print "<br/><br/></div>\n"; + print "<div class=\"title\">$file_name</div>\n"; print "<div class=\"page_body\">\n" . "<pre>\n"; foreach my $rev (@revlist) { my %co = git_commit($rev); my $parents = $co{'parents'}; + my $found = 0; foreach my $parent (@$parents) { open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; my (@difftree) = map { chomp; $_ } <$fd>; @@ -622,11 +647,15 @@ if ($action eq "blob") { $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $file = $5; if ($file eq $file_name) { - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, $rev) . " (" . $co{'title'} .")\n"; + $found = 1; last; } } } + if ($found) { + print $co{'age_string'} . "\t " . $co{'author_name'} . " - " . $co{'title'} . + " (" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "view") .")\n"; + } } print "<br/></pre>\n"; print "</div>"; From b51103f3cd4f1a08f5c26f5f6cd835dd2e6ead13 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:17:09 +0200 Subject: [PATCH 034/148] v063 --- gitweb.cgi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 045384d53b4..4b891fd8278 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,14 +14,16 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "062"; -my $projectroot = "/home/kay/public_html/pub/scm"; +my $version = "063"; +my $projectroot = "/pub/scm"; my $defaultprojects = "linux/kernel/git"; -my $gitbin = "/home/kay/bin/git"; -my $gittmp = "/tmp"; +my $gitbin = "/usr/bin"; +my $gittmp = "/tmp/gitweb"; +my $giturl = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +mkdir($gittmp, 0700); my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); @@ -113,7 +115,7 @@ sub git_header_html { <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"http://kernel.org/pub/software/scm/git/\">" . + "<a href=\"$giturl\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; From 664f4cc5eba8c6fab56e6ab112f295d5ef26316e Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:17:19 +0200 Subject: [PATCH 035/148] v064 --- gitweb.cgi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 4b891fd8278..61fc23f0605 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "063"; +my $version = "064"; my $projectroot = "/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/usr/bin"; @@ -142,6 +142,9 @@ sub git_footer_html { sub die_error { my $status = shift || "403 Forbidden"; my $error = shift || "Malformed query, file missing or permission denied"; + + $project = ""; + $action = ""; git_header_html($status); print "<div class=\"page_body\">\n" . "<br/><br/>\n"; @@ -522,7 +525,7 @@ if ($action eq "blob") { if ($ad{'hour_local'} < 6 ) { print "</span>"; } print "<br/>\n"; print "committer " . escapeHTML($co{'committer'}) . "<br/>\n"; - print "commit-time " . $ad{'rfc2822'}; + print "commit-time " . $cd{'rfc2822'}; printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); print "<br/>\n"; print "commit   $hash<br/>\n"; From 9cd3d988730949f7d1cc6f6c96417bf5aa845110 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:17:42 +0200 Subject: [PATCH 036/148] v070 --- gitweb.cgi | 211 +++++++++++++++++++++++++++++------------------------ 1 file changed, 115 insertions(+), 96 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 61fc23f0605..80a883d80f8 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,15 +14,21 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "064"; +my $version = "070"; my $projectroot = "/pub/scm"; -my $defaultprojects = "linux/kernel/git"; +my $home_link = "/git"; my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; -my $giturl = "/pub/software/scm/cogito"; +my $logo_link = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +# remove # +my $projectroot = "/home/kay/public_html/pub/scm"; +my $home_link = "/~kay/git"; +my $logo_link = "/~kay/pub/software/scm/cogito"; +# remove # + mkdir($gittmp, 0700); my $project = $cgi->param('p'); my $action = $cgi->param('a'); @@ -33,8 +39,13 @@ my $time_back = $cgi->param('t'); $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; # validate input -if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - die_error("", "Invalid project parameter."); +if (defined($project)) { + if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) { + die_error("", "Invalid project parameter."); + } + if (!(-d "$projectroot/$project")) { + die_error("", "No such project."); + } } if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { die_error("", "Invalid file parameter."); @@ -80,26 +91,18 @@ sub git_header_html { clear:both; background-color: #d9d8d1; } div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + div.page_body { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } div.title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; color:#000000; } a.log_title { - display:block; margin:0px 25px; padding:8px; clear:both; + display:block; margin:0px 25px; padding:6px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; } a.log_title:hover { background-color: #c9c8c1; } - a.xml_logo { float:right; border:1px solid; - line-height:15px; - border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; - color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; text-align:center; - font-size:11px; display:block; text-decoration:none; - } - a.xml_logo:hover { background-color:#ee5500; } div.log_head { - margin:0px 25px; min-height: 30px; padding:8px; clear:both; + margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6; } @@ -108,18 +111,28 @@ sub git_header_html { border:solid #d9d8d1; border-width:0px 1px; } span.log_age { position:relative; float:left; width:142px; } - div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.signed_off { color: #a9a8a1; } + div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } + div.list { + display:block; margin:0px 25px; padding:2px 8px; border:solid #d9d8d1; border-width:0px 1px; + font-family:monospace; background-color: #edece6; + } + div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + a.xml_logo { float:right; border:1px solid; + line-height:15px; + border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; + color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; text-align:center; + font-size:11px; display:block; text-decoration:none; + } + a.xml_logo:hover { background-color:#ee5500; } </style> </head> <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"$giturl\">" . + "<a href=\"$logo_link\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; - if ($defaultprojects ne "") { - print $cgi->a({-href => "$my_uri"}, "projects") . " / "; - } + print $cgi->a({-href => "$my_uri"}, "projects") . " / "; if ($project ne "") { print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); } @@ -135,8 +148,9 @@ sub git_footer_html { if ($project ne '') { print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; } - print "</div>"; - print "</body>\n</html>"; + print "</div>" . + "</body>" . + "</html>"; } sub die_error { @@ -168,7 +182,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/cat-file commit $commit"; + open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -238,7 +252,7 @@ sub git_diff_html { if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open(my $fd2, "> $from_tmp"); - open my $fd, "-|", "$gitbin/cat-file blob $from"; + open my $fd, "-|", "$gitbin/git-cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -250,7 +264,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file blob $to"; + open my $fd, "-|", "$gitbin/git-cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -294,13 +308,13 @@ sub mode_str { my $perms = oct shift; my $modestr; if ($perms & 040000) { - $modestr .= 'drwxrwxr-x'; + $modestr .= 'drwxr-xr-x'; } else { # git cares only about the executable bit if ($perms & 0100) { - $modestr .= '-rwxrwxr-x'; + $modestr .= '-rwxr-xr-x'; } else { - $modestr .= '-rw-rw-r--'; + $modestr .= '-rw-r--r--'; }; } return $modestr; @@ -349,26 +363,8 @@ if ($action eq "git-logo.png") { exit; } -# show list of default projects -if ($project eq "") { - opendir(my $fd, "$projectroot/$defaultprojects") || die_error("", "No projects found."); - my (@users) = sort grep(!/^\./, readdir($fd)); - closedir($fd); - git_header_html(); - print "<div class=\"page_body\">\n"; - print "<br/><br/>\n"; - foreach my $user (@users) { - opendir($fd, "$projectroot/$defaultprojects/$user"); - my (@repos) = sort grep(/\.git$/, readdir($fd)); - closedir($fd); - foreach my $repo (@repos) { - if (-e "$projectroot/$defaultprojects/$user/$repo/HEAD") { - print $cgi->a({-href => "$my_uri?p=$defaultprojects/$user/$repo;a=log"}, "$defaultprojects/$user/$repo") . "<br/>\n"; - } - } - } - print "<br/></div>"; - git_footer_html(); +if (!defined($project)) { + print $cgi->redirect($home_link); exit; } @@ -385,22 +381,22 @@ if ($action eq "blob") { print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; print "<div class=\"title\">$hash</div>\n"; - print "<div class=\"page_body\"><pre><br/><br/>\n"; - open(my $fd, "-|", "$gitbin/cat-file blob $hash"); + print "<div class=\"page_body\"><pre>\n"; + open(my $fd, "-|", "$gitbin/git-cat-file blob $hash"); my $nr; while (my $line = <$fd>) { $nr++; printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);; } close $fd; - print "<br/><br/></pre>\n"; + print "<br/></pre>\n"; print "</div>"; git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/ls-tree $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); @@ -417,16 +413,16 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, "view") . ")\n"; + print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash", -class => "link"}, "view") . "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, "view") . ")\n"; + print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash", -class => "link"}, "view") . "\n"; } } print "</pre>\n"; print "<br/></div>"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list " . git_head($project); + open my $fd, "-|", "$gitbin/git-rev-list " . git_head($project); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -463,26 +459,24 @@ if ($action eq "blob") { } last; } - print "<div><a href=\"$my_uri?p=$project;a=commit;h=$commit\" class=\"log_title\">\n" . - "<span class=\"log_age\">" . $co{'age_string'} . "</span>\n" . escapeHTML($co{'title'}) . "</a>\n" . + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "log_title"}, + "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"log_head\">\n" . - "<div class=\"log_functions\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "<br/>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "<br/>\n" . + "<div class=\"log_link\">\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" . "</div>\n" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n" . "</div>\n" . "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { - if ($line =~ m/^(signed-off|acked)-by:/i) { - print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; - } else { - print escapeHTML($line) . "<br/>\n"; - } + last if ($line =~ m/^(signed-off|acked)-by:/i); + print escapeHTML($line) . "<br/>\n"; } - print "<br/><br/>\n" . + print "<br/>\n" . "</div>\n"; } elsif ($action eq "rss") { last if ($i >= 20); @@ -507,7 +501,7 @@ if ($action eq "blob") { my %co = git_commit($hash); my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -516,7 +510,9 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "<br/><br/></div>\n"; - print "<a class=\"log_title\" href=\"$my_uri?p=$project;a=commitdiff;h=$hash\">$co{'title'}</a>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; print "<div class=\"log_head\">\n"; print "author " . escapeHTML($co{'author'}) . "<br/>\n"; print "author-time " . $ad{'rfc2822'}; @@ -539,51 +535,70 @@ if ($action eq "blob") { my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/(signed-off|acked)-by:/i) { - print '<div class="signed_off">' . escapeHTML($line) . "<br/></div>\n"; + print "<span style=\"color: #a9a8a1\">" . escapeHTML($line) . "</span><br/>\n"; } else { print escapeHTML($line) . "<br/>\n"; } } - print "<br/><br/>\n"; - print "<pre>\n"; + print "<br/><br/>\n" . + "</div>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' + # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c' + # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; my $type = $3; my $id = $4; my $file = $5; - $mode =~ m/^([0-7]{6})/; - my $modestr = mode_str($1); + my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { - print "$modestr $file" . "[new] " . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; + print "<div class=\"list\">\n" . + "$file <span style=\"color: #55cc55;\">[new]</span>\n" . + "</div>"; + print "<div class=\"link\">\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . + "</div>\n"; } elsif ($op eq "-") { - print "$modestr $file" . "[removed] " . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; + print "<div class=\"list\">\n" . + "$file <span style=\"color: #cc5555;\">[removed]</span>\n" . + "</div>"; + print "<div class=\"link\">\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . + "</div>\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - my $from = $1; - my $to = $2; - print "$modestr $file " . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, "view") . ")" . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, "diff") . ")" . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . ")\n"; + my $from_id = $1; + my $to_id = $2; + $mode =~ m/^([0-7]{6})->([0-7]{6})$/; + my $from_mode = $1; + my $to_mode = $2; + print "<div class=\"list\">\n"; + print $file; + if ($from_mode != $to_mode) { + print "<span style=\"color: #555555;\"> [chmod $mode]</span>"; + } + print "\n</div>\n"; + print "<div class=\"link\">\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | "; + if ($to_id ne $from_id) { + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; + } + print $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" . + "</div>\n"; } } } - print "</pre>\n" . - "<br/></div>\n"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; print "<div class=\"title\">$hash vs $hash_parent</div>\n"; - print "<div class=\"page_body\"><br/><br/>\n" . + print "<div class=\"page_body\">\n" . "<pre>\n"; git_diff_html($hash_parent, $hash, $hash_parent, $hash); print "</pre>\n" . @@ -591,7 +606,7 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -600,7 +615,9 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "<br/><br/></div>\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; print "<div class=\"page_body\">\n" . "<pre>\n"; foreach my $line (@difftree) { @@ -618,7 +635,9 @@ if ($action eq "blob") { git_diff_html($file, "", $id, ""); } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - git_diff_html($file, $file, $1, $2); + if ($1 ne $2) { + git_diff_html($file, $file, $1, $2); + } } } } @@ -629,14 +648,14 @@ if ($action eq "blob") { if (!(defined($hash))) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/rev-list $hash"; + open my $fd, "-|", "$gitbin/git-rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; - print "<div class=\"title\">$file_name</div>\n"; + print "<div class=\"title\">". escapeHTML($file_name) . "</div>\n"; print "<div class=\"page_body\">\n" . "<pre>\n"; foreach my $rev (@revlist) { @@ -644,7 +663,7 @@ if ($action eq "blob") { my $parents = $co{'parents'}; my $found = 0; foreach my $parent (@$parents) { - open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; + open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -658,8 +677,8 @@ if ($action eq "blob") { } } if ($found) { - print $co{'age_string'} . "\t " . $co{'author_name'} . " - " . $co{'title'} . - " (" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "view") .")\n"; + print $co{'age_string'} . "\t " . $co{'author_name'} . " - " . $co{'title'} . " " . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "link"}, "view") ."\n"; } } print "<br/></pre>\n"; From 820e4f6b6b4141b779c140d08e46fde0aa30117c Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:17:50 +0200 Subject: [PATCH 037/148] v071 --- gitweb.cgi | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 80a883d80f8..4363621f913 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "070"; +my $version = "071"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -657,7 +657,8 @@ if ($action eq "blob") { print "<br/><br/></div>\n"; print "<div class=\"title\">". escapeHTML($file_name) . "</div>\n"; print "<div class=\"page_body\">\n" . - "<pre>\n"; + "<br/>\n" . + "</div>\n"; foreach my $rev (@revlist) { my %co = git_commit($rev); my $parents = $co{'parents'}; @@ -677,12 +678,16 @@ if ($action eq "blob") { } } if ($found) { - print $co{'age_string'} . "\t " . $co{'author_name'} . " - " . $co{'title'} . " " . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "link"}, "view") ."\n"; + print "<div class=\"list\">\n" . + $co{'age_string'} . "" . $co{'title'} . "\n" . + "</div>"; + print "<div class=\"link\">\n" . + "view " . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" . + "</div>\n"; } } - print "<br/></pre>\n"; - print "</div>"; git_footer_html(); } else { die_error("", "unknown action"); From 1207151d40bec83569fb5bb67c0aee6a1a36c353 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:18:01 +0200 Subject: [PATCH 038/148] v073 --- gitweb.cgi | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 4363621f913..fbe3a48b49f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "071"; +my $version = "073"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -112,17 +112,18 @@ sub git_header_html { } span.log_age { position:relative; float:left; width:142px; } div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.list { - display:block; margin:0px 25px; padding:2px 8px; border:solid #d9d8d1; border-width:0px 1px; - font-family:monospace; background-color: #edece6; + a.list { + display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; + font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; } + a.list:hover { background-color: #d9d8d1; } div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; font-weight:bold; font-family:sans-serif; text-align:center; - font-size:11px; display:block; text-decoration:none; + font-size:10px; display:block; text-decoration:none; } a.xml_logo:hover { background-color:#ee5500; } </style> @@ -413,9 +414,9 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash", -class => "link"}, "view") . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash", -class => "link"}, "view") . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; } } print "</pre>\n"; @@ -508,7 +509,8 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . @@ -557,17 +559,20 @@ if ($action eq "blob") { if ($type eq "blob") { if ($op eq "+") { print "<div class=\"list\">\n" . - "$file <span style=\"color: #55cc55;\">[new]</span>\n" . + "$file <span style=\"color: #33cc33;\">[new]</span>\n" . "</div>"; print "<div class=\"link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . + "view " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . "</div>\n"; } elsif ($op eq "-") { print "<div class=\"list\">\n" . "$file <span style=\"color: #cc5555;\">[removed]</span>\n" . "</div>"; print "<div class=\"link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . + "view " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" . "</div>\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; @@ -576,18 +581,19 @@ if ($action eq "blob") { $mode =~ m/^([0-7]{6})->([0-7]{6})$/; my $from_mode = $1; my $to_mode = $2; - print "<div class=\"list\">\n"; - print $file; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, $file) . "\n"; if ($from_mode != $to_mode) { print "<span style=\"color: #555555;\"> [chmod $mode]</span>"; } print "\n</div>\n"; print "<div class=\"link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | "; + "view "; if ($to_id ne $from_id) { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" . + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" . "</div>\n"; } } @@ -613,7 +619,8 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . @@ -678,9 +685,10 @@ if ($action eq "blob") { } } if ($found) { - print "<div class=\"list\">\n" . - $co{'age_string'} . "" . $co{'title'} . "\n" . - "</div>"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, + "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . + "</div>\n"; print "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . From d63577da05b8994f97bba210aa5816848c1c03a5 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:18:13 +0200 Subject: [PATCH 039/148] v077 --- gitweb.cgi | 101 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fbe3a48b49f..f96013fd802 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "073"; +my $version = "078"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -81,43 +81,45 @@ sub git_header_html { a:active { color:#880000; } div.page_header { margin:15px 25px 0px; height:25px; padding:8px; - font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1; + font-size:18px; font-weight:bold; background-color:#d9d8d1; } div.page_header a:visited { color:#0000cc; } - div.page_nav { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } + div.page_header a:hover { color:#880000; } + div.page_nav { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.page_nav a:visited { color:#0000cc; } div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; - clear:both; background-color: #d9d8d1; + background-color: #d9d8d1; } div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } + div.page_body { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.title { - display:block; margin:0px 25px; padding:8px; clear:both; - font-weight:bold; background-color: #d9d8d1; color:#000000; + display:block; margin:0px 25px; padding:8px; + font-weight:bold; background-color:#d9d8d1; color:#000000; } a.log_title { - display:block; margin:0px 25px; padding:6px; clear:both; - font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; + display:block; margin:0px 25px; padding:6px; + font-weight:bold; background-color:#d9d8d1; text-decoration:none; color:#000000; } a.log_title:hover { background-color: #c9c8c1; } div.log_head { - margin:0px 25px; padding:8px; clear:both; + margin:0px 25px; padding:8px; border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6; } div.log_body { - margin:0px 25px; padding:8px; padding-left:150px; clear:both; + margin:0px 25px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } span.log_age { position:relative; float:left; width:142px; } div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - a.list { - display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; - font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; + div.list { + display:block; margin:0px 25px; padding:2px 8px 0px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; + font-weight:bold; text-decoration:none; color:#000000; } - a.list:hover { background-color: #d9d8d1; } - div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + div.list a { color:#000000; text-decoration:none; } + div.link { font-weight:normal; font-family:sans-serif; font-size:10px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; } + a.view { display:inline; font-size:24px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; @@ -135,7 +137,7 @@ EOF "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => "$my_uri"}, "projects") . " / "; if ($project ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, escapeHTML($project)); } if ($action ne "") { print " / $action"; @@ -205,7 +207,9 @@ sub git_commit { $co{'committer_name'} =~ s/ <.*//; } } - if (!defined($co{'tree'})) { die_error("", "Invalid commit object."); } + if (!defined($co{'tree'})) { + return; + } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; @@ -400,10 +404,23 @@ if ($action eq "blob") { open my $fd, "-|", "$gitbin/git-ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; + git_header_html(); - print "<div class=\"page_nav\">\n"; - print "<br/><br/></div>\n"; - print "<div class=\"title\">$hash</div>\n"; + my %co = git_commit($hash); + if (defined(%co)) { + print "<div class=\"page_nav\"> view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . + "<br/><br/></div>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + } else { + print "<div class=\"page_nav\">\n"; + print "<br/><br/></div>\n"; + print "<div class=\"title\">$hash</div>\n"; + } print "<div class=\"page_body\">\n"; print "<br/><pre>\n"; foreach my $line (@entries) { @@ -500,6 +517,9 @@ if ($action eq "blob") { } } elsif ($action eq "commit") { my %co = git_commit($hash); + if (!defined(%co)) { + die_error("", "Unknown commit object."); + } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; @@ -527,7 +547,7 @@ if ($action eq "blob") { printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); print "<br/>\n"; print "commit   $hash<br/>\n"; - print "tree  " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "<br/>\n"; + print "tree  " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "<br/>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n"; @@ -558,16 +578,18 @@ if ($action eq "blob") { my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { - print "<div class=\"list\">\n" . - "$file <span style=\"color: #33cc33;\">[new]</span>\n" . + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, + escapeHTML($file) . " <span style=\"color: #008000;\">[new]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . "</div>\n"; } elsif ($op eq "-") { - print "<div class=\"list\">\n" . - "$file <span style=\"color: #cc5555;\">[removed]</span>\n" . + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, + escapeHTML($file) . " <span style=\"color: #c00000;\">[removed]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -581,12 +603,14 @@ if ($action eq "blob") { $mode =~ m/^([0-7]{6})->([0-7]{6})$/; my $from_mode = $1; my $to_mode = $2; - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, $file) . "\n"; + my $mode_chnge = ""; if ($from_mode != $to_mode) { - print "<span style=\"color: #555555;\"> [chmod $mode]</span>"; + $mode_chnge = " <span style=\"color: #555555;\"> [chmod $mode]</span>\n"; } - print "\n</div>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, + escapeHTML($file) . $mode_chnge) . "\n" . + "</div>\n"; print "<div class=\"link\">\n" . "view "; if ($to_id ne $from_id) { @@ -612,6 +636,9 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); + if (!defined(%co)) { + die_error("", "Unknown commit object."); + } open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -662,7 +689,9 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; - print "<div class=\"title\">". escapeHTML($file_name) . "</div>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($file_name)) . "\n" . + "</div>\n"; print "<div class=\"page_body\">\n" . "<br/>\n" . "</div>\n"; @@ -685,14 +714,14 @@ if ($action eq "blob") { } } if ($found) { - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . - "</div>\n"; - print "<div class=\"link\">\n" . + "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" . + "</div>\n" . "</div>\n"; } } From 334538f11d30024de28b4490ed6b006d82fadb80 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:18:30 +0200 Subject: [PATCH 040/148] v078 --- gitweb.cgi | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index f96013fd802..fdc018533a2 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -113,13 +113,12 @@ sub git_header_html { } span.log_age { position:relative; float:left; width:142px; } div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.list { - display:block; margin:0px 25px; padding:2px 8px 0px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; - font-weight:bold; text-decoration:none; color:#000000; + a.list { + display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; + font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; } - div.list a { color:#000000; text-decoration:none; } - div.link { font-weight:normal; font-family:sans-serif; font-size:10px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; } - a.view { display:inline; font-size:24px; } + a.list:hover { background-color: #d9d8d1; } + div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; @@ -580,7 +579,7 @@ if ($action eq "blob") { if ($op eq "+") { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " <span style=\"color: #008000;\">[new]</span>") . "\n" . + escapeHTML($file) . " <span style=\"color: #33cc33;\">[new]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -589,7 +588,7 @@ if ($action eq "blob") { } elsif ($op eq "-") { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " <span style=\"color: #c00000;\">[removed]</span>") . "\n" . + escapeHTML($file) . " <span style=\"color: #cc5555;\">[removed]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -714,14 +713,14 @@ if ($action eq "blob") { } } if ($found) { - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . - "<div class=\"link\">\n" . + "</div>\n"; + print "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" . - "</div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" . "</div>\n"; } } From 927dcec4805b32b1f7252e0c4dea341df166deb0 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:18:44 +0200 Subject: [PATCH 041/148] v080 --- gitweb.cgi | 110 +++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fdc018533a2..fa2ba70aadc 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "078"; +my $version = "080"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -97,28 +97,29 @@ sub git_header_html { display:block; margin:0px 25px; padding:8px; font-weight:bold; background-color:#d9d8d1; color:#000000; } - a.log_title { - display:block; margin:0px 25px; padding:6px; - font-weight:bold; background-color:#d9d8d1; text-decoration:none; color:#000000; + a.title { + display:block; margin:0px 25px; padding:6px 8px; + font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; } - a.log_title:hover { background-color: #c9c8c1; } - div.log_head { - margin:0px 25px; padding:8px; - border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; - background-color: #edece6; + a.title:hover { background-color: #d9d8d1; } + div.title2 { + margin:0px 25px; padding:6px 8px; + border: solid #d9d8d1; border-width:0px 1px 1px; } div.log_body { margin:0px 25px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } - span.log_age { position:relative; float:left; width:142px; } - div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - a.list { - display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; - font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; + span.log_age { position:relative; float:left; width:142px; font-style:italic; } + div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } + div.list { + display:block; margin:0px 25px; padding:4px 6px 0px; border:solid #d9d8d1; border-width:1px 1px 0px; + font-weight:bold; } - a.list:hover { background-color: #d9d8d1; } - div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + div.list a { text-decoration:none; color:#000000; } + div.list a:hover { color:#880000; } + div.link { margin:0px 25px; padding:0px 6px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + td.key { padding-right:10px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; @@ -413,7 +414,7 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n"; @@ -477,15 +478,15 @@ if ($action eq "blob") { last; } print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "log_title"}, + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"log_head\">\n" . + print "<div class=\"title2\">\n" . "<div class=\"log_link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" . "</div>\n" . - escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]<br/>\n" . + "<i>" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]</i><br/>\n" . "</div>\n" . "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; @@ -532,37 +533,41 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"log_head\">\n"; - print "author " . escapeHTML($co{'author'}) . "<br/>\n"; - print "author-time " . $ad{'rfc2822'}; - if ($ad{'hour_local'} < 6) { print "<span style=\"color: #cc0000;\">"; } + print "<div class=\"title2\">\n" . + "<table cellspacing=\"0\">"; + print "<tr><td class=\"key\">author</td><td>" . escapeHTML($co{'author'}) . "</td><tr><td></td><td>" . + " " . $ad{'rfc2822'}; + if ($ad{'hour_local'} < 6) { + print "<span style=\"color: #cc0000;\">"; + } printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); - if ($ad{'hour_local'} < 6 ) { print "</span>"; } - print "<br/>\n"; - print "committer " . escapeHTML($co{'committer'}) . "<br/>\n"; - print "commit-time " . $cd{'rfc2822'}; - printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); - print "<br/>\n"; - print "commit   $hash<br/>\n"; - print "tree  " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "<br/>\n"; + if ($ad{'hour_local'} < 6 ) { + print "</span>"; + } + print "</i>\n" . + "</td></tr>\n"; + print "<tr><td class=\"key\">committer</td><td>" . escapeHTML($co{'committer'}) . "</td><tr><td></td><td>" . + " " . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</i>\n" . + "</td></tr>\n"; + print "<tr><td class=\"key\">commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; + print "<tr><td class=\"key\">tree</td><td style=\"font-family: monospace;\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "</td></tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "<br/>\n"; + print "<tr><td class=\"key\">parent</td><td style=\"font-family: monospace;\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n"; } - print "</div>\n"; + print "</table></div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/(signed-off|acked)-by:/i) { - print "<span style=\"color: #a9a8a1\">" . escapeHTML($line) . "</span><br/>\n"; + print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { print escapeHTML($line) . "<br/>\n"; } } - print "<br/><br/>\n" . - "</div>\n"; + print "</div>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -577,18 +582,18 @@ if ($action eq "blob") { my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " <span style=\"color: #33cc33;\">[new]</span>") . "\n" . + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + escapeHTML($file) . " <span style=\"color: #008000;\">[new]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . "</div>\n"; } elsif ($op eq "-") { - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " <span style=\"color: #cc5555;\">[removed]</span>") . "\n" . + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + escapeHTML($file) . " <span style=\"color: #c00000;\">[removed]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -604,10 +609,10 @@ if ($action eq "blob") { my $to_mode = $2; my $mode_chnge = ""; if ($from_mode != $to_mode) { - $mode_chnge = " <span style=\"color: #555555;\"> [chmod $mode]</span>\n"; + $mode_chnge = " <span style=\"color: #888888;\"> [chmod $mode]</span>\n"; } - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id"}, escapeHTML($file) . $mode_chnge) . "\n" . "</div>\n"; print "<div class=\"link\">\n" . @@ -649,7 +654,7 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_body\">\n" . "<pre>\n"; @@ -689,10 +694,7 @@ if ($action eq "blob") { print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($file_name)) . "\n" . - "</div>\n"; - print "<div class=\"page_body\">\n" . - "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($file_name)) . "\n" . "</div>\n"; foreach my $rev (@revlist) { my %co = git_commit($rev); @@ -713,8 +715,8 @@ if ($action eq "blob") { } } if ($found) { - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"link\">\n" . From 2bb7c6d4179ca7cd5cfd353400866ef0aed16777 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:19:45 +0200 Subject: [PATCH 042/148] v082 --- gitweb.cgi | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fa2ba70aadc..15bb123b21f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "080"; +my $version = "082"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -23,12 +23,6 @@ my $logo_link = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -# remove # -my $projectroot = "/home/kay/public_html/pub/scm"; -my $home_link = "/~kay/git"; -my $logo_link = "/~kay/pub/software/scm/cogito"; -# remove # - mkdir($gittmp, 0700); my $project = $cgi->param('p'); my $action = $cgi->param('a'); @@ -185,7 +179,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; + open my $fd, "-|", "$gitbin/cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -257,7 +251,7 @@ sub git_diff_html { if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open(my $fd2, "> $from_tmp"); - open my $fd, "-|", "$gitbin/git-cat-file blob $from"; + open my $fd, "-|", "$gitbin/cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -269,7 +263,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/git-cat-file blob $to"; + open my $fd, "-|", "$gitbin/cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -387,7 +381,7 @@ if ($action eq "blob") { print "<br/><br/></div>\n"; print "<div class=\"title\">$hash</div>\n"; print "<div class=\"page_body\"><pre>\n"; - open(my $fd, "-|", "$gitbin/git-cat-file blob $hash"); + open(my $fd, "-|", "$gitbin/cat-file blob $hash"); my $nr; while (my $line = <$fd>) { $nr++; @@ -401,7 +395,7 @@ if ($action eq "blob") { if ($hash eq "") { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/git-ls-tree $hash"; + open my $fd, "-|", "$gitbin/ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; @@ -440,7 +434,7 @@ if ($action eq "blob") { print "<br/></div>"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/git-rev-list " . git_head($project); + open my $fd, "-|", "$gitbin/rev-list " . git_head($project); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -522,7 +516,7 @@ if ($action eq "blob") { } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -611,10 +605,16 @@ if ($action eq "blob") { if ($from_mode != $to_mode) { $mode_chnge = " <span style=\"color: #888888;\"> [chmod $mode]</span>\n"; } - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id"}, - escapeHTML($file) . $mode_chnge) . "\n" . - "</div>\n"; + print "<div class=\"list\">\n"; + if ($to_id ne $from_id) { + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, + escapeHTML($file) . $mode_chnge) . "\n" . + "</div>\n"; + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, + escapeHTML($file) . $mode_chnge) . "\n" . + "</div>\n"; + } print "<div class=\"link\">\n" . "view "; if ($to_id ne $from_id) { @@ -643,7 +643,7 @@ if ($action eq "blob") { if (!defined(%co)) { die_error("", "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -686,7 +686,7 @@ if ($action eq "blob") { if (!(defined($hash))) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/git-rev-list $hash"; + open my $fd, "-|", "$gitbin/rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -701,7 +701,7 @@ if ($action eq "blob") { my $parents = $co{'parents'}; my $found = 0; foreach my $parent (@$parents) { - open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name"; + open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -728,5 +728,5 @@ if ($action eq "blob") { } git_footer_html(); } else { - die_error("", "unknown action"); + die_error("", "Unknown action."); } From 6191f8e1ddbc03dd2b5db2f6d433f7a1da93c4af Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:19:56 +0200 Subject: [PATCH 043/148] v085 --- gitweb.cgi | 213 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 119 insertions(+), 94 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 15bb123b21f..4ad3ce4dcb3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "082"; +my $version = "085"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -22,107 +22,116 @@ my $gittmp = "/tmp/gitweb"; my $logo_link = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +my $rss_link = ""; -mkdir($gittmp, 0700); my $project = $cgi->param('p'); -my $action = $cgi->param('a'); -my $hash = $cgi->param('h'); -my $hash_parent = $cgi->param('hp'); -my $file_name = $cgi->param('f'); -my $time_back = $cgi->param('t'); -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; - -# validate input if (defined($project)) { if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) { + $project = ""; die_error("", "Invalid project parameter."); } if (!(-d "$projectroot/$project")) { + $project = ""; die_error("", "No such project."); } + $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; } + +my $file_name = $cgi->param('f'); if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { + $file_name = ""; die_error("", "Invalid file parameter."); } -if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { + +my $action = $cgi->param('a'); +if (defined($action) && $action =~ m/[^0-9a-zA-Z\.\-]+$/) { + $action = ""; die_error("", "Invalid action parameter."); } + +my $hash = $cgi->param('h'); if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { + $hash = ""; die_error("", "Invalid hash parameter."); } + +my $hash_parent = $cgi->param('hp'); if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { + $hash_parent = ""; die_error("", "Invalid parent hash parameter."); } + +my $time_back = $cgi->param('t'); if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { + $time_back = ""; die_error("", "Invalid time parameter."); } +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; +mkdir($gittmp, 0700); + sub git_header_html { my $status = shift || "200 OK"; print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); print <<EOF; +<?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"> +<!-- git web interface v$version, (C) 2005, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke <ch\@gierke.de> --> <html> <head> - <title>git - $project $action</title> - <link rel="alternate" title="$project log" href="$my_uri?p=$project;a=rss" type="application/rss+xml"/> - <style type="text/css"> - body { font-family: sans-serif; font-size: 12px; margin:0px; } - a { color:#0000cc; } - a:hover { color:#880000; } - a:visited { color:#880000; } - a:active { color:#880000; } - div.page_header { - margin:15px 25px 0px; height:25px; padding:8px; - font-size:18px; font-weight:bold; background-color:#d9d8d1; - } - div.page_header a:visited { color:#0000cc; } - div.page_header a:hover { color:#880000; } - div.page_nav { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } - div.page_nav a:visited { color:#0000cc; } - div.page_footer { - margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; - background-color: #d9d8d1; - } - div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } - div.title { - display:block; margin:0px 25px; padding:8px; - font-weight:bold; background-color:#d9d8d1; color:#000000; - } - a.title { - display:block; margin:0px 25px; padding:6px 8px; - font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; - } - a.title:hover { background-color: #d9d8d1; } - div.title2 { - margin:0px 25px; padding:6px 8px; - border: solid #d9d8d1; border-width:0px 1px 1px; - } - div.log_body { - margin:0px 25px; padding:8px; padding-left:150px; - border:solid #d9d8d1; border-width:0px 1px; - } - span.log_age { position:relative; float:left; width:142px; font-style:italic; } - div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } - div.list { - display:block; margin:0px 25px; padding:4px 6px 0px; border:solid #d9d8d1; border-width:1px 1px 0px; - font-weight:bold; - } - div.list a { text-decoration:none; color:#000000; } - div.list a:hover { color:#880000; } - div.link { margin:0px 25px; padding:0px 6px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } - td.key { padding-right:10px; } - a.xml_logo { float:right; border:1px solid; - line-height:15px; - border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; - color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; text-align:center; - font-size:10px; display:block; text-decoration:none; - } - a.xml_logo:hover { background-color:#ee5500; } - </style> +<title>git - $project</title> +$rss_link +<style type="text/css"> +body { font-family: sans-serif; font-size: 12px; margin:0px; } +a { color:#0000cc; } +a:hover { color:#880000; } +a:visited { color:#880000; } +a:active { color:#880000; } +div.page_header { + margin:15px 25px 0px; height:25px; padding:8px; + font-size:18px; font-weight:bold; background-color:#d9d8d1; +} +div.page_header a:visited { color:#0000cc; } +div.page_header a:hover { color:#880000; } +div.page_nav { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } +div.page_nav a:visited { color:#0000cc; } +div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; background-color: #d9d8d1; } +div.page_footer_text { float:left; color:#555555; font-style:italic; } +div.page_body { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } +div.title, a.title { + display:block; margin:0px 25px; padding:6px 8px; + font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; +} +a.title:hover { background-color: #d9d8d1; } +div.title_text { margin:0px 25px; padding:6px 8px; border: solid #d9d8d1; border-width:0px 1px 1px; } +div.log_body { margin:0px 25px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } +span.log_age { position:relative; float:left; width:142px; font-style:italic; } +div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } +div.list { + display:block; margin:0px 25px; padding:4px 6px 2px; border:solid #d9d8d1; border-width:1px 1px 0px; + font-weight:bold; +} +div.list_head { + display:block; margin:0px 25px; padding:4px 6px 4px; border:solid #d9d8d1; border-width:1px 1px 0px; + font-style:italic; +} +div.list a { text-decoration:none; color:#000000; } +div.list a:hover { color:#880000; } +div.link { + margin:0px 25px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px; + font-family:sans-serif; font-size:10px; +} +td.key { padding-right:10px; } +a.xml_logo { float:right; border:1px solid; + line-height:15px; + border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; + color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; text-align:center; + font-size:10px; display:block; text-decoration:none; +} +a.xml_logo:hover { background-color:#ee5500; } +</style> </head> <body> EOF @@ -140,13 +149,18 @@ EOF } sub git_footer_html { - print "<div class=\"page_footer\">"; - print "<div class=\"page_footer_text\">version $version</div>"; - if ($project ne '') { + print "<div class=\"page_footer\">\n"; + if ($project ne "") { + if (-e "$projectroot/$project/description") { + open(my $fd, "$projectroot/$project/description"); + my $descr = <$fd>; + print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; + close $fd; + } print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; } - print "</div>" . - "</body>" . + print "</div>\n" . + "</body>\n" . "</html>"; } @@ -154,12 +168,10 @@ sub die_error { my $status = shift || "403 Forbidden"; my $error = shift || "Malformed query, file missing or permission denied"; - $project = ""; - $action = ""; git_header_html($status); print "<div class=\"page_body\">\n" . "<br/><br/>\n"; - print "$error\n"; + print "$status - $error\n"; print "<br/></div>\n"; git_footer_html(); exit 0; @@ -167,7 +179,7 @@ sub die_error { sub git_head { my $path = shift; - open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory.");; + open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory."); my $head = <$fd>; close $fd; chomp $head; @@ -403,10 +415,11 @@ if ($action eq "blob") { my %co = git_commit($hash); if (defined(%co)) { print "<div class=\"page_nav\"> view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . - "<br/><br/></div>\n"; + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . + "<br/><br/>\n" . + "</div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; @@ -442,10 +455,10 @@ if ($action eq "blob") { git_header_html(); print "<div class=\"page_nav\">\n"; print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" . + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; print "<br/><br/>\n" . "</div>\n"; @@ -475,7 +488,7 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"title2\">\n" . + print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" . @@ -516,10 +529,18 @@ if ($action eq "blob") { } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; - my (@difftree) = map { chomp; $_ } <$fd>; - close $fd; + my @difftree; + if (defined($co{'parent'})) { + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + @difftree = map { chomp; $_ } <$fd>; + close $fd; + } else { + # fake git-diff-tree output for initial revision + open my $fd, "-|", "$gitbin/ls-tree -r $hash"; + @difftree = map { chomp; "+" . $_ } <$fd>; + close $fd; + } git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . @@ -529,7 +550,7 @@ if ($action eq "blob") { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"title2\">\n" . + print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">"; print "<tr><td class=\"key\">author</td><td>" . escapeHTML($co{'author'}) . "</td><tr><td></td><td>" . " " . $ad{'rfc2822'}; @@ -562,6 +583,9 @@ if ($action eq "blob") { } } print "</div>\n"; + if ($#difftree > 10) { + print "<div class=\"list_head\">" . ($#difftree + 1) . " files changed:<br/></div>\n"; + } foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -582,7 +606,7 @@ if ($action eq "blob") { "</div>"; print "<div class=\"link\">\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/>\n" . "</div>\n"; } elsif ($op eq "-") { print "<div class=\"list\">\n" . @@ -592,7 +616,7 @@ if ($action eq "blob") { print "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . "</div>\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; @@ -621,7 +645,7 @@ if ($action eq "blob") { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; } print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . "</div>\n"; } } @@ -728,5 +752,6 @@ if ($action eq "blob") { } git_footer_html(); } else { + $action = ""; die_error("", "Unknown action."); } From 034df39ef7c80bd7e41e244c39400019123273c1 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:20:07 +0200 Subject: [PATCH 044/148] v088 --- gitweb.cgi | 186 ++++++++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 87 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 4ad3ce4dcb3..1e8565a8a7d 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,12 +14,21 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "085"; +# !! This devel-version uses a modified git-rev-list binary !! +# The git changes are expected to show up upstream soon. + +# begin config my $projectroot = "/pub/scm"; +$projectroot = "/home/kay/public_html/pub/scm"; my $home_link = "/git"; +$home_link = "/~kay/git"; my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; my $logo_link = "/pub/software/scm/cogito"; +$logo_link = "/~kay/pub/software/scm/cogito"; +# end config + +my $version = "088-devel"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -35,6 +44,7 @@ if (defined($project)) { die_error("", "No such project."); } $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; + $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; } my $file_name = $cgi->param('f'); @@ -67,7 +77,6 @@ if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { die_error("", "Invalid time parameter."); } -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; mkdir($gittmp, 0700); sub git_header_html { @@ -77,8 +86,8 @@ sub git_header_html { print <<EOF; <?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> --> -<html> <head> <title>git - $project</title> $rss_link @@ -157,7 +166,7 @@ sub git_footer_html { print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; close $fd; } - print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "RSS") . "\n"; } print "</div>\n" . "</body>\n" . @@ -191,7 +200,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/cat-file commit $commit"; + open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -263,7 +272,7 @@ sub git_diff_html { if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open(my $fd2, "> $from_tmp"); - open my $fd, "-|", "$gitbin/cat-file blob $from"; + open my $fd, "-|", "$gitbin/git-cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -275,7 +284,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file blob $to"; + open my $fd, "-|", "$gitbin/git-cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -347,8 +356,8 @@ sub date_str { $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; - $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; - my $local = $epoch + (($1 + ($2/60)) * 3600); + $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/; + my $local = $epoch + ((int $1 + ($2/60)) * 3600); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); $date{'hour_local'} = $hour; $date{'minute_local'} = $min; @@ -356,7 +365,7 @@ sub date_str { return %date; } -if ($action eq "git-logo.png") { +if (defined($action) && $action eq "git-logo.png") { print $cgi->header(-type => 'image/png', -expires => '+1d'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". @@ -393,7 +402,7 @@ if ($action eq "blob") { print "<br/><br/></div>\n"; print "<div class=\"title\">$hash</div>\n"; print "<div class=\"page_body\"><pre>\n"; - open(my $fd, "-|", "$gitbin/cat-file blob $hash"); + open(my $fd, "-|", "$gitbin/git-cat-file blob $hash"); my $nr; while (my $line = <$fd>) { $nr++; @@ -407,13 +416,13 @@ if ($action eq "blob") { if ($hash eq "") { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/ls-tree $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); my %co = git_commit($hash); - if (defined(%co)) { + if (%co) { print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . @@ -446,85 +455,88 @@ if ($action eq "blob") { print "</pre>\n"; print "<br/></div>"; git_footer_html(); -} elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list " . git_head($project); +} elsif ($action eq "rss") { + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_head($project); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; - if ($action eq "log") { - git_header_html(); - print "<div class=\"page_nav\">\n"; - print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; - print "<br/><br/>\n" . - "</div>\n"; - } elsif ($action eq "rss") { - print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); - print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". - "<rss version=\"0.91\">\n"; - print "<channel>\n"; - print "<title>$project</title>\n". - "<link> " . $my_url . "/$project/log</link>\n". - "<description>$project log</description>\n". - "<language>en</language>\n"; - } + print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); + print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". + "<rss version=\"0.91\">\n"; + print "<channel>\n"; + print "<title>$project</title>\n". + "<link> " . $my_url . "/$project/log</link>\n". + "<description>$project log</description>\n". + "<language>en</language>\n"; - for (my $i = 0; $i <= $#revlist; $i++) { - my $commit = $revlist[$i]; + foreach my $commit (@revlist) { my %co = git_commit($commit); my %ad = date_str($co{'author_epoch'}); - if ($action eq "log") { - if ($time_back > 0 && $co{'age'} > $time_back*60*60*24) { - if ($i == 0) { - print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n"; - } - last; - } - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, - "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . - "</div>\n"; - print "<div class=\"title_text\">\n" . - "<div class=\"log_link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" . - "</div>\n" . - "<i>" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]</i><br/>\n" . - "</div>\n" . - "<div class=\"log_body\">\n"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - last if ($line =~ m/^(signed-off|acked)-by:/i); - print escapeHTML($line) . "<br/>\n"; - } - print "<br/>\n" . - "</div>\n"; - } elsif ($action eq "rss") { - last if ($i >= 20); - print "<item>\n" . - "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . - "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" . - "\t<description>"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - print escapeHTML($line) . "\n"; - } - print "\t</description>\n" . - "</item>\n"; + print "<item>\n" . + "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . + "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" . + "\t<description>"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + print escapeHTML($line) . "<br/>\n"; } + print "\t</description>\n" . + "</item>\n"; } - if ($action eq "log") { - git_footer_html(); - } elsif ($action eq "rss") { - print "</channel></rss>"; + print "</channel></rss>"; +} elsif ($action eq "log") { + my $date = 0; + if ($time_back > 0) { + $date = time - $time_back*24*60*60; } + my $head = git_head($project); + open my $fd, "-|", "$gitbin/git-rev-list --max-age=$date $head"; + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + + git_header_html(); + print "<div class=\"page_nav\">\n"; + print "view "; + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; + print "<br/><br/>\n" . + "</div>\n"; + + if (!(@revlist)) { + my %co = git_commit($head); + print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n"; + } + + foreach my $commit (@revlist) { + my %co = git_commit($commit); + my %ad = date_str($co{'author_epoch'}); + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, + "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + print "<div class=\"title_text\">\n" . + "<div class=\"log_link\">\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" . + "</div>\n" . + "<i>" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]</i><br/>\n" . + "</div>\n" . + "<div class=\"log_body\">\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + last if ($line =~ m/^(signed-off|acked)-by:/i); + print escapeHTML($line) . "<br/>\n"; + } + print "<br/>\n" . + "</div>\n"; + } + git_footer_html(); } elsif ($action eq "commit") { my %co = git_commit($hash); - if (!defined(%co)) { + if (!%co) { die_error("", "Unknown commit object."); } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); @@ -532,12 +544,12 @@ if ($action eq "blob") { my @difftree; if (defined($co{'parent'})) { - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; @difftree = map { chomp; $_ } <$fd>; close $fd; } else { # fake git-diff-tree output for initial revision - open my $fd, "-|", "$gitbin/ls-tree -r $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree -r $hash"; @difftree = map { chomp; "+" . $_ } <$fd>; close $fd; } @@ -664,10 +676,10 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); - if (!defined(%co)) { + if (!%co) { die_error("", "Unknown commit object."); } - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -710,7 +722,7 @@ if ($action eq "blob") { if (!(defined($hash))) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/rev-list $hash"; + open my $fd, "-|", "$gitbin/git-rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -725,7 +737,7 @@ if ($action eq "blob") { my $parents = $co{'parents'}; my $found = 0; foreach my $parent (@$parents) { - open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; + open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; From 2735983d79172313359cdf57afce723cc89326fd Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:20:20 +0200 Subject: [PATCH 045/148] v089 --- gitweb.cgi | 127 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 47 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1e8565a8a7d..fa7a0f590b2 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,9 +14,6 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -# !! This devel-version uses a modified git-rev-list binary !! -# The git changes are expected to show up upstream soon. - # begin config my $projectroot = "/pub/scm"; $projectroot = "/home/kay/public_html/pub/scm"; @@ -28,7 +25,7 @@ my $logo_link = "/pub/software/scm/cogito"; $logo_link = "/~kay/pub/software/scm/cogito"; # end config -my $version = "088-devel"; +my $version = "089"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -97,7 +94,7 @@ a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } a:active { color:#880000; } -div.page_header { +div.page_header\{ margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } @@ -132,14 +129,15 @@ div.link { font-family:sans-serif; font-size:10px; } td.key { padding-right:10px; } -a.xml_logo { float:right; border:1px solid; +span.diff_info { color:#000099; background-color:#eeeeee; font-style:italic; } +a.rss_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; font-weight:bold; font-family:sans-serif; text-align:center; font-size:10px; display:block; text-decoration:none; } -a.xml_logo:hover { background-color:#ee5500; } +a.rss_logo:hover { background-color:#ee5500; } </style> </head> <body> @@ -166,7 +164,7 @@ sub git_footer_html { print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; close $fd; } - print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "RSS") . "\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n"; } print "</div>\n" . "</body>\n" . @@ -257,15 +255,13 @@ sub git_commit { } sub git_diff_html { - my $from_name = shift || "/dev/null"; - my $to_name = shift || "/dev/null"; my $from = shift; + my $from_name = shift; my $to = shift; + my $to_name = shift; my $from_tmp = "/dev/null"; my $to_tmp = "/dev/null"; - my $from_label = "/dev/null"; - my $to_label = "/dev/null"; my $pid = $$; # create tmp from-file @@ -277,7 +273,6 @@ sub git_diff_html { print $fd2 @file; close $fd2; close $fd; - $from_label = "a/$from_name"; } # create tmp to-file @@ -289,25 +284,14 @@ sub git_diff_html { print $fd2 @file; close $fd2; close $fd; - $to_label = "b/$to_name"; } - open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp"; - print "<span style=\"color: #000099;\">===== "; - if ($from ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); - } else { - print $from_name; - } - print " vs "; - if ($to ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to); - } else { - print $to_name; - } - print " =====</span>\n"; + open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp"; while (my $line = <$fd>) { my $char = substr($line,0,1); + # skip errors + next if $char eq '\\'; + # color the diff print '<span style="color: #008800;">' if $char eq '+'; print '<span style="color: #CC0000;">' if $char eq '-'; print '<span style="color: #990099;">' if $char eq '@'; @@ -317,29 +301,50 @@ sub git_diff_html { close $fd; if ($from ne "") { - unlink("$from_tmp"); + unlink($from_tmp); } if ($to ne "") { - unlink("$to_tmp"); + unlink($to_tmp); } } sub mode_str { - my $perms = oct shift; + my $mode = oct shift; + my $modestr; - if ($perms & 040000) { - $modestr .= 'drwxr-xr-x'; - } else { + if (($mode & 00170000) == 0040000 ) { + $modestr = 'drwxr-xr-x'; + } elsif (($mode & 00170000) == 0120000 ) { + $modestr = 'lrwxrwxrwx'; + } elsif (($mode & 00170000) == 0100000 ) { # git cares only about the executable bit - if ($perms & 0100) { - $modestr .= '-rwxr-xr-x'; + if ($mode & 0100) { + $modestr = '-rwxr-xr-x'; } else { - $modestr .= '-rw-r--r--'; + $modestr = '-rw-r--r--'; }; } return $modestr; } +sub file_type { + my $mode = oct shift; + + if (($mode & 0170000) == 0040000 ) { + return "directory"; + } elsif (($mode & 0170000) == 0120000 ) { + return "symlink"; + } elsif (($mode & 0170000) == 0100000 ) { + if ($mode & 0100) { + return "executable file"; + } else { + return "file"; + } + } else { + return "unknown"; + } +} + sub date_str { my $epoch = shift; my $tz = shift || "-0000"; @@ -447,7 +452,14 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name); + if (((oct $t_mode) & 0170000) == 0120000) { + open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash"; + my $target = <$fd>; + close $fd; + print "\t -> $target"; + } + print "\n"; } elsif ($t_type eq "tree") { print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; } @@ -614,7 +626,7 @@ if ($action eq "blob") { if ($op eq "+") { print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, - escapeHTML($file) . " <span style=\"color: #008000;\">[new]</span>") . "\n" . + escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -623,7 +635,7 @@ if ($action eq "blob") { } elsif ($op eq "-") { print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, - escapeHTML($file) . " <span style=\"color: #c00000;\">[removed]</span>") . "\n" . + escapeHTML($file) . " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -638,8 +650,8 @@ if ($action eq "blob") { my $from_mode = $1; my $to_mode = $2; my $mode_chnge = ""; - if ($from_mode != $to_mode) { - $mode_chnge = " <span style=\"color: #888888;\"> [chmod $mode]</span>\n"; + if (((oct $from_mode) & 0170100) != ((oct $to_mode) & 0170100)) { + $mode_chnge = " <span style=\"color: #888888;\">[changed from " . file_type($from_mode) . " to " . file_type($to_mode) . "]</span>\n"; } print "<div class=\"list\">\n"; if ($to_id ne $from_id) { @@ -670,7 +682,12 @@ if ($action eq "blob") { print "<div class=\"title\">$hash vs $hash_parent</div>\n"; print "<div class=\"page_body\">\n" . "<pre>\n"; - git_diff_html($hash_parent, $hash, $hash_parent, $hash); + print "<span class=\"diff_info\">blob:" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent"}, $hash_parent) . + " -> blob:" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash"}, $hash) . + "</span>\n"; + git_diff_html($hash_parent, $hash_parent, $hash, $hash); print "</pre>\n" . "<br/></div>"; git_footer_html(); @@ -704,13 +721,29 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - git_diff_html("", $file, "", $id); + print "<span class=\"diff_info\">new " . file_type($mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . + "</span>\n"; + git_diff_html("", "/dev/null", $id, "b/$file"); } elsif ($op eq "-") { - git_diff_html($file, "", $id, ""); + print "<span class=\"diff_info\">deleted " . file_type($mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . + "</span>\n"; + git_diff_html($id, "a/$file", "", "/dev/null"); } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - if ($1 ne $2) { - git_diff_html($file, $file, $1, $2); + my $from_id = $1; + my $to_id = $2; + $mode =~ m/([0-7]+)->([0-7]+)/; + my $from_mode = $1; + my $to_mode = $2; + if ($from_id ne $to_id) { + print "<span class=\"diff_info\">" . + file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id"}, $from_id) . + " -> " . + file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, $to_id); + print "</span>\n"; + git_diff_html($from_id, "a/$file", $to_id, "b/$file"); } } } From b87d78d60ce3798c8938ba1d3ed176b6ed9ba539 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:21:04 +0200 Subject: [PATCH 046/148] v107 --- gitweb.cgi | 539 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 339 insertions(+), 200 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fa7a0f590b2..ec68636c243 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -5,39 +5,79 @@ # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> # -# This file is licensed under the GPL v2, or a later version +# This program is licensed under the GPL v2, or a later version use strict; use warnings; use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); +use Fcntl ':mode'; my $cgi = new CGI; - -# begin config -my $projectroot = "/pub/scm"; -$projectroot = "/home/kay/public_html/pub/scm"; -my $home_link = "/git"; -$home_link = "/~kay/git"; -my $gitbin = "/usr/bin"; -my $gittmp = "/tmp/gitweb"; -my $logo_link = "/pub/software/scm/cogito"; -$logo_link = "/~kay/pub/software/scm/cogito"; -# end config - -my $version = "089"; +my $version = "107"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; +# absolute fs-path which will be prepended to the project path +my $projectroot = "/pub/scm"; + +# location of the git-core binaries +my $gitbin = "/usr/bin"; + +# location for temporary files needed for diffs +my $gittmp = "/tmp/gitweb"; + +# target of the home link on top of all pages +my $home_link = $my_uri; +$home_link = "/git"; + +# handler to return the list of projects +sub get_projects_list { + my @list; + + # search in directory +# my $dir = $projectroot; +# opendir my $dh, $dir || return undef; +# while (my $dir = readdir($dh)) { +# if (-e "$projectroot/$dir/HEAD") { +# push @list, $dir; +# } +# } +# closedir($dh); + + # read from file + my $file = "index/index.txt"; + open my $fd , $file || return undef; + while (my $line = <$fd>) { + chomp $line; + if (-e "$projectroot/$line/HEAD") { + push @list, $line; + } + } + close $fd; + + @list = sort @list; + return \@list; +} + +# input validation my $project = $cgi->param('p'); -if (defined($project)) { - if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - $project = ""; - die_error("", "Invalid project parameter."); +if (defined $project) { + if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $project; + die_error("", "Non-canonical project parameter."); + } + if ($project =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + undef $project; + die_error("", "Invalid character in project parameter."); } if (!(-d "$projectroot/$project")) { - $project = ""; + undef $project; + die_error("", "No such directory."); + } + if (!(-e "$projectroot/$project/HEAD")) { + undef $project; die_error("", "No such project."); } $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; @@ -45,40 +85,57 @@ if (defined($project)) { } my $file_name = $cgi->param('f'); -if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { - $file_name = ""; - die_error("", "Invalid file parameter."); +if (defined $file_name) { + if ($file_name =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $file_name; + die_error("", "Non-canonical file parameter."); + } + if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + undef $file_name; + die_error("", "Invalid character in file parameter."); + } } my $action = $cgi->param('a'); -if (defined($action) && $action =~ m/[^0-9a-zA-Z\.\-]+$/) { - $action = ""; - die_error("", "Invalid action parameter."); +if (defined $action) { + if ($action =~ m/[^0-9a-zA-Z\.\-]+/) { + undef $action; + die_error("", "Invalid action parameter."); + } +} else { + $action = "log"; } my $hash = $cgi->param('h'); -if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { - $hash = ""; +if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { + undef $hash; die_error("", "Invalid hash parameter."); } my $hash_parent = $cgi->param('hp'); -if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { - $hash_parent = ""; +if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { + undef $hash_parent; die_error("", "Invalid parent hash parameter."); } my $time_back = $cgi->param('t'); -if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { - $time_back = ""; - die_error("", "Invalid time parameter."); +if (defined $time_back) { + if ($time_back =~ m/^[^0-9]+$/) { + undef $time_back; + die_error("", "Invalid time parameter."); + } } -mkdir($gittmp, 0700); - sub git_header_html { my $status = shift || "200 OK"; + my $title = "git"; + if (defined $project) { + $title .= " - $project"; + if (defined $action) { + $title .= "/$action"; + } + } print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); print <<EOF; <?xml version="1.0" encoding="utf-8"?> @@ -86,7 +143,7 @@ sub git_header_html { <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> --> <head> -<title>git - $project</title> +<title>$title</title> $rss_link <style type="text/css"> body { font-family: sans-serif; font-size: 12px; margin:0px; } @@ -94,47 +151,47 @@ a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } a:active { color:#880000; } -div.page_header\{ - margin:15px 25px 0px; height:25px; padding:8px; +div.page_header { + margin:15px 15px 0px; height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } div.page_header a:visited { color:#0000cc; } div.page_header a:hover { color:#880000; } -div.page_nav { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } +div.page_nav { margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.page_nav a:visited { color:#0000cc; } -div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; background-color: #d9d8d1; } +div.page_footer { margin:0px 15px 15px; height:17px; padding:4px; padding-left:8px; background-color: #d9d8d1; } div.page_footer_text { float:left; color:#555555; font-style:italic; } -div.page_body { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } +div.page_body { margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.title, a.title { - display:block; margin:0px 25px; padding:6px 8px; + display:block; margin:0px 15px; padding:6px 8px; font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; } a.title:hover { background-color: #d9d8d1; } -div.title_text { margin:0px 25px; padding:6px 8px; border: solid #d9d8d1; border-width:0px 1px 1px; } -div.log_body { margin:0px 25px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } +div.title_text { margin:0px 15px; padding:6px 8px; border: solid #d9d8d1; border-width:0px 1px 1px; } +div.log_body { margin:0px 15px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } span.log_age { position:relative; float:left; width:142px; font-style:italic; } div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } div.list { - display:block; margin:0px 25px; padding:4px 6px 2px; border:solid #d9d8d1; border-width:1px 1px 0px; + display:block; margin:0px 15px; padding:4px 6px 2px; border:solid #d9d8d1; border-width:1px 1px 0px; font-weight:bold; } div.list_head { - display:block; margin:0px 25px; padding:4px 6px 4px; border:solid #d9d8d1; border-width:1px 1px 0px; + display:block; margin:0px 15px; padding:4px 6px 4px; border:solid #d9d8d1; border-width:1px 1px 0px; font-style:italic; } div.list a { text-decoration:none; color:#000000; } div.list a:hover { color:#880000; } div.link { - margin:0px 25px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px; + margin:0px 15px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } -td.key { padding-right:10px; } -span.diff_info { color:#000099; background-color:#eeeeee; font-style:italic; } -a.rss_logo { float:right; border:1px solid; - line-height:15px; +td { padding:5px 15px 0px 0px; font-size:12px; } +th { padding-right:10px; font-size:12px; text-align:left; } +span.diff_info { color:#000099; background-color:#edece6; font-style:italic; } +a.rss_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; text-align:center; + font-weight:bold; font-family:sans-serif; text-align:center; vertical-align:middle; font-size:10px; display:block; text-decoration:none; } a.rss_logo:hover { background-color:#ee5500; } @@ -143,26 +200,24 @@ a.rss_logo:hover { background-color:#ee5500; } <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"$logo_link\">" . + "<a href=\"http://kernel.org/pub/software/scm/cogito\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; - print $cgi->a({-href => "$my_uri"}, "projects") . " / "; - if ($project ne "") { + print $cgi->a({-href => $home_link}, "projects") . " / "; + if (defined $project) { print $cgi->a({-href => "$my_uri?p=$project;a=log"}, escapeHTML($project)); - } - if ($action ne "") { - print " / $action"; + if (defined $action) { + print " / $action"; + } } print "</div>\n"; } sub git_footer_html { print "<div class=\"page_footer\">\n"; - if ($project ne "") { - if (-e "$projectroot/$project/description") { - open(my $fd, "$projectroot/$project/description"); - my $descr = <$fd>; + if (defined $project) { + my $descr = git_description($project); + if (defined $descr) { print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; - close $fd; } print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n"; } @@ -186,11 +241,24 @@ sub die_error { sub git_head { my $path = shift; - open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory."); + open my $fd, "$projectroot/$path/HEAD" || return undef; my $head = <$fd>; close $fd; chomp $head; - return $head; + if ($head =~ m/^[0-9a-fA-F]{40}$/) { + return $head; + } else { + return undef; + } +} + +sub git_description { + my $path = shift; + open my $fd, "$projectroot/$path/description" || return undef; + my $descr = <$fd>; + close $fd; + chomp $descr; + return $descr; } sub git_commit { @@ -198,10 +266,10 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; + open my $fd, "-|", "$gitbin/git-cat-file commit $commit" || return; while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; + last if $line eq "\n"; + chomp $line; if ($line =~ m/^tree (.*)$/) { $co{'tree'} = $1; } elsif ($line =~ m/^parent (.*)$/) { @@ -220,15 +288,15 @@ sub git_commit { $co{'committer_name'} =~ s/ <.*//; } } - if (!defined($co{'tree'})) { - return; - } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; $co{'title'} = $comment[0]; - close $fd; + close $fd || return; + if (!defined $co{'tree'}) { + return undef + }; my $age = time - $co{'committer_epoch'}; $co{'age'} = $age; @@ -250,6 +318,11 @@ sub git_commit { } elsif ($age > 60*2) { $co{'age_string'} = int $age/60; $co{'age_string'} .= " minutes ago"; + } elsif ($age > 2) { + $co{'age_string'} = int $age; + $co{'age_string'} .= " seconds ago"; + } else { + $co{'age_string'} .= " right now"; } return %co; } @@ -265,9 +338,9 @@ sub git_diff_html { my $pid = $$; # create tmp from-file - if ($from ne "") { + if (defined $from) { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; - open(my $fd2, "> $from_tmp"); + open my $fd2, "> $from_tmp"; open my $fd, "-|", "$gitbin/git-cat-file blob $from"; my @file = <$fd>; print $fd2 @file; @@ -276,7 +349,7 @@ sub git_diff_html { } # create tmp to-file - if ($to ne "") { + if (defined $to) { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; open my $fd, "-|", "$gitbin/git-cat-file blob $to"; @@ -300,10 +373,10 @@ sub git_diff_html { } close $fd; - if ($from ne "") { + if (defined $from) { unlink($from_tmp); } - if ($to ne "") { + if (defined $to) { unlink($to_tmp); } } @@ -311,35 +384,31 @@ sub git_diff_html { sub mode_str { my $mode = oct shift; - my $modestr; - if (($mode & 00170000) == 0040000 ) { - $modestr = 'drwxr-xr-x'; - } elsif (($mode & 00170000) == 0120000 ) { - $modestr = 'lrwxrwxrwx'; - } elsif (($mode & 00170000) == 0100000 ) { + if (S_ISDIR($mode & S_IFMT)) { + return 'drwxr-xr-x'; + } elsif (S_ISLNK($mode)) { + return 'lrwxrwxrwx'; + } elsif (S_ISREG($mode)) { # git cares only about the executable bit - if ($mode & 0100) { - $modestr = '-rwxr-xr-x'; + if ($mode & S_IXUSR) { + return '-rwxr-xr-x'; } else { - $modestr = '-rw-r--r--'; + return '-rw-r--r--'; }; + } else { + return '----------'; } - return $modestr; } sub file_type { my $mode = oct shift; - if (($mode & 0170000) == 0040000 ) { + if (S_ISDIR($mode & S_IFMT)) { return "directory"; - } elsif (($mode & 0170000) == 0120000 ) { + } elsif (S_ISLNK($mode)) { return "symlink"; - } elsif (($mode & 0170000) == 0100000 ) { - if ($mode & 0100) { - return "executable file"; - } else { - return "file"; - } + } elsif (S_ISREG($mode)) { + return "file"; } else { return "unknown"; } @@ -370,60 +439,102 @@ sub date_str { return %date; } -if (defined($action) && $action eq "git-logo.png") { +# git-logo (cached in browser for one day) +if (defined $action && $action eq "git-logo.png") { print $cgi->header(-type => 'image/png', -expires => '+1d'); - print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". - "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". - "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". - "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367". - "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143". - "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010". - "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261". - "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052". - "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030". - "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202". - "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006". - "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". - "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; + # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g' + print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" . + "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" . + "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" . + "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" . + "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" . + "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" . + "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" . + "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" . + "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" . + "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" . + "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" . + "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" . + "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82"; exit; } -if (!defined($project)) { - print $cgi->redirect($home_link); +# project browser +if (!defined $project) { + my $projects = get_projects_list(); + git_header_html(); + print "<div class=\"page_body\">\n"; + print "<table cellspacing=\"0\">\n"; + print "<tr>\n" . + "<th>Project</th>\n" . + "<th>Description</th>\n" . + "<th>Owner</th>\n" . + "<th>last change</th>\n" . + "</tr>\n" . + "<br/>"; + foreach my $proj (@$projects) { + my $head = git_head($proj); + if (!defined $head) { + next; + } + $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj/objects"; + my %co = git_commit($head); + if (!%co) { + next; + } + my $descr = git_description($proj) || ""; + my $owner = ""; + my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat("$projectroot/$proj"); + my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid); + if (defined $gcos) { + $owner = $gcos; + $owner =~ s/[,;].*$//; + } + print "<tr>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$proj;a=log"}, escapeHTML($proj)) . "</td>\n" . + "<td>$descr</td>\n" . + "<td><i>$owner</i></td>\n"; + if ($co{'age'} < 60*60*2) { + print "<td><span style =\"color: #009900;\"><b><i>" . $co{'age_string'} . "</i></b></span></td>\n"; + } elsif ($co{'age'} < 60*60*24*2) { + print "<td><span style =\"color: #009900;\"><i>" . $co{'age_string'} . "</i></span></td>\n"; + } else { + print "<td><i>" . $co{'age_string'} . "</i></td>\n"; + } + print "</tr>\n"; + undef %co; + } + print "</table>\n" . + "<br/>\n" . + "</div>\n"; + git_footer_html(); exit; } -if (!defined($action)) { - $action = "log"; -} - -if (!defined($time_back)) { - $time_back = 1; -} - +# action dispatch if ($action eq "blob") { + open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error("", "Open failed."); git_header_html(); print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; print "<div class=\"title\">$hash</div>\n"; print "<div class=\"page_body\"><pre>\n"; - open(my $fd, "-|", "$gitbin/git-cat-file blob $hash"); my $nr; while (my $line = <$fd>) { $nr++; printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);; } - close $fd; - print "<br/></pre>\n"; + close $fd || print "Reading blob failed.\n"; + print "</pre><br/>\n"; print "</div>"; git_footer_html(); } elsif ($action eq "tree") { - if ($hash eq "") { + if (!defined $hash) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/git-ls-tree $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error("", "Open failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd; + close $fd || die_error("", "Reading tree failed."); git_header_html(); my %co = git_commit($hash); @@ -453,7 +564,7 @@ if ($action eq "blob") { my $t_name = $4; if ($t_type eq "blob") { print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name); - if (((oct $t_mode) & 0170000) == 0120000) { + if (S_ISLNK(oct $t_mode)) { open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash"; my $target = <$fd>; close $fd; @@ -468,9 +579,9 @@ if ($action eq "blob") { print "<br/></div>"; git_footer_html(); } elsif ($action eq "rss") { - open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_head($project); + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_head($project) || die_error("", "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd; + close $fd || die_error("", "Reading rev-list failed."); print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". @@ -494,22 +605,28 @@ if ($action eq "blob") { } print "\t</description>\n" . "</item>\n"; + undef %ad; + undef %co; } print "</channel></rss>"; } elsif ($action eq "log") { - my $date = 0; - if ($time_back > 0) { - $date = time - $time_back*24*60*60; - } my $head = git_head($project); - open my $fd, "-|", "$gitbin/git-rev-list --max-age=$date $head"; + my $limit_option = ""; + if (!defined $time_back) { + $limit_option = "--max-count=10"; + } elsif ($time_back > 0) { + my $date = time - $time_back*24*60*60; + $limit_option = "--max-age=$date"; + } + open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error("", "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd; + close $fd || die_error("", "Reading rev-list failed."); git_header_html(); print "<div class=\"page_nav\">\n"; print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last 10") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=1"}, "day") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . @@ -517,13 +634,14 @@ if ($action eq "blob") { print "<br/><br/>\n" . "</div>\n"; - if (!(@revlist)) { + if (!@revlist) { my %co = git_commit($head); print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n"; } foreach my $commit (@revlist) { my %co = git_commit($commit); + next if !%co; my %ad = date_str($co{'author_epoch'}); print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, @@ -544,6 +662,8 @@ if ($action eq "blob") { } print "<br/>\n" . "</div>\n"; + undef %ad; + undef %co; } git_footer_html(); } elsif ($action eq "commit") { @@ -555,15 +675,15 @@ if ($action eq "blob") { my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); my @difftree; - if (defined($co{'parent'})) { - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; + if (defined $co{'parent'}) { + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error("", "Open failed."); @difftree = map { chomp; $_ } <$fd>; - close $fd; + close $fd || die_error("", "Reading diff-tree failed."); } else { # fake git-diff-tree output for initial revision - open my $fd, "-|", "$gitbin/git-ls-tree -r $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error("", "Open failed."); @difftree = map { chomp; "+" . $_ } <$fd>; - close $fd; + close $fd || die_error("", "Reading ls-tree failed."); } git_header_html(); print "<div class=\"page_nav\"> view\n" . @@ -571,32 +691,38 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . - "</div>\n"; + if (defined $co{'parent'}) { + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + } else { + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + } print "<div class=\"title_text\">\n" . - "<table cellspacing=\"0\">"; - print "<tr><td class=\"key\">author</td><td>" . escapeHTML($co{'author'}) . "</td><tr><td></td><td>" . - " " . $ad{'rfc2822'}; + "<table cellspacing=\"0\">\n"; + print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n". + "<tr><td></td><td> " . $ad{'rfc2822'}; if ($ad{'hour_local'} < 6) { - print "<span style=\"color: #cc0000;\">"; + printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); + } else { + printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } - printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); - if ($ad{'hour_local'} < 6 ) { - print "</span>"; - } - print "</i>\n" . - "</td></tr>\n"; - print "<tr><td class=\"key\">committer</td><td>" . escapeHTML($co{'committer'}) . "</td><tr><td></td><td>" . - " " . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</i>\n" . - "</td></tr>\n"; - print "<tr><td class=\"key\">commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; - print "<tr><td class=\"key\">tree</td><td style=\"font-family: monospace;\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "</td></tr>\n"; + print "</td></tr>\n"; + print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; + print "<tr><td></td><td> " . $cd{'rfc2822'} . + sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; + print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; + print "<tr><td>tree</td><td style=\"font-family: monospace;\">" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "</td></tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "<tr><td class=\"key\">parent</td><td style=\"font-family: monospace;\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n"; + print "<tr><td>parent</td><td style=\"font-family: monospace;\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n"; } - print "</table></div>\n"; + print "</table>". + "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -621,12 +747,15 @@ if ($action eq "blob") { my $type = $3; my $id = $4; my $file = $5; - my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { + my $mode_chng = ""; + if (S_ISREG(oct $mode)) { + $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777); + } print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, - escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . "]</span>") . "\n" . + escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . @@ -650,8 +779,19 @@ if ($action eq "blob") { my $from_mode = $1; my $to_mode = $2; my $mode_chnge = ""; - if (((oct $from_mode) & 0170100) != ((oct $to_mode) & 0170100)) { - $mode_chnge = " <span style=\"color: #888888;\">[changed from " . file_type($from_mode) . " to " . file_type($to_mode) . "]</span>\n"; + if ($from_mode != $to_mode) { + $mode_chnge = " <span style=\"color: #888888;\">[changed"; + if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) { + $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode); + } + if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) { + if (S_ISREG($from_mode) && S_ISREG($to_mode)) { + $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777); + } elsif (S_ISREG($to_mode)) { + $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777); + } + } + $mode_chnge .= "]</span>\n"; } print "<div class=\"list\">\n"; if ($to_id ne $from_id) { @@ -676,6 +816,7 @@ if ($action eq "blob") { } git_footer_html(); } elsif ($action eq "blobdiff") { + mkdir($gittmp, 0700); git_header_html(); print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; @@ -692,13 +833,14 @@ if ($action eq "blob") { "<br/></div>"; git_footer_html(); } elsif ($action eq "commitdiff") { + mkdir($gittmp, 0700); my %co = git_commit($hash); if (!%co) { die_error("", "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error("", "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; - close $fd; + close $fd || die_error("", "Reading diff-tree failed."); git_header_html(); print "<div class=\"page_nav\"> view\n" . @@ -721,15 +863,15 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "<span class=\"diff_info\">new " . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . + print "<span class=\"diff_info\">" . file_type($mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . "(new)" . "</span>\n"; - git_diff_html("", "/dev/null", $id, "b/$file"); + git_diff_html(undef, "/dev/null", $id, "b/$file"); } elsif ($op eq "-") { - print "<span class=\"diff_info\">deleted " . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . + print "<span class=\"diff_info\">" . file_type($mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . "(deleted)" . "</span>\n"; - git_diff_html($id, "a/$file", "", "/dev/null"); + git_diff_html($id, "a/$file", undef, "/dev/null"); } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $from_id = $1; @@ -748,55 +890,52 @@ if ($action eq "blob") { } } } - print "<br/></pre>\n"; + print "</pre><br/>\n"; print "</div>"; git_footer_html(); } elsif ($action eq "history") { - if (!(defined($hash))) { + if (!defined $hash) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/git-rev-list $hash"; - my (@revlist) = map { chomp; $_ } <$fd>; - close $fd; - git_header_html(); print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($file_name)) . "\n" . "</div>\n"; - foreach my $rev (@revlist) { - my %co = git_commit($rev); - my $parents = $co{'parents'}; - my $found = 0; - foreach my $parent (@$parents) { - open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name"; - my (@difftree) = map { chomp; $_ } <$fd>; - close $fd; - - foreach my $line (@difftree) { - $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; - my $file = $5; - if ($file eq $file_name) { - $found = 1; - last; - } - } + open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; + my $commit; + while (my $line = <$fd>) { + if ($line =~ m/^([0-9a-fA-F]{40}) /){ + $commit = $1; + next; } - if ($found) { + if ($line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/ && (defined $commit)) { + my $type = $3; + my $file = $5; + if ($file ne $file_name || $type ne "blob") { + next; + } + my %co = git_commit($commit); + if (!%co) { + next; + } print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"link\">\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$commit"}, "tree") . "<br/><br/>\n" . "</div>\n"; + undef %co; + undef $commit; } } + close $fd; git_footer_html(); } else { - $action = ""; + undef $action; die_error("", "Unknown action."); } From 09bd78984114118208fecb2c52e4dabdba20fa17 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:21:23 +0200 Subject: [PATCH 047/148] v118 --- gitweb.cgi | 501 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 338 insertions(+), 163 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index ec68636c243..546b239720c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "107"; +my $version = "118"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -29,103 +29,120 @@ my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; # target of the home link on top of all pages -my $home_link = $my_uri; -$home_link = "/git"; +my $home_link = "/git"; -# handler to return the list of projects -sub get_projects_list { - my @list; +# source of projects list +#my $projects_list = $projectroot; +my $projects_list = "index/index.txt"; - # search in directory -# my $dir = $projectroot; -# opendir my $dh, $dir || return undef; -# while (my $dir = readdir($dh)) { -# if (-e "$projectroot/$dir/HEAD") { -# push @list, $dir; -# } -# } -# closedir($dh); - - # read from file - my $file = "index/index.txt"; - open my $fd , $file || return undef; - while (my $line = <$fd>) { - chomp $line; - if (-e "$projectroot/$line/HEAD") { - push @list, $line; - } +# input validation and dispatch +my $action = $cgi->param('a'); +if (defined $action) { + if ($action =~ m/[^0-9a-zA-Z\.\-]+/) { + undef $action; + die_error(undef, "Invalid action parameter."); } - close $fd; - - @list = sort @list; - return \@list; + if ($action eq "git-logo.png") { + git_logo(); + exit; + } +} else { + $action = "log"; } -# input validation my $project = $cgi->param('p'); if (defined $project) { if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) { undef $project; - die_error("", "Non-canonical project parameter."); + die_error(undef, "Non-canonical project parameter."); } if ($project =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { undef $project; - die_error("", "Invalid character in project parameter."); + die_error(undef, "Invalid character in project parameter."); } if (!(-d "$projectroot/$project")) { undef $project; - die_error("", "No such directory."); + die_error(undef, "No such directory."); } if (!(-e "$projectroot/$project/HEAD")) { undef $project; - die_error("", "No such project."); + die_error(undef, "No such project."); } $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; +} else { + git_project_list($projects_list); + exit; } my $file_name = $cgi->param('f'); if (defined $file_name) { if ($file_name =~ m/(^|\/)(|\.|\.\.)($|\/)/) { undef $file_name; - die_error("", "Non-canonical file parameter."); + die_error(undef, "Non-canonical file parameter."); } - if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { undef $file_name; - die_error("", "Invalid character in file parameter."); + die_error(undef, "Invalid character in file parameter."); } } -my $action = $cgi->param('a'); -if (defined $action) { - if ($action =~ m/[^0-9a-zA-Z\.\-]+/) { - undef $action; - die_error("", "Invalid action parameter."); - } -} else { - $action = "log"; -} - my $hash = $cgi->param('h'); if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { undef $hash; - die_error("", "Invalid hash parameter."); + die_error(undef, "Invalid hash parameter."); } my $hash_parent = $cgi->param('hp'); if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { undef $hash_parent; - die_error("", "Invalid parent hash parameter."); + die_error(undef, "Invalid hash_parent parameter."); +} + +my $hash_base = $cgi->param('hb'); +if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) { + undef $hash_base; + die_error(undef, "Invalid parent hash parameter."); } my $time_back = $cgi->param('t'); if (defined $time_back) { if ($time_back =~ m/^[^0-9]+$/) { undef $time_back; - die_error("", "Invalid time parameter."); + die_error(undef, "Invalid time parameter."); } } +if ($action eq "blob") { + git_blob(); + exit; +} elsif ($action eq "tree") { + git_tree(); + exit; +} elsif ($action eq "rss") { + git_rss(); + exit; +} elsif ($action eq "commit") { + git_commit(); + exit; +} elsif ($action eq "log") { + git_log(); + exit; +} elsif ($action eq "blobdiff") { + git_blobdiff(); + exit; +} elsif ($action eq "commitdiff") { + git_commitdiff(); + exit; +} elsif ($action eq "history") { + git_history(); + exit; +} else { + undef $action; + die_error(undef, "Unknown action."); + exit; +} + sub git_header_html { my $status = shift || "200 OK"; @@ -159,6 +176,7 @@ div.page_header a:visited { color:#0000cc; } div.page_header a:hover { color:#880000; } div.page_nav { margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.page_nav a:visited { color:#0000cc; } +div.page_path { font-weight:bold; margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px 1px} div.page_footer { margin:0px 15px 15px; height:17px; padding:4px; padding-left:8px; background-color: #d9d8d1; } div.page_footer_text { float:left; color:#555555; font-style:italic; } div.page_body { margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } @@ -172,27 +190,27 @@ div.log_body { margin:0px 15px; padding:8px; padding-left:150px; border:solid #d span.log_age { position:relative; float:left; width:142px; font-style:italic; } div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } div.list { - display:block; margin:0px 15px; padding:4px 6px 2px; border:solid #d9d8d1; border-width:1px 1px 0px; + display:block; margin:0px 15px; padding:4px 6px 2px; border:solid #d9d8d1; border-width:0px 1px; font-weight:bold; } div.list_head { - display:block; margin:0px 15px; padding:4px 6px 4px; border:solid #d9d8d1; border-width:1px 1px 0px; + display:block; margin:0px 15px; padding:6px 6px 4px; border:solid #d9d8d1; border-width:0px 1px 1px; font-style:italic; } div.list a { text-decoration:none; color:#000000; } div.list a:hover { color:#880000; } div.link { - margin:0px 15px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px; + margin:0px 15px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px 1px; font-family:sans-serif; font-size:10px; } td { padding:5px 15px 0px 0px; font-size:12px; } th { padding-right:10px; font-size:12px; text-align:left; } span.diff_info { color:#000099; background-color:#edece6; font-style:italic; } -a.rss_logo { float:right; border:1px solid; line-height:15px; - border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; +a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; + border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; text-align:center; vertical-align:middle; - font-size:10px; display:block; text-decoration:none; + font-weight:bold; font-family:sans-serif; font-size:10px; + text-align:center; text-decoration:none; } a.rss_logo:hover { background-color:#ee5500; } </style> @@ -215,7 +233,7 @@ EOF sub git_footer_html { print "<div class=\"page_footer\">\n"; if (defined $project) { - my $descr = git_description($project); + my $descr = git_read_description($project); if (defined $descr) { print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; } @@ -236,11 +254,12 @@ sub die_error { print "$status - $error\n"; print "<br/></div>\n"; git_footer_html(); - exit 0; + exit; } -sub git_head { +sub git_read_head { my $path = shift; + open my $fd, "$projectroot/$path/HEAD" || return undef; my $head = <$fd>; close $fd; @@ -252,8 +271,9 @@ sub git_head { } } -sub git_description { +sub git_read_description { my $path = shift; + open my $fd, "$projectroot/$path/description" || return undef; my $descr = <$fd>; close $fd; @@ -261,7 +281,7 @@ sub git_description { return $descr; } -sub git_commit { +sub git_read_commit { my $commit = shift; my %co; my @parents; @@ -440,7 +460,7 @@ sub date_str { } # git-logo (cached in browser for one day) -if (defined $action && $action eq "git-logo.png") { +sub git_logo() { print $cgi->header(-type => 'image/png', -expires => '+1d'); # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g' print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" . @@ -456,12 +476,39 @@ if (defined $action && $action eq "git-logo.png") { "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" . "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" . "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82"; - exit; } -# project browser -if (!defined $project) { - my $projects = get_projects_list(); +sub git_project_list { + my $project_list = shift; + my @list; + + if (-d $project_list) { + # search in directory + my $dir = $project_list; + opendir my $dh, $dir || return undef; + while (my $dir = readdir($dh)) { + if (-e "$projectroot/$dir/HEAD") { + push @list, $dir; + } + } + closedir($dh); + } elsif (-e $project_list) { + # read from file + open my $fd , $project_list || return undef; + while (my $line = <$fd>) { + chomp $line; + if (-e "$projectroot/$line/HEAD") { + push @list, $line; + } + } + close $fd; + } + + if (!@list) { + die_error(undef, "No project found."); + } + @list = sort @list; + git_header_html(); print "<div class=\"page_body\">\n"; print "<table cellspacing=\"0\">\n"; @@ -472,17 +519,17 @@ if (!defined $project) { "<th>last change</th>\n" . "</tr>\n" . "<br/>"; - foreach my $proj (@$projects) { - my $head = git_head($proj); + foreach my $proj (@list) { + my $head = git_read_head($proj); if (!defined $head) { next; } $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj/objects"; - my %co = git_commit($head); + my %co = git_read_commit($head); if (!%co) { next; } - my $descr = git_description($proj) || ""; + my $descr = git_read_description($proj) || ""; my $owner = ""; my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat("$projectroot/$proj"); my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid); @@ -502,59 +549,123 @@ if (!defined $project) { print "<td><i>" . $co{'age_string'} . "</i></td>\n"; } print "</tr>\n"; - undef %co; } print "</table>\n" . "<br/>\n" . "</div>\n"; git_footer_html(); - exit; } -# action dispatch -if ($action eq "blob") { - open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error("", "Open failed."); +sub git_get_hash_by_path { + my $base = shift; + my $path = shift; + + my $tree = $base; + my @parts = split '/', $path; + while (my $part = shift @parts) { + open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error(undef, "Open git-ls-tree failed."); + my (@entries) = map { chomp; $_ } <$fd>; + close $fd || die_error(undef, "Reading tree failed."); + foreach my $line (@entries) { + #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' + $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; + my $t_mode = $1; + my $t_type = $2; + my $t_hash = $3; + my $t_name = $4; + if ($t_name eq $part) { + if (!(@parts)) { + return $t_hash; + } + if ($t_type eq "tree") { + $tree = $t_hash; + } + last; + } + } + } +} + +sub git_blob { + if (!defined $hash && defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "blob"); + } + open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error(undef, "Open failed."); + my $base = $file_name || ""; git_header_html(); - print "<div class=\"page_nav\">\n"; - print "<br/><br/></div>\n"; - print "<div class=\"title\">$hash</div>\n"; - print "<div class=\"page_body\"><pre>\n"; + if (defined $hash_base && (my %co = git_read_commit($hash_base))) { + print "<div class=\"page_nav\"> view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + if (defined $file_name) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); + } + print "<br/><br/>\n" . + "</div>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n"; + } else { + print "<div class=\"page_nav\">\n" . + "<br/><br/></div>\n" . + "<div class=\"title\">$hash</div>\n"; + } + if (defined $file_name) { + print "<div class=\"page_path\">/$file_name</div>\n"; + } + print "<div class=\"page_body\"><pre>\n" . my $nr; while (my $line = <$fd>) { $nr++; printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);; } close $fd || print "Reading blob failed.\n"; - print "</pre><br/>\n"; + print "</pre>\n"; print "</div>"; git_footer_html(); -} elsif ($action eq "tree") { +} + +sub git_tree { if (!defined $hash) { - $hash = git_head($project); + $hash = git_read_head($project); + if (defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "tree"); + } } - open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading tree failed."); + close $fd || die_error(undef, "Reading tree failed."); git_header_html(); - my %co = git_commit($hash); - if (%co) { + my $base_key = ""; + my $file_key = ""; + my $base = ""; + if (defined $hash_base && (my %co = git_read_commit($hash_base))) { + $base_key = ";hb=$hash_base"; print "<div class=\"page_nav\"> view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n"; print "<br/><br/></div>\n"; print "<div class=\"title\">$hash</div>\n"; } + if (defined $file_name) { + $base = "$file_name/"; + print "<div class=\"page_path\">/$file_name</div>\n"; + } else { + print "<div class=\"page_path\">/</div>\n"; + } print "<div class=\"page_body\">\n"; - print "<br/><pre>\n"; + print "<pre>\n"; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -562,8 +673,9 @@ if ($action eq "blob") { my $t_type = $2; my $t_hash = $3; my $t_name = $4; + $file_key = ";f=$base$t_name"; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name); + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, $t_name); if (S_ISLNK(oct $t_mode)) { open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash"; my $target = <$fd>; @@ -572,16 +684,18 @@ if ($action eq "blob") { } print "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "\n"; } } print "</pre>\n"; - print "<br/></div>"; + print "</div>"; git_footer_html(); -} elsif ($action eq "rss") { - open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_head($project) || die_error("", "Open failed."); +} + +sub git_rss { + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_head($project) || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading rev-list failed."); + close $fd || die_error(undef, "Reading rev-list failed."); print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". @@ -593,7 +707,7 @@ if ($action eq "blob") { "<language>en</language>\n"; foreach my $commit (@revlist) { - my %co = git_commit($commit); + my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); print "<item>\n" . "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . @@ -605,12 +719,12 @@ if ($action eq "blob") { } print "\t</description>\n" . "</item>\n"; - undef %ad; - undef %co; } print "</channel></rss>"; -} elsif ($action eq "log") { - my $head = git_head($project); +} + +sub git_log { + my $head = git_read_head($project); my $limit_option = ""; if (!defined $time_back) { $limit_option = "--max-count=10"; @@ -618,9 +732,9 @@ if ($action eq "blob") { my $date = time - $time_back*24*60*60; $limit_option = "--max-age=$date"; } - open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading rev-list failed."); + close $fd || die_error(undef, "Reading rev-list failed."); git_header_html(); print "<div class=\"page_nav\">\n"; @@ -635,16 +749,16 @@ if ($action eq "blob") { "</div>\n"; if (!@revlist) { - my %co = git_commit($head); + my %co = git_read_commit($head); print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n"; } foreach my $commit (@revlist) { - my %co = git_commit($commit); + my %co = git_read_commit($commit); next if !%co; my %ad = date_str($co{'author_epoch'}); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . @@ -656,40 +770,53 @@ if ($action eq "blob") { "</div>\n" . "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; + my $empty = 0; foreach my $line (@$comment) { - last if ($line =~ m/^(signed-off|acked)-by:/i); - print escapeHTML($line) . "<br/>\n"; + if ($line =~ m/^(signed.off|acked).by/i) { + next; + } + if ($line eq "") { + if ($empty) { + next; + } + $empty = 1; + } else { + $empty = 0; + } + print escapeHTML($line) . "<br/>\n"; } - print "<br/>\n" . - "</div>\n"; - undef %ad; - undef %co; + if (!$empty) { + print "<br/>\n"; + } + print "</div>\n"; } git_footer_html(); -} elsif ($action eq "commit") { - my %co = git_commit($hash); +} + +sub git_commit { + my %co = git_read_commit($hash); if (!%co) { - die_error("", "Unknown commit object."); + die_error(undef, "Unknown commit object."); } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); my @difftree; if (defined $co{'parent'}) { - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading diff-tree failed."); + close $fd || die_error(undef, "Reading diff-tree failed."); } else { # fake git-diff-tree output for initial revision - open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error(undef, "Open failed."); @difftree = map { chomp; "+" . $_ } <$fd>; - close $fd || die_error("", "Reading ls-tree failed."); + close $fd || die_error(undef, "Reading ls-tree failed."); } git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . @@ -697,7 +824,7 @@ if ($action eq "blob") { "</div>\n"; } else { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } print "<div class=\"title_text\">\n" . @@ -715,7 +842,7 @@ if ($action eq "blob") { sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; print "<tr><td>tree</td><td style=\"font-family: monospace;\">" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "</td></tr>\n"; + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "</td></tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "<tr><td>parent</td><td style=\"font-family: monospace;\">" . @@ -725,17 +852,32 @@ if ($action eq "blob") { "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; + my $empty = 0; + my $signed = 0; foreach my $line (@$comment) { - if ($line =~ m/(signed-off|acked)-by:/i) { + # print only one empty line + if ($line eq "") { + if ($empty || $signed) { + next; + } + $empty = 1; + } else { + $empty = 0; + } + if ($line =~ m/(signed.off|acked).by/i) { + $signed = 1; print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { + $signed = 0; print escapeHTML($line) . "<br/>\n"; } } print "</div>\n"; + print "<div class=\"list_head\">\n"; if ($#difftree > 10) { - print "<div class=\"list_head\">" . ($#difftree + 1) . " files changed:<br/></div>\n"; + print(($#difftree + 1) . " files changed:\n"); } + print "</div>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -754,21 +896,21 @@ if ($action eq "blob") { $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777); } print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . "<br/>\n" . "</div>\n"; } elsif ($op eq "-") { print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . "</div>\n"; } elsif ($op eq "*") { @@ -795,58 +937,82 @@ if ($action eq "blob") { } print "<div class=\"list\">\n"; if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, escapeHTML($file) . $mode_chnge) . "\n" . "</div>\n"; } else { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, escapeHTML($file) . $mode_chnge) . "\n" . "</div>\n"; } print "<div class=\"link\">\n" . "view "; if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " . + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "file") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . "</div>\n"; } } } git_footer_html(); -} elsif ($action eq "blobdiff") { +} + +sub git_blobdiff { mkdir($gittmp, 0700); git_header_html(); - print "<div class=\"page_nav\">\n"; - print "<br/><br/></div>\n"; - print "<div class=\"title\">$hash vs $hash_parent</div>\n"; + if (defined $hash_base && (my %co = git_read_commit($hash_base))) { + print "<div class=\"page_nav\"> view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + if (defined $file_name) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); + } + print "<br/><br/>\n" . + "</div>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + } else { + print "<div class=\"page_nav\">\n" . + "<br/><br/></div>\n" . + "<div class=\"title\">$hash vs $hash_parent</div>\n"; + } + if (defined $file_name) { + print "<div class=\"page_path\">\n" . + "/$file_name\n" . + "</div>\n"; + } print "<div class=\"page_body\">\n" . "<pre>\n"; print "<span class=\"diff_info\">blob:" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent"}, $hash_parent) . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) . " -> blob:" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash"}, $hash) . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) . "</span>\n"; - git_diff_html($hash_parent, $hash_parent, $hash, $hash); + git_diff_html($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); print "</pre>\n" . - "<br/></div>"; + "</div>"; git_footer_html(); -} elsif ($action eq "commitdiff") { +} + +sub git_commitdiff { mkdir($gittmp, 0700); - my %co = git_commit($hash); + my %co = git_read_commit($hash); if (!%co) { - die_error("", "Unknown commit object."); + die_error(undef, "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading diff-tree failed."); + close $fd || die_error(undef, "Reading diff-tree failed."); git_header_html(); print "<div class=\"page_nav\"> view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . @@ -864,12 +1030,12 @@ if ($action eq "blob") { if ($type eq "blob") { if ($op eq "+") { print "<span class=\"diff_info\">" . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . "(new)" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(new)" . "</span>\n"; git_diff_html(undef, "/dev/null", $id, "b/$file"); } elsif ($op eq "-") { print "<span class=\"diff_info\">" . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . "(deleted)" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(deleted)" . "</span>\n"; git_diff_html($id, "a/$file", undef, "/dev/null"); } elsif ($op eq "*") { @@ -881,9 +1047,9 @@ if ($action eq "blob") { my $to_mode = $2; if ($from_id ne $to_id) { print "<span class=\"diff_info\">" . - file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id"}, $from_id) . + file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . " -> " . - file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, $to_id); + file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id); print "</span>\n"; git_diff_html($from_id, "a/$file", $to_id, "b/$file"); } @@ -893,16 +1059,29 @@ if ($action eq "blob") { print "</pre><br/>\n"; print "</div>"; git_footer_html(); -} elsif ($action eq "history") { +} + +sub git_history { if (!defined $hash) { - $hash = git_head($project); + $hash = git_read_head($project); + } + my %co = git_read_commit($hash); + if (!%co) { + die_error(undef, "Unknown commit object."); } git_header_html(); - print "<div class=\"page_nav\">\n"; - print "<br/><br/></div>\n"; - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($file_name)) . "\n" . + print "<div class=\"page_nav\"> view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . + "<br/><br/>\n" . "</div>\n"; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + print "<div class=\"page_path\">\n" . + "/$file_name<br/>\n"; + print "</div>\n"; open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; my $commit; while (my $line = <$fd>) { @@ -916,7 +1095,7 @@ if ($action eq "blob") { if ($file ne $file_name || $type ne "blob") { next; } - my %co = git_commit($commit); + my %co = git_read_commit($commit); if (!%co) { next; } @@ -927,15 +1106,11 @@ if ($action eq "blob") { print "<div class=\"link\">\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$commit"}, "tree") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . "<br/><br/>\n" . "</div>\n"; - undef %co; undef $commit; } } close $fd; git_footer_html(); -} else { - undef $action; - die_error("", "Unknown action."); } From eb28240b64396e8dd35c79dd0158bcd80021fcc4 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:21:34 +0200 Subject: [PATCH 048/148] v121 --- gitweb.cgi | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 546b239720c..2be26bdbbe3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "118"; +my $version = "121"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -460,7 +460,7 @@ sub date_str { } # git-logo (cached in browser for one day) -sub git_logo() { +sub git_logo { print $cgi->header(-type => 'image/png', -expires => '+1d'); # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g' print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" . @@ -510,15 +510,14 @@ sub git_project_list { @list = sort @list; git_header_html(); - print "<div class=\"page_body\">\n"; + print "<div class=\"page_body\"><br/>\n"; print "<table cellspacing=\"0\">\n"; print "<tr>\n" . "<th>Project</th>\n" . "<th>Description</th>\n" . "<th>Owner</th>\n" . "<th>last change</th>\n" . - "</tr>\n" . - "<br/>"; + "</tr>\n"; foreach my $proj (@list) { my $head = git_read_head($proj); if (!defined $head) { @@ -614,7 +613,7 @@ sub git_blob { if (defined $file_name) { print "<div class=\"page_path\">/$file_name</div>\n"; } - print "<div class=\"page_body\"><pre>\n" . + print "<div class=\"page_body\"><pre>\n"; my $nr; while (my $line = <$fd>) { $nr++; @@ -710,7 +709,7 @@ sub git_rss { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); print "<item>\n" . - "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . + "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" . "\t<description>"; my $comment = $co{'comment'}; @@ -763,8 +762,9 @@ sub git_log { "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "<br/>\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . + "<br/>\n" . "</div>\n" . "<i>" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]</i><br/>\n" . "</div>\n" . @@ -1105,8 +1105,10 @@ sub git_history { "</div>\n"; print "<div class=\"link\">\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . "<br/><br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "file") . + "<br/><br/>\n" . "</div>\n"; undef $commit; } From 42f7eb94a0016125523cc24dbabfbf4ad5f60a59 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:21:46 +0200 Subject: [PATCH 049/148] v125 --- gitweb.cgi | 113 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 47 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 2be26bdbbe3..534edeaa8f2 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "121"; +my $version = "125"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -200,11 +200,13 @@ div.list_head { div.list a { text-decoration:none; color:#000000; } div.list a:hover { color:#880000; } div.link { - margin:0px 15px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px 1px; + margin:0px 15px; padding:4px 6px 6px; border:solid #d9d8d1; border-width:0px 1px 1px; font-family:sans-serif; font-size:10px; } td { padding:5px 15px 0px 0px; font-size:12px; } th { padding-right:10px; font-size:12px; text-align:left; } +td.link { font-family:sans-serif; font-size:10px; } +td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; } span.diff_info { color:#000099; background-color:#edece6; font-style:italic; } a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; @@ -257,6 +259,16 @@ sub die_error { exit; } +sub git_get_type { + my $hash = shift; + + open my $fd, "-|", "$gitbin/git-cat-file -t $hash" || return; + my $type = <$fd>; + close $fd; + chomp $type; + return $type; +} + sub git_read_head { my $path = shift; @@ -312,7 +324,11 @@ sub git_read_commit { $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; - $co{'title'} = $comment[0]; + $comment[0] =~ m/^(.{0,60}[^ ]*)/; + $co{'title'} = $1; + if ($comment[0] ne $co{'title'}) { + $co{'title'} .= " [...]"; + } close $fd || return; if (!defined $co{'tree'}) { return undef @@ -564,7 +580,7 @@ sub git_get_hash_by_path { while (my $part = shift @parts) { open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading tree failed."); + close $fd || return undef; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -594,9 +610,9 @@ sub git_blob { my $base = $file_name || ""; git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "<div class=\"page_nav\"> view\n" . + print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); @@ -643,9 +659,9 @@ sub git_tree { my $base = ""; if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; - print "<div class=\"page_nav\"> view\n" . + print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree") . "<br/><br/>\n" . "</div>\n"; @@ -664,7 +680,7 @@ sub git_tree { print "<div class=\"page_path\">/</div>\n"; } print "<div class=\"page_body\">\n"; - print "<pre>\n"; + print "<table cellspacing=\"0\">\n"; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -673,21 +689,23 @@ sub git_tree { my $t_hash = $3; my $t_name = $4; $file_key = ";f=$base$t_name"; + print "<tr>\n" . + "<td class=\"pre\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, $t_name); - if (S_ISLNK(oct $t_mode)) { - open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash"; - my $target = <$fd>; - close $fd; - print "\t -> $target"; - } - print "\n"; + print "<td class=\"pre\">$t_name</td>\n"; + print "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "file") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . + "</td>\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "\n"; + print "<td class=\"pre\">" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . + "</td>\n"; } + print "</tr>\n"; } - print "</pre>\n"; - print "</div>"; + print "</table>\n" . + "</div>"; git_footer_html(); } @@ -737,7 +755,6 @@ sub git_log { git_header_html(); print "<div class=\"page_nav\">\n"; - print "view "; print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last 10") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=1"}, "day") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . @@ -762,8 +779,8 @@ sub git_log { "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . "<br/>\n" . "</div>\n" . "<i>" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]</i><br/>\n" . @@ -772,7 +789,7 @@ sub git_log { my $comment = $co{'comment'}; my $empty = 0; foreach my $line (@$comment) { - if ($line =~ m/^(signed.off|acked).by/i) { + if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { next; } if ($line eq "") { @@ -813,10 +830,12 @@ sub git_commit { close $fd || die_error(undef, "Reading ls-tree failed."); } git_header_html(); - print "<div class=\"page_nav\"> view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit"); + if (defined $co{'parent'}) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); + } + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . @@ -838,8 +857,7 @@ sub git_commit { } print "</td></tr>\n"; print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; - print "<tr><td></td><td> " . $cd{'rfc2822'} . - sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; + print "<tr><td></td><td> " . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; print "<tr><td>tree</td><td style=\"font-family: monospace;\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "</td></tr>\n"; @@ -864,7 +882,7 @@ sub git_commit { } else { $empty = 0; } - if ($line =~ m/(signed.off|acked).by/i) { + if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { $signed = 1; print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { @@ -900,8 +918,7 @@ sub git_commit { escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . - "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "<br/>\n" . "</div>\n"; } elsif ($op eq "-") { print "<div class=\"list\">\n" . @@ -909,8 +926,7 @@ sub git_commit { escapeHTML($file) . " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" . "</div>"; print "<div class=\"link\">\n" . - "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . "</div>\n"; } elsif ($op eq "*") { @@ -945,12 +961,11 @@ sub git_commit { escapeHTML($file) . $mode_chnge) . "\n" . "</div>\n"; } - print "<div class=\"link\">\n" . - "view "; + print "<div class=\"link\">\n"; if ($to_id ne $from_id) { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "file") . " | " . + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . "</div>\n"; } @@ -963,9 +978,9 @@ sub git_blobdiff { mkdir($gittmp, 0700); git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "<div class=\"page_nav\"> view\n" . + print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); @@ -1009,9 +1024,9 @@ sub git_commitdiff { close $fd || die_error(undef, "Reading diff-tree failed."); git_header_html(); - print "<div class=\"page_nav\"> view\n" . + print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; print "<div>\n" . @@ -1070,9 +1085,9 @@ sub git_history { die_error(undef, "Unknown commit object."); } git_header_html(); - print "<div class=\"page_nav\"> view\n" . + print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "<br/><br/>\n" . "</div>\n"; @@ -1104,11 +1119,15 @@ sub git_history { "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"link\">\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "file") . - "<br/><br/>\n" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "blob"); + my $blob = git_get_hash_by_path($hash, $file_name); + my $blob_parent = git_get_hash_by_path($commit, $file_name); + if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=" . $file}, "diff"); + } + print "<br/>\n" . "</div>\n"; undef $commit; } From c07ad4b97128d26949ed34a2fd4a3a7039278fe8 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:22:44 +0200 Subject: [PATCH 050/148] v133 --- gitweb.cgi | 180 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 103 insertions(+), 77 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 534edeaa8f2..619db534a3c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "125"; +my $version = "133"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -29,6 +29,7 @@ my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; # target of the home link on top of all pages +#my $home_link = $my_uri; my $home_link = "/git"; # source of projects list @@ -163,51 +164,47 @@ sub git_header_html { <title>$title</title> $rss_link <style type="text/css"> -body { font-family: sans-serif; font-size: 12px; margin:0px; } +body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; } a { color:#0000cc; } -a:hover { color:#880000; } -a:visited { color:#880000; } -a:active { color:#880000; } -div.page_header { - margin:15px 15px 0px; height:25px; padding:8px; - font-size:18px; font-weight:bold; background-color:#d9d8d1; -} +a:hover, a:visited, a:active { color:#880000; } +div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } div.page_header a:visited { color:#0000cc; } div.page_header a:hover { color:#880000; } -div.page_nav { margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } +div.page_nav { padding:8px; } div.page_nav a:visited { color:#0000cc; } -div.page_path { font-weight:bold; margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px 1px} -div.page_footer { margin:0px 15px 15px; height:17px; padding:4px; padding-left:8px; background-color: #d9d8d1; } +div.page_path { font-weight:bold; padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} +div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; } div.page_footer_text { float:left; color:#555555; font-style:italic; } -div.page_body { margin:0px 15px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } +div.page_body { padding:8px; } div.title, a.title { - display:block; margin:0px 15px; padding:6px 8px; + display:block; padding:6px 8px; font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; } a.title:hover { background-color: #d9d8d1; } -div.title_text { margin:0px 15px; padding:6px 8px; border: solid #d9d8d1; border-width:0px 1px 1px; } -div.log_body { margin:0px 15px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } +div.title_text { padding:6px 8px; border: solid #d9d8d1; border-width:0px 0px 1px; } +div.log_body { padding:8px 8px 8px 150px; } span.log_age { position:relative; float:left; width:142px; font-style:italic; } -div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } -div.list { - display:block; margin:0px 15px; padding:4px 6px 2px; border:solid #d9d8d1; border-width:0px 1px; - font-weight:bold; +div.log_link { + font-size:10px; font-family:sans-serif; font-style:normal; + position:relative; float:left; width:142px; } +div.list { display:block; padding:4px 8px 2px; font-weight:bold; } div.list_head { - display:block; margin:0px 15px; padding:6px 6px 4px; border:solid #d9d8d1; border-width:0px 1px 1px; - font-style:italic; + display:block; padding:6px 6px 4px; border:solid #d9d8d1; + border-width:0px 0px 1px; font-style:italic; } div.list a { text-decoration:none; color:#000000; } div.list a:hover { color:#880000; } div.link { - margin:0px 15px; padding:4px 6px 6px; border:solid #d9d8d1; border-width:0px 1px 1px; + padding:4px 8px 6px; border:solid #d9d8d1; border-width:0px 0px 1px; font-family:sans-serif; font-size:10px; } td { padding:5px 15px 0px 0px; font-size:12px; } th { padding-right:10px; font-size:12px; text-align:left; } td.link { font-family:sans-serif; font-size:10px; } td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; } -span.diff_info { color:#000099; background-color:#edece6; font-style:italic; } +div.pre { font-family:monospace; font-size:12px; white-space:pre; } +div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; color:#ffffff; background-color:#ff6600; @@ -397,15 +394,20 @@ sub git_diff_html { open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp"; while (my $line = <$fd>) { - my $char = substr($line,0,1); - # skip errors - next if $char eq '\\'; - # color the diff - print '<span style="color: #008800;">' if $char eq '+'; - print '<span style="color: #CC0000;">' if $char eq '-'; - print '<span style="color: #990099;">' if $char eq '@'; - print escapeHTML($line); - print '</span>' if $char eq '+' or $char eq '-' or $char eq '@'; + chomp($line); + my $char = substr($line, 0, 1); + my $color = ""; + if ($char eq '+') { + $color = " style=\"color:#008800;\""; + } elsif ($char eq '-') { + $color = " style=\"color:#cc0000;\""; + } elsif ($char eq '@') { + $color = " style=\"color:#990099;\""; + } elsif ($char eq '\\') { + # skip errors + next; + } + print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n"; } close $fd; @@ -494,6 +496,19 @@ sub git_logo { "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82"; } +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 $project_list = shift; my @list; @@ -504,17 +519,30 @@ sub git_project_list { opendir my $dh, $dir || return undef; while (my $dir = readdir($dh)) { if (-e "$projectroot/$dir/HEAD") { - push @list, $dir; + my $pr = { + path => $dir, + }; + push @list, $pr } } closedir($dh); } elsif (-e $project_list) { # read from file + # 'git/git.git:Linus Torvalds' + # 'linux/hotplug/udev.git' open my $fd , $project_list || return undef; while (my $line = <$fd>) { chomp $line; - if (-e "$projectroot/$line/HEAD") { - push @list, $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; @@ -523,7 +551,7 @@ sub git_project_list { if (!@list) { die_error(undef, "No project found."); } - @list = sort @list; + @list = sort {$a->{'path'} cmp $b->{'path'}} @list; git_header_html(); print "<div class=\"page_body\"><br/>\n"; @@ -534,34 +562,32 @@ sub git_project_list { "<th>Owner</th>\n" . "<th>last change</th>\n" . "</tr>\n"; - foreach my $proj (@list) { - my $head = git_read_head($proj); + foreach my $pr (@list) { + my %proj = %$pr; + my $head = git_read_head($proj{'path'}); if (!defined $head) { next; } - $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj/objects"; + $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj{'path'}/objects"; my %co = git_read_commit($head); if (!%co) { next; } - my $descr = git_read_description($proj) || ""; - my $owner = ""; - my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat("$projectroot/$proj"); - my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid); - if (defined $gcos) { - $owner = $gcos; - $owner =~ s/[,;].*$//; + 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;a=log"}, escapeHTML($proj)) . "</td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=" . $proj{'path'} . ";a=log"}, escapeHTML($proj{'path'})) . "</td>\n" . "<td>$descr</td>\n" . - "<td><i>$owner</i></td>\n"; + "<td><i>$proj{'owner'}</i></td>\n"; if ($co{'age'} < 60*60*2) { - print "<td><span style =\"color: #009900;\"><b><i>" . $co{'age_string'} . "</i></b></span></td>\n"; + print "<td><span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span></td>\n"; } elsif ($co{'age'} < 60*60*24*2) { - print "<td><span style =\"color: #009900;\"><i>" . $co{'age_string'} . "</i></span></td>\n"; + print "<td><span style =\"color: #009900;\"><i>$co{'age_string'}</i></span></td>\n"; } else { - print "<td><i>" . $co{'age_string'} . "</i></td>\n"; + print "<td><i>$co{'age_string'}</i></td>\n"; } print "</tr>\n"; } @@ -619,8 +645,9 @@ sub git_blob { } print "<br/><br/>\n" . "</div>\n"; - print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n"; + print "<div>" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . + "</div>\n"; } else { print "<div class=\"page_nav\">\n" . "<br/><br/></div>\n" . @@ -629,14 +656,16 @@ sub git_blob { if (defined $file_name) { print "<div class=\"page_path\">/$file_name</div>\n"; } - print "<div class=\"page_body\"><pre>\n"; + print "<div class=\"page_body\">\n"; my $nr; while (my $line = <$fd>) { + chomp $line; $nr++; - printf "<span style =\"color: #999999;\">%4i\t</span>%s", $nr, escapeHTML($line);; + print "<div class=\"pre\">"; + printf "<span style=\"color:#999999;\">%4i</span>", $nr; + print " " .escapeHTML($line) . "</div>\n"; } close $fd || print "Reading blob failed.\n"; - print "</pre>\n"; print "</div>"; git_footer_html(); } @@ -694,7 +723,7 @@ sub git_tree { if ($t_type eq "blob") { print "<td class=\"pre\">$t_name</td>\n"; print "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "file") . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . "</td>\n"; } elsif ($t_type eq "tree") { @@ -916,9 +945,9 @@ sub git_commit { print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" . - "</div>"; + "</div>\n"; print "<div class=\"link\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" . "</div>\n"; } elsif ($op eq "-") { print "<div class=\"list\">\n" . @@ -927,7 +956,7 @@ sub git_commit { "</div>"; print "<div class=\"link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" . "</div>\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; @@ -966,7 +995,7 @@ sub git_commit { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; } print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "<br/>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" . "</div>\n"; } } @@ -1001,15 +1030,13 @@ sub git_blobdiff { "</div>\n"; } print "<div class=\"page_body\">\n" . - "<pre>\n"; - print "<span class=\"diff_info\">blob:" . + "<div class=\"diff_info\">blob:" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) . " -> blob:" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) . - "</span>\n"; + "</div>\n"; git_diff_html($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); - print "</pre>\n" . - "</div>"; + print "</div>"; git_footer_html(); } @@ -1032,8 +1059,7 @@ sub git_commitdiff { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"page_body\">\n" . - "<pre>\n"; + print "<div class=\"page_body\">\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; @@ -1044,14 +1070,14 @@ sub git_commitdiff { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - print "<span class=\"diff_info\">" . file_type($mode) . ":" . + print "<div class=\"diff_info\">" . file_type($mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(new)" . - "</span>\n"; + "</div>\n"; git_diff_html(undef, "/dev/null", $id, "b/$file"); } elsif ($op eq "-") { - print "<span class=\"diff_info\">" . file_type($mode) . ":" . + print "<div class=\"diff_info\">" . file_type($mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(deleted)" . - "</span>\n"; + "</div>\n"; git_diff_html($id, "a/$file", undef, "/dev/null"); } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; @@ -1061,18 +1087,18 @@ sub git_commitdiff { my $from_mode = $1; my $to_mode = $2; if ($from_id ne $to_id) { - print "<span class=\"diff_info\">" . + print "<div class=\"diff_info\">" . file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . " -> " . file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id); - print "</span>\n"; + print "</div>\n"; git_diff_html($from_id, "a/$file", $to_id, "b/$file"); } } } } - print "</pre><br/>\n"; - print "</div>"; + print "<br/>\n" . + "</div>"; git_footer_html(); } From 8ab1da2c4ffeaabacd1644fab820bf99828652f3 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:22:53 +0200 Subject: [PATCH 051/148] v136 --- gitweb.cgi | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 619db534a3c..d5e8502a58d 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "133"; +my $version = "136"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -32,6 +32,9 @@ my $gittmp = "/tmp/gitweb"; #my $home_link = $my_uri; my $home_link = "/git"; +# html text to include at home page +my $home_text = "indextext.html"; + # source of projects list #my $projects_list = $projectroot; my $projects_list = "index/index.txt"; @@ -205,6 +208,7 @@ td.link { font-family:sans-serif; font-size:10px; } td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; } div.pre { font-family:monospace; font-size:12px; white-space:pre; } div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } +div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; color:#ffffff; background-color:#ff6600; @@ -217,7 +221,7 @@ a.rss_logo:hover { background-color:#ee5500; } <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"http://kernel.org/pub/software/scm/cogito\">" . + "<a href=\"http://kernel.org/pub/software/scm/git/docs/\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => $home_link}, "projects") . " / "; if (defined $project) { @@ -554,9 +558,16 @@ sub git_project_list { @list = sort {$a->{'path'} cmp $b->{'path'}} @list; git_header_html(); - print "<div class=\"page_body\"><br/>\n"; - print "<table cellspacing=\"0\">\n"; - print "<tr>\n" . + 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" . From ede5e1009e9a5f80e84a7f360a734f1af9f4c4e7 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:23:12 +0200 Subject: [PATCH 052/148] v142 --- gitweb.cgi | 285 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 233 insertions(+), 52 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index d5e8502a58d..34dc9bc80d6 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "136"; +my $version = "142"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -29,8 +29,7 @@ my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; # target of the home link on top of all pages -#my $home_link = $my_uri; -my $home_link = "/git"; +my $home_link = $my_uri; # html text to include at home page my $home_text = "indextext.html"; @@ -51,7 +50,7 @@ if (defined $action) { exit; } } else { - $action = "log"; + $action = "summary"; } my $project = $cgi->param('p'); @@ -73,9 +72,10 @@ if (defined $project) { die_error(undef, "No such project."); } $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; + $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; } else { - git_project_list($projects_list); + git_project_list(); exit; } @@ -117,7 +117,13 @@ if (defined $time_back) { } } -if ($action eq "blob") { +if ($action eq "summary") { + git_summary(); + exit; +} elsif ($action eq "tags") { + git_tags(); + exit; +} elsif ($action eq "blob") { git_blob(); exit; } elsif ($action eq "tree") { @@ -191,14 +197,14 @@ div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } -div.list { display:block; padding:4px 8px 2px; font-weight:bold; } +div.list { display:block; padding:4px 8px 2px; } div.list_head { display:block; padding:6px 6px 4px; border:solid #d9d8d1; border-width:0px 0px 1px; font-style:italic; } div.list a { text-decoration:none; color:#000000; } div.list a:hover { color:#880000; } -div.link { +div.list_link { padding:4px 8px 6px; border:solid #d9d8d1; border-width:0px 0px 1px; font-family:sans-serif; font-size:10px; } @@ -225,7 +231,7 @@ EOF "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; print $cgi->a({-href => $home_link}, "projects") . " / "; if (defined $project) { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, escapeHTML($project)); + print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, escapeHTML($project)); if (defined $action) { print " / $action"; } @@ -270,17 +276,15 @@ sub git_get_type { return $type; } -sub git_read_head { +sub git_read_hash { my $path = shift; - open my $fd, "$projectroot/$path/HEAD" || return undef; + open my $fd, "$projectroot/$path" || return undef; my $head = <$fd>; close $fd; chomp $head; if ($head =~ m/^[0-9a-fA-F]{40}$/) { return $head; - } else { - return undef; } } @@ -294,6 +298,28 @@ sub git_read_description { return $descr; } +sub git_read_tag { + my $tag_id = shift; + my %tag; + + open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" || return; + while (my $line = <$fd>) { + chomp $line; + if ($line =~ m/^object ([0-9a-fA-F]{40})$/) { + $tag{'object'} = $1; + } elsif ($line =~ m/^type (.*)$/) { + $tag{'type'} = $1; + } elsif ($line =~ m/^tag (.*)$/) { + $tag{'name'} = $1; + } + } + close $fd || return; + if (!defined $tag{'name'}) { + return + }; + return %tag +} + sub git_read_commit { my $commit = shift; my %co; @@ -321,6 +347,10 @@ sub git_read_commit { $co{'committer_name'} =~ s/ <.*//; } } + if (!defined $co{'tree'}) { + close $fd; + return undef + }; $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; @@ -328,20 +358,17 @@ sub git_read_commit { $comment[0] =~ m/^(.{0,60}[^ ]*)/; $co{'title'} = $1; if ($comment[0] ne $co{'title'}) { - $co{'title'} .= " [...]"; + $co{'title'} .= " ..."; } close $fd || return; - if (!defined $co{'tree'}) { - return undef - }; my $age = time - $co{'committer_epoch'}; $co{'age'} = $age; if ($age > 60*60*24*365*2) { $co{'age_string'} = (int $age/60/60/24/365); $co{'age_string'} .= " years ago"; - } elsif ($age > 60*60*24*365/12*2) { - $co{'age_string'} = int $age/60/60/24/365/12; + } elsif ($age > 60*60*24*(365/12)*2) { + $co{'age_string'} = int $age/60/60/24/(365/12); $co{'age_string'} .= " months ago"; } elsif ($age > 60*60*24*7*2) { $co{'age_string'} = int $age/60/60/24/7; @@ -514,12 +541,11 @@ sub get_file_owner { } sub git_project_list { - my $project_list = shift; my @list; - if (-d $project_list) { + if (-d $projects_list) { # search in directory - my $dir = $project_list; + my $dir = $projects_list; opendir my $dh, $dir || return undef; while (my $dir = readdir($dh)) { if (-e "$projectroot/$dir/HEAD") { @@ -530,11 +556,11 @@ sub git_project_list { } } closedir($dh); - } elsif (-e $project_list) { - # read from file + } elsif (-f $projects_list) { + # read from file: # 'git/git.git:Linus Torvalds' # 'linux/hotplug/udev.git' - open my $fd , $project_list || return undef; + open my $fd , $projects_list || return undef; while (my $line = <$fd>) { chomp $line; my ($path, $owner) = split ':', $line; @@ -560,7 +586,7 @@ sub git_project_list { git_header_html(); if (-f $home_text) { print "<div class=\"index_include\">\n"; - open my $fd, $home_text; + open (my $fd, $home_text); print <$fd>; close $fd; print "</div>\n"; @@ -572,13 +598,15 @@ sub git_project_list { "<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_head($proj{'path'}); + 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) { @@ -590,17 +618,23 @@ sub git_project_list { $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; } print "<tr>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=" . $proj{'path'} . ";a=log"}, escapeHTML($proj{'path'})) . "</td>\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) { - print "<td><span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span></td>\n"; + $colored_age = "<span style =\"color: #009900;\"><b><i>$co{'age_string'}</i></b></span>"; } elsif ($co{'age'} < 60*60*24*2) { - print "<td><span style =\"color: #009900;\"><i>$co{'age_string'}</i></span></td>\n"; + $colored_age = "<span style =\"color: #009900;\"><i>$co{'age_string'}</i></span>"; } else { - print "<td><i>$co{'age_string'}</i></td>\n"; + $colored_age = "<i>$co{'age_string'}</i>"; } - print "</tr>\n"; + 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"; } print "</table>\n" . "<br/>\n" . @@ -608,6 +642,149 @@ sub git_project_list { git_footer_html(); } +sub git_read_tags { + my @taglist; + + opendir my $dh, "$projectroot/$project/refs/tags"; + my @tags = grep !m/^\./, readdir $dh; + closedir($dh); + foreach my $tag_file (@tags) { + my $tag_id = git_read_hash("$project/refs/tags/$tag_file"); + my $type = git_get_type($tag_id) || next; + my %tag_item; + my %co; + if ($type eq "tag") { + my %tag = git_read_tag($tag_id); + if ($tag{'type'} eq "commit") { + %co = git_read_commit($tag{'object'}); + } + $tag_item{'type'} = $tag{'type'}; + $tag_item{'name'} = $tag{'name'}; + $tag_item{'id'} = $tag{'object'}; + } elsif ($type eq "commit"){ + %co = git_read_commit($tag_id); + $tag_item{'type'} = "commit"; + $tag_item{'name'} = $tag_file; + $tag_item{'id'} = $tag_id; + } + $tag_item{'epoch'} = $co{'author_epoch'} || 0; + $tag_item{'age'} = $co{'age_string'} || "unknown"; + + push @taglist, \%tag_item; + } + # sort tags by age + @taglist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @taglist; + return \@taglist; +} + +sub git_summary { + my $descr = git_read_description($project) || "none"; + my $head = git_read_hash("$project/HEAD"); + $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; + $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; + my %co = git_read_commit($head); + my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); + + my $owner; + if (-f $projects_list) { + open (my $fd , $projects_list); + while (my $line = <$fd>) { + chomp $line; + my ($pr, $ow) = split ':', $line; + if ($pr eq $project) { + $owner = $ow; + last; + } + } + close $fd; + } + if (!defined $owner) { + $owner = get_file_owner("$projectroot/$project"); + } + + git_header_html(); + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "latest tree") . + "<br/><br/>\n" . + "</div>\n"; + print "<div class=\"title\">project</div>\n"; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n" . + "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" . + "<tr><td>owner</td><td>$owner</td></tr>\n" . + "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" . + "</table>\n" . + "</div><br/>\n"; + open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "recent commits") . + "</div>\n"; + my $i = 10; + foreach my $commit (@revlist) { + my %co = git_read_commit($commit); + my %ad = date_str($co{'author_epoch'}); + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, + "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + if (--$i == 0) { + print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</div>\n"; + last; + } + } + print "<br/>\n"; + + my $taglist = git_read_tags(); + if (defined @$taglist) { + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "recent tags") . + "</div>\n"; + my $i = 10; + foreach my $entry (@$taglist) { + my %tag = %$entry; + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, + "<span class=\"log_age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . + "</div>\n"; + if (--$i == 0) { + print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</div>\n"; + last; + } + } + } + print "<br/>\n"; + git_footer_html(); +} + +sub git_tags { + my $head = git_read_hash("$project/HEAD"); + git_header_html(); + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . + "<br/><br/>\n" . + "</div>\n"; + my $taglist = git_read_tags(); + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") . + "</div>\n"; + if (defined @$taglist) { + foreach my $entry (@$taglist) { + my %tag = %$entry; + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, + "<span class=\"log_age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . + "</div>\n"; + } + } + print "<br/>\n"; + git_footer_html(); +} + sub git_get_hash_by_path { my $base = shift; my $path = shift; @@ -640,7 +817,7 @@ sub git_get_hash_by_path { sub git_blob { if (!defined $hash && defined $file_name) { - my $base = $hash_base || git_read_head($project); + my $base = $hash_base || git_read_hash("$project/HEAD"); $hash = git_get_hash_by_path($base, $file_name, "blob"); } open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error(undef, "Open failed."); @@ -683,9 +860,9 @@ sub git_blob { sub git_tree { if (!defined $hash) { - $hash = git_read_head($project); + $hash = git_read_hash("$project/HEAD"); if (defined $file_name) { - my $base = $hash_base || git_read_head($project); + my $base = $hash_base || git_read_hash("$project/HEAD"); $hash = git_get_hash_by_path($base, $file_name, "tree"); } } @@ -700,9 +877,10 @@ sub git_tree { if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree") . + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . @@ -750,7 +928,7 @@ sub git_tree { } sub git_rss { - open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_head($project) || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading rev-list failed."); @@ -781,7 +959,7 @@ sub git_rss { } sub git_log { - my $head = git_read_head($project); + my $head = git_read_hash("$project/HEAD"); my $limit_option = ""; if (!defined $time_back) { $limit_option = "--max-count=10"; @@ -801,7 +979,7 @@ sub git_log { $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; - print "<br/><br/>\n" . + print "<br/>\n" . "</div>\n"; if (!@revlist) { @@ -871,7 +1049,8 @@ sub git_commit { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit"); + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit"); if (defined $co{'parent'}) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); } @@ -957,7 +1136,7 @@ sub git_commit { $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" . "</div>\n"; - print "<div class=\"link\">\n" . + print "<div class=\"list_link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" . "</div>\n"; } elsif ($op eq "-") { @@ -965,7 +1144,7 @@ sub git_commit { $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" . "</div>"; - print "<div class=\"link\">\n" . + print "<div class=\"list_link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" . "</div>\n"; @@ -978,7 +1157,7 @@ sub git_commit { my $to_mode = $2; my $mode_chnge = ""; if ($from_mode != $to_mode) { - $mode_chnge = " <span style=\"color: #888888;\">[changed"; + $mode_chnge = " <span style=\"color: #777777;\">[changed"; if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) { $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode); } @@ -1001,7 +1180,7 @@ sub git_commit { escapeHTML($file) . $mode_chnge) . "\n" . "</div>\n"; } - print "<div class=\"link\">\n"; + print "<div class=\"list_link\">\n"; if ($to_id ne $from_id) { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; } @@ -1019,7 +1198,8 @@ sub git_blobdiff { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); if (defined $file_name) { @@ -1063,9 +1243,10 @@ sub git_commitdiff { git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "<br/><br/></div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . @@ -1115,7 +1296,7 @@ sub git_commitdiff { sub git_history { if (!defined $hash) { - $hash = git_read_head($project); + $hash = git_read_hash("$project/HEAD"); } my %co = git_read_commit($hash); if (!%co) { @@ -1155,7 +1336,7 @@ sub git_history { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"link\">\n" . + print "<div class=\"list_link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "blob"); From 9ea82aa8e02c8d24316e77244c9859b011eec565 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:23:24 +0200 Subject: [PATCH 053/148] v143 --- gitweb.cgi | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 34dc9bc80d6..b6fa5ec6711 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "142"; +my $version = "143"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -634,7 +634,8 @@ sub git_project_list { $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"; + "</td>\n" . + "</tr>\n"; } print "</table>\n" . "<br/>\n" . @@ -715,7 +716,7 @@ sub git_summary { "<tr><td>owner</td><td>$owner</td></tr>\n" . "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" . "</table>\n" . - "</div><br/>\n"; + "<br/></div>\n"; open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -735,7 +736,7 @@ sub git_summary { last; } } - print "<br/>\n"; + print "<div class=\"list\"><br/></div>\n"; my $taglist = git_read_tags(); if (defined @$taglist) { @@ -754,8 +755,8 @@ sub git_summary { last; } } + print "<div class=\"list\"><br/></div>\n"; } - print "<br/>\n"; git_footer_html(); } @@ -781,7 +782,7 @@ sub git_tags { "</div>\n"; } } - print "<br/>\n"; + print "<div class=\"list\"><br/></div>\n"; git_footer_html(); } From e925f38c2d2d38298088903419dd9dbfde2268b0 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:23:35 +0200 Subject: [PATCH 054/148] v145 --- gitweb.cgi | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index b6fa5ec6711..a2b2e27fed2 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "143"; +my $version = "145"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -618,7 +618,7 @@ sub git_project_list { $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>" . $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; @@ -706,7 +706,7 @@ sub git_summary { git_header_html(); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "latest tree") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div class=\"title\">project</div>\n"; @@ -729,7 +729,7 @@ sub git_summary { my %ad = date_str($co{'author_epoch'}); print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . + "<span class=\"log_age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; if (--$i == 0) { print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</div>\n"; @@ -828,7 +828,7 @@ sub git_blob { print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); } @@ -867,6 +867,9 @@ sub git_tree { $hash = git_get_hash_by_path($base, $file_name, "tree"); } } + if (!defined $hash_base) { + $hash_base = git_read_hash("$project/HEAD"); + } open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading tree failed."); @@ -938,7 +941,7 @@ sub git_rss { "<rss version=\"0.91\">\n"; print "<channel>\n"; print "<title>$project</title>\n". - "<link> " . $my_url . "/$project/log</link>\n". + "<link> $my_url/$project/log</link>\n". "<description>$project log</description>\n". "<language>en</language>\n"; @@ -947,7 +950,7 @@ sub git_rss { my %ad = date_str($co{'author_epoch'}); print "<item>\n" . "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . - "\t<link> " . $my_url . "?p=$project;a=commit;h=$commit</link>\n" . + "\t<link> $my_url?p=$project;a=commit;h=$commit</link>\n" . "\t<description>"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -985,7 +988,7 @@ sub git_log { if (!@revlist) { my %co = git_read_commit($head); - print "<div class=\"page_body\"> Last change " . $co{'age_string'} . ".<br/><br/></div>\n"; + print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; } foreach my $commit (@revlist) { @@ -994,7 +997,7 @@ sub git_log { my %ad = date_str($co{'author_epoch'}); print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, - "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . + "<span class=\"log_age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . @@ -1002,13 +1005,13 @@ sub git_log { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . "<br/>\n" . "</div>\n" . - "<i>" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]</i><br/>\n" . + "<i>" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" . "</div>\n" . "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; my $empty = 0; foreach my $line (@$comment) { - if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { + if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { next; } if ($line eq "") { @@ -1039,7 +1042,7 @@ sub git_commit { my @difftree; if (defined $co{'parent'}) { - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading diff-tree failed."); } else { @@ -1055,7 +1058,7 @@ sub git_commit { if (defined $co{'parent'}) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); } - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" . "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . @@ -1063,13 +1066,13 @@ sub git_commit { "</div>\n"; } else { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n"; print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n". - "<tr><td></td><td> " . $ad{'rfc2822'}; + "<tr><td></td><td> $ad{'rfc2822'}"; if ($ad{'hour_local'} < 6) { printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } else { @@ -1077,10 +1080,10 @@ sub git_commit { } print "</td></tr>\n"; print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; - print "<tr><td></td><td> " . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; + print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; print "<tr><td>tree</td><td style=\"font-family: monospace;\">" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "</td></tr>\n"; + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, $co{'tree'}) . "</td></tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "<tr><td>parent</td><td style=\"font-family: monospace;\">" . @@ -1102,7 +1105,7 @@ sub git_commit { } else { $empty = 0; } - if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { + if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { $signed = 1; print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { @@ -1135,7 +1138,7 @@ sub git_commit { } print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, - escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . $mode_chng . "]</span>") . "\n" . + escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . "$mode_chng]</span>") . "\n" . "</div>\n"; print "<div class=\"list_link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" . @@ -1202,7 +1205,7 @@ sub git_blobdiff { $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); } @@ -1238,7 +1241,7 @@ sub git_commitdiff { if (!%co) { die_error(undef, "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading diff-tree failed."); @@ -1307,7 +1310,7 @@ sub git_history { print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . @@ -1335,16 +1338,16 @@ sub git_history { } print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "<span class=\"log_age\">" . $co{'age_string'} . "</span>" . escapeHTML($co{'title'})) . "\n" . + "<span class=\"log_age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"list_link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "blob"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=" . $file}, "diff"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff"); } print "<br/>\n" . "</div>\n"; From 7403d50bd2c6a9e72dd5e3db61d68befa8dc34fb Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:23:49 +0200 Subject: [PATCH 055/148] v148 --- gitweb.cgi | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index a2b2e27fed2..e738ea2ba44 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -10,11 +10,12 @@ use strict; use warnings; use CGI qw(:standard :escapeHTML); +use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "145"; +my $version = "148"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -36,7 +37,7 @@ my $home_text = "indextext.html"; # source of projects list #my $projects_list = $projectroot; -my $projects_list = "index/index.txt"; +my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); @@ -563,7 +564,9 @@ sub git_project_list { open my $fd , $projects_list || return undef; while (my $line = <$fd>) { chomp $line; - my ($path, $owner) = split ':', $line; + my ($path, $owner) = split ' ', $line; + $path = unescape($path); + $owner = unescape($owner); if (!defined $path) { next; } @@ -691,7 +694,9 @@ sub git_summary { open (my $fd , $projects_list); while (my $line = <$fd>) { chomp $line; - my ($pr, $ow) = split ':', $line; + my ($pr, $ow) = split ' ', $line; + $pr = unescape($pr); + $ow = unescape($ow); if ($pr eq $project) { $owner = $ow; last; From 440c60068b85db4c637f9cdb088ca267cd367fa2 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:24:01 +0200 Subject: [PATCH 056/148] v149 --- gitweb.cgi | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index e738ea2ba44..fccb96ea486 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "148"; +my $version = "149"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -193,7 +193,7 @@ div.title, a.title { a.title:hover { background-color: #d9d8d1; } div.title_text { padding:6px 8px; border: solid #d9d8d1; border-width:0px 0px 1px; } div.log_body { padding:8px 8px 8px 150px; } -span.log_age { position:relative; float:left; width:142px; font-style:italic; } +span.age { position:relative; float:left; width:142px; font-style:italic; } div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; @@ -729,19 +729,25 @@ sub git_summary { $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "recent commits") . "</div>\n"; my $i = 10; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; foreach my $commit (@revlist) { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "<span class=\"log_age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . - "</div>\n"; - if (--$i == 0) { - print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</div>\n"; + print "<tr>\n"; + if (--$i > 0) { + print "<td>$co{'age_string'}</td>\n" . + "<td>$co{'author_name'}</td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . "</td>\n" . + "</tr>"; + } else { + print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</td>\n" . + "</tr>"; last; } } - print "<div class=\"list\"><br/></div>\n"; + print "</table\n>" . + "</div>\n"; my $taglist = git_read_tags(); if (defined @$taglist) { @@ -749,18 +755,23 @@ sub git_summary { $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "recent tags") . "</div>\n"; my $i = 10; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; foreach my $entry (@$taglist) { my %tag = %$entry; - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, - "<span class=\"log_age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . - "</div>\n"; - if (--$i == 0) { - print "<div class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</div>\n"; + print "<tr>\n"; + if (--$i > 0) { + print "<td>$tag{'age'}</td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" . + "</tr>"; + } else { + print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" . + "</tr>"; last; } } - print "<div class=\"list\"><br/></div>\n"; + print "</table\n>" . + "</div>\n"; } git_footer_html(); } @@ -783,7 +794,7 @@ sub git_tags { my %tag = %$entry; print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, - "<span class=\"log_age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . + "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . "</div>\n"; } } @@ -1002,7 +1013,7 @@ sub git_log { my %ad = date_str($co{'author_epoch'}); print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, - "<span class=\"log_age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . + "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . @@ -1343,7 +1354,7 @@ sub git_history { } print "<div class=\"list\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "<span class=\"log_age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . + "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"list_link\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . From 0db37973ed6ce0ee96bf2a333f7c5f141e692fb6 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:24:35 +0200 Subject: [PATCH 057/148] v150 --- gitweb.cgi | 102 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 13 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fccb96ea486..608ab123290 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "149"; +my $version = "150"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -121,6 +121,9 @@ if (defined $time_back) { if ($action eq "summary") { git_summary(); exit; +} elsif ($action eq "branches") { + git_branches(); + exit; } elsif ($action eq "tags") { git_tags(); exit; @@ -382,10 +385,10 @@ sub git_read_commit { $co{'age_string'} .= " hours ago"; } elsif ($age > 60*2) { $co{'age_string'} = int $age/60; - $co{'age_string'} .= " minutes ago"; + $co{'age_string'} .= " min ago"; } elsif ($age > 2) { $co{'age_string'} = int $age; - $co{'age_string'} .= " seconds ago"; + $co{'age_string'} .= " sec ago"; } else { $co{'age_string'} .= " right now"; } @@ -646,14 +649,15 @@ sub git_project_list { git_footer_html(); } -sub git_read_tags { +sub git_read_refs { + my $ref_dir = shift; my @taglist; - opendir my $dh, "$projectroot/$project/refs/tags"; + opendir my $dh, "$projectroot/$project/$ref_dir"; my @tags = grep !m/^\./, readdir $dh; closedir($dh); foreach my $tag_file (@tags) { - my $tag_id = git_read_hash("$project/refs/tags/$tag_file"); + my $tag_id = git_read_hash("$project/$ref_dir/$tag_file"); my $type = git_get_type($tag_id) || next; my %tag_item; my %co; @@ -669,6 +673,7 @@ sub git_read_tags { %co = git_read_commit($tag_id); $tag_item{'type'} = "commit"; $tag_item{'name'} = $tag_file; + $tag_item{'title'} = $co{'title'}; $tag_item{'id'} = $tag_id; } $tag_item{'epoch'} = $co{'author_epoch'} || 0; @@ -726,7 +731,7 @@ sub git_summary { my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "recent commits") . + $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "commits") . "</div>\n"; my $i = 10; print "<div class=\"page_body\">\n" . @@ -749,10 +754,10 @@ sub git_summary { print "</table\n>" . "</div>\n"; - my $taglist = git_read_tags(); + my $taglist = git_read_refs("refs/tags"); if (defined @$taglist) { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "recent tags") . + $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") . "</div>\n"; my $i = 10; print "<div class=\"page_body\">\n" . @@ -773,6 +778,31 @@ sub git_summary { print "</table\n>" . "</div>\n"; } + + my $branchlist = git_read_refs("refs/heads"); + if (defined @$branchlist) { + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") . + "</div>\n"; + my $i = 10; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; + foreach my $entry (@$branchlist) { + my %tag = %$entry; + print "<tr>\n"; + if (--$i > 0) { + print "<td>$tag{'age'}</td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" . + "</tr>"; + } else { + print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" . + "</tr>"; + last; + } + } + print "</table\n>" . + "</div>\n"; + } git_footer_html(); } @@ -785,7 +815,7 @@ sub git_tags { " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . "<br/><br/>\n" . "</div>\n"; - my $taglist = git_read_tags(); + my $taglist = git_read_refs("refs/tags"); print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") . "</div>\n"; @@ -802,6 +832,32 @@ sub git_tags { git_footer_html(); } +sub git_branches { + my $head = git_read_hash("$project/HEAD"); + git_header_html(); + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . + "<br/><br/>\n" . + "</div>\n"; + my $taglist = git_read_refs("refs/heads"); + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") . + "</div>\n"; + if (defined @$taglist) { + foreach my $entry (@$taglist) { + my %tag = %$entry; + print "<div class=\"list\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, + "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . + "</div>\n"; + } + } + print "<div class=\"list\"><br/></div>\n"; + git_footer_html(); +} + sub git_get_hash_by_path { my $base = shift; my $path = shift; @@ -979,7 +1035,9 @@ sub git_rss { } sub git_log { - my $head = git_read_hash("$project/HEAD"); + if (!defined $hash) { + $hash = git_read_hash("$project/HEAD"); + } my $limit_option = ""; if (!defined $time_back) { $limit_option = "--max-count=10"; @@ -987,7 +1045,7 @@ sub git_log { my $date = time - $time_back*24*60*60; $limit_option = "--max-age=$date"; } - open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading rev-list failed."); @@ -1003,7 +1061,7 @@ sub git_log { "</div>\n"; if (!@revlist) { - my %co = git_read_commit($head); + my %co = git_read_commit($hash); print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; } @@ -1272,6 +1330,24 @@ sub git_commitdiff { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_body\">\n"; + my $comment = $co{'comment'}; + my $empty = 0; + my $signed = 0; + foreach my $line (@$comment) { + if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { + next; + } + if ($line eq "") { + if ($empty) { + next; + } + $empty = 1; + } else { + $empty = 0; + } + print escapeHTML($line) . "<br/>\n"; + } + print "<br/>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; From fa378499c7f935ba4bbeffe230cb4188e7317b30 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:24:43 +0200 Subject: [PATCH 058/148] v152 --- gitweb.cgi | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 608ab123290..6ab52218225 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "150"; +my $version = "152"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -651,39 +651,39 @@ sub git_project_list { sub git_read_refs { my $ref_dir = shift; - my @taglist; + my @reflist; opendir my $dh, "$projectroot/$project/$ref_dir"; - my @tags = grep !m/^\./, readdir $dh; + my @refs = grep !m/^\./, readdir $dh; closedir($dh); - foreach my $tag_file (@tags) { - my $tag_id = git_read_hash("$project/$ref_dir/$tag_file"); - my $type = git_get_type($tag_id) || next; - my %tag_item; + foreach my $ref_file (@refs) { + my $ref_id = git_read_hash("$project/$ref_dir/$ref_file"); + my $type = git_get_type($ref_id) || next; + my %ref_item; my %co; if ($type eq "tag") { - my %tag = git_read_tag($tag_id); + my %tag = git_read_tag($ref_id); if ($tag{'type'} eq "commit") { %co = git_read_commit($tag{'object'}); } - $tag_item{'type'} = $tag{'type'}; - $tag_item{'name'} = $tag{'name'}; - $tag_item{'id'} = $tag{'object'}; + $ref_item{'type'} = $tag{'type'}; + $ref_item{'name'} = $tag{'name'}; + $ref_item{'id'} = $tag{'object'}; } elsif ($type eq "commit"){ - %co = git_read_commit($tag_id); - $tag_item{'type'} = "commit"; - $tag_item{'name'} = $tag_file; - $tag_item{'title'} = $co{'title'}; - $tag_item{'id'} = $tag_id; + %co = git_read_commit($ref_id); + $ref_item{'type'} = "commit"; + $ref_item{'name'} = $ref_file; + $ref_item{'title'} = $co{'title'}; + $ref_item{'id'} = $ref_id; } - $tag_item{'epoch'} = $co{'author_epoch'} || 0; - $tag_item{'age'} = $co{'age_string'} || "unknown"; + $ref_item{'epoch'} = $co{'committer_epoch'} || 0; + $ref_item{'age'} = $co{'age_string'} || "unknown"; - push @taglist, \%tag_item; + push @reflist, \%ref_item; } # sort tags by age - @taglist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @taglist; - return \@taglist; + @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist; + return \@reflist; } sub git_summary { @@ -1333,7 +1333,12 @@ sub git_commitdiff { my $comment = $co{'comment'}; my $empty = 0; my $signed = 0; - foreach my $line (@$comment) { + my @log = @$comment; + shift @log; + #while ($log[0] eq "") { + # shift @log; + #} + foreach my $line (@log) { if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { next; } From a4d26ef062e68d276f94fa8be9130375a3b9ebe8 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:24:51 +0200 Subject: [PATCH 059/148] v154 --- gitweb.cgi | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 6ab52218225..a7a7edf720e 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "152"; +my $version = "154"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -359,7 +359,7 @@ sub git_read_commit { $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; - $comment[0] =~ m/^(.{0,60}[^ ]*)/; + $comment[0] =~ m/^(.{0,60}[^ \/]*)/; $co{'title'} = $1; if ($comment[0] ne $co{'title'}) { $co{'title'} .= " ..."; @@ -744,6 +744,10 @@ sub git_summary { print "<td>$co{'age_string'}</td>\n" . "<td>$co{'author_name'}</td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . + "</td>\n" . "</tr>"; } else { print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</td>\n" . @@ -1334,10 +1338,11 @@ sub git_commitdiff { my $empty = 0; my $signed = 0; my @log = @$comment; + # remove first and empty lines after that shift @log; - #while ($log[0] eq "") { - # shift @log; - #} + while (defined $log[0] && $log[0] eq "") { + shift @log; + } foreach my $line (@log) { if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { next; From 10dba28d74a22f304e3c64b2e190a35ea3306523 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:25:27 +0200 Subject: [PATCH 060/148] v157 --- gitweb.cgi | 232 ++++++++++++++++++++++++++++------------------------- 1 file changed, 122 insertions(+), 110 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index a7a7edf720e..09ea9998311 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "154"; +my $version = "157"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -201,17 +201,12 @@ div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } -div.list { display:block; padding:4px 8px 2px; } div.list_head { display:block; padding:6px 6px 4px; border:solid #d9d8d1; - border-width:0px 0px 1px; font-style:italic; -} -div.list a { text-decoration:none; color:#000000; } -div.list a:hover { color:#880000; } -div.list_link { - padding:4px 8px 6px; border:solid #d9d8d1; border-width:0px 0px 1px; - font-family:sans-serif; font-size:10px; + border-width:1px 0px 0px; font-style:italic; } +a.list { text-decoration:none; color:#000000; } +a.list:hover { color:#880000; } td { padding:5px 15px 0px 0px; font-size:12px; } th { padding-right:10px; font-size:12px; text-align:left; } td.link { font-family:sans-serif; font-size:10px; } @@ -359,7 +354,7 @@ sub git_read_commit { $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; - $comment[0] =~ m/^(.{0,60}[^ \/]*)/; + $comment[0] =~ m/^(.{0,50}[^ \/\-_:\.]{0,10})/; $co{'title'} = $1; if ($comment[0] ne $co{'title'}) { $co{'title'} .= " ..."; @@ -624,7 +619,7 @@ sub git_project_list { $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>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . "<td>$descr</td>\n" . "<td><i>$proj{'owner'}</i></td>\n"; my $colored_age; @@ -639,7 +634,6 @@ sub git_project_list { "<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"; } @@ -741,9 +735,9 @@ sub git_summary { my %ad = date_str($co{'author_epoch'}); print "<tr>\n"; if (--$i > 0) { - print "<td>$co{'age_string'}</td>\n" . - "<td>$co{'author_name'}</td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . "</td>\n" . + print "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>$co{'author_name'}</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . @@ -770,8 +764,9 @@ sub git_summary { my %tag = %$entry; print "<tr>\n"; if (--$i > 0) { - print "<td>$tag{'age'}</td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" . + print "<td><i>$tag{'age'}</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" . "</tr>"; } else { print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" . @@ -795,8 +790,9 @@ sub git_summary { my %tag = %$entry; print "<tr>\n"; if (--$i > 0) { - print "<td>$tag{'age'}</td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "</td>\n" . + print "<td><i>$tag{'age'}</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" . "</tr>"; } else { print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" . @@ -823,16 +819,20 @@ sub git_tags { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") . "</div>\n"; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, - "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . - "</div>\n"; + print "<tr>\n" . + "<td><i>$tag{'age'}</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" . + "</tr>"; } } - print "<div class=\"list\"><br/></div>\n"; + print "</table\n>" . + "</div>\n"; git_footer_html(); } @@ -849,16 +849,20 @@ sub git_branches { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") . "</div>\n"; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, - "<span class=\"age\">$tag{'age'}</span>" . escapeHTML($tag{'name'})) . "\n" . - "</div>\n"; + print "<tr>\n" . + "<td><i>$tag{'age'}</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" . + "</tr>"; } } - print "<div class=\"list\"><br/></div>\n"; + print "</table\n>" . + "</div>\n"; git_footer_html(); } @@ -942,9 +946,9 @@ sub git_tree { my $base = $hash_base || git_read_hash("$project/HEAD"); $hash = git_get_hash_by_path($base, $file_name, "tree"); } - } - if (!defined $hash_base) { - $hash_base = git_read_hash("$project/HEAD"); + if (!defined $hash_base) { + $hash_base = git_read_hash("$project/HEAD"); + } } open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; @@ -988,15 +992,17 @@ sub git_tree { my $t_name = $4; $file_key = ";f=$base$t_name"; print "<tr>\n" . - "<td class=\"pre\">" . mode_str($t_mode) . "</td>\n"; + "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { - print "<td class=\"pre\">$t_name</td>\n"; + print "<td class=\"list\">" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) . + "</td>\n"; print "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . "</td>\n"; } elsif ($t_type eq "tree") { - print "<td class=\"pre\">" . + print "<td class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "</td>\n"; } @@ -1089,7 +1095,7 @@ sub git_log { my $comment = $co{'comment'}; my $empty = 0; foreach my $line (@$comment) { - if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { + if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { next; } if ($line eq "") { @@ -1159,12 +1165,12 @@ sub git_commit { print "</td></tr>\n"; print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; - print "<tr><td>commit</td><td style=\"font-family: monospace;\">$hash</td></tr>\n"; - print "<tr><td>tree</td><td style=\"font-family: monospace;\">" . + print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n"; + print "<tr><td>tree</td><td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, $co{'tree'}) . "</td></tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "<tr><td>parent</td><td style=\"font-family: monospace;\">" . + print "<tr><td>parent</td><td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n"; } print "</table>". @@ -1183,7 +1189,7 @@ sub git_commit { } else { $empty = 0; } - if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { + if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { $signed = 1; print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { @@ -1197,6 +1203,8 @@ sub git_commit { print(($#difftree + 1) . " files changed:\n"); } print "</div>\n"; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -1208,70 +1216,69 @@ sub git_commit { my $type = $3; my $id = $4; my $file = $5; - if ($type eq "blob") { - if ($op eq "+") { - my $mode_chng = ""; - if (S_ISREG(oct $mode)) { - $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777); - } - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, - escapeHTML($file) . " <span style=\"color: #008000;\">[new " . file_type($mode) . "$mode_chng]</span>") . "\n" . - "</div>\n"; - print "<div class=\"list_link\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" . - "</div>\n"; - } elsif ($op eq "-") { - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, - escapeHTML($file) . " <span style=\"color: #c00000;\">[deleted " . file_type($mode) . "]</span>") . "\n" . - "</div>"; - print "<div class=\"list_link\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" . - "</div>\n"; - } elsif ($op eq "*") { - $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - my $from_id = $1; - my $to_id = $2; - $mode =~ m/^([0-7]{6})->([0-7]{6})$/; - my $from_mode = $1; - my $to_mode = $2; - my $mode_chnge = ""; - if ($from_mode != $to_mode) { - $mode_chnge = " <span style=\"color: #777777;\">[changed"; - if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) { - $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode); - } - if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) { - if (S_ISREG($from_mode) && S_ISREG($to_mode)) { - $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777); - } elsif (S_ISREG($to_mode)) { - $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777); - } - } - $mode_chnge .= "]</span>\n"; - } - print "<div class=\"list\">\n"; - if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, - escapeHTML($file) . $mode_chnge) . "\n" . - "</div>\n"; - } else { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, - escapeHTML($file) . $mode_chnge) . "\n" . - "</div>\n"; - } - print "<div class=\"list_link\">\n"; - if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; - } - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n" . - "</div>\n"; - } + if ($type ne "blob") { + next; } + print "<tr>\n"; + if ($op eq "+") { + my $mode_chng = ""; + if (S_ISREG(oct $mode)) { + $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777); + } + print "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + "<td><span style=\"color: #008000;\">[new " . file_type($mode) . "$mode_chng]</span></td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "</td>\n"; + } elsif ($op eq "-") { + print "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + "<td><span style=\"color: #c00000;\">[deleted " . file_type($mode). "]</span></td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . + "</td>\n" + } elsif ($op eq "*") { + $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; + my $from_id = $1; + my $to_id = $2; + $mode =~ m/^([0-7]{6})->([0-7]{6})$/; + my $from_mode = $1; + my $to_mode = $2; + my $mode_chnge = ""; + if ($from_mode != $to_mode) { + $mode_chnge = " <span style=\"color: #777777;\">[changed"; + if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) { + $mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode); + } + if (((oct $from_mode) & 0777) != ((oct $to_mode) & 0777)) { + if (S_ISREG($from_mode) && S_ISREG($to_mode)) { + $mode_chnge .= sprintf(" mode: %04o->%04o", (oct $from_mode) & 0777, (oct $to_mode) & 0777); + } elsif (S_ISREG($to_mode)) { + $mode_chnge .= sprintf(" mode: %04o", (oct $to_mode) & 0777); + } + } + $mode_chnge .= "]</span>\n"; + } + print "<td>"; + if ($to_id ne $from_id) { + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)); + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)); + } + print "</td>\n" . + "<td>$mode_chnge</td>\n" . + "<td class=\"link\">"; + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob"); + if ($to_id ne $from_id) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff"); + } + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n"; + print "</td>\n"; + } + print "</tr>\n"; } + print "</table><br/>\n" . + "</div>\n"; git_footer_html(); } @@ -1344,7 +1351,7 @@ sub git_commitdiff { shift @log; } foreach my $line (@log) { - if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { + if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { next; } if ($line eq "") { @@ -1421,8 +1428,11 @@ sub git_history { print "<div class=\"page_path\">\n" . "/$file_name<br/>\n"; print "</div>\n"; + open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; my $commit; + print "<div class=\"page_body\">\n" . + "<table cellspacing=\"0\">\n"; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40}) /){ $commit = $1; @@ -1438,11 +1448,11 @@ sub git_history { if (!%co) { next; } - print "<div class=\"list\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . - "</div>\n"; - print "<div class=\"list_link\">\n" . + print "<tr>" . + "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>$co{'author_name'}</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob"); @@ -1451,11 +1461,13 @@ sub git_history { if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff"); } - print "<br/>\n" . - "</div>\n"; + print "</td>\n" . + "</tr>\n"; undef $commit; } } + print "</table><br/>\n" . + "</div>\n"; close $fd; git_footer_html(); } From bddec01de1bf3081174b2ffc379d228c080f957d Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:25:42 +0200 Subject: [PATCH 061/148] v160 --- gitweb.cgi | 197 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 73 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 09ea9998311..078f25fa329 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "157"; +my $version = "160"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -194,23 +194,21 @@ div.title, a.title { font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; } a.title:hover { background-color: #d9d8d1; } -div.title_text { padding:6px 8px; border: solid #d9d8d1; border-width:0px 0px 1px; } +div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; } div.log_body { padding:8px 8px 8px 150px; } span.age { position:relative; float:left; width:142px; font-style:italic; } div.log_link { + padding:0px 8px; font-size:10px; font-family:sans-serif; font-style:normal; - position:relative; float:left; width:142px; -} -div.list_head { - display:block; padding:6px 6px 4px; border:solid #d9d8d1; - border-width:1px 0px 0px; font-style:italic; + position:relative; float:left; width:136px; } +div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } a.list { text-decoration:none; color:#000000; } a.list:hover { color:#880000; } -td { padding:5px 15px 0px 0px; font-size:12px; } -th { padding-right:10px; font-size:12px; text-align:left; } -td.link { font-family:sans-serif; font-size:10px; } -td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; } +table { padding:8px 4px; } +th { padding:2px 5px; font-size:12px; text-align:left; } +td { padding:2px 5px; font-size:12px; } +td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } div.pre { font-family:monospace; font-size:12px; white-space:pre; } div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } @@ -592,8 +590,7 @@ sub git_project_list { close $fd; print "</div>\n"; } - print "<div class=\"page_body\"><br/>\n" . - "<table cellspacing=\"0\">\n" . + print "<table cellspacing=\"0\">\n" . "<tr>\n" . "<th>Project</th>\n" . "<th>Description</th>\n" . @@ -601,6 +598,7 @@ sub git_project_list { "<th>last change</th>\n" . "<th></th>\n" . "</tr>\n"; + my $alternate = 0; foreach my $pr (@list) { my %proj = %$pr; my $head = git_read_hash("$proj{'path'}/HEAD"); @@ -618,8 +616,13 @@ sub git_project_list { 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", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . "<td>$descr</td>\n" . "<td><i>$proj{'owner'}</i></td>\n"; my $colored_age; @@ -638,8 +641,7 @@ sub git_project_list { "</tr>\n"; } print "</table>\n" . - "<br/>\n" . - "</div>\n"; + "<br/>\n"; git_footer_html(); } @@ -714,26 +716,29 @@ sub git_summary { "<br/><br/>\n" . "</div>\n"; print "<div class=\"title\">project</div>\n"; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n" . + print "<table cellspacing=\"0\">\n" . "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" . "<tr><td>owner</td><td>$owner</td></tr>\n" . "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" . - "</table>\n" . - "<br/></div>\n"; - open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); + "</table>\n"; + open my $fd, "-|", "$gitbin/git-rev-list --max-count=16 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "commits") . "</div>\n"; - my $i = 10; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + my $i = 15; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; foreach my $commit (@revlist) { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); - print "<tr>\n"; + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; if (--$i > 0) { print "<td><i>$co{'age_string'}</i></td>\n" . "<td><i>$co{'author_name'}</i></td>\n" . @@ -749,20 +754,24 @@ sub git_summary { last; } } - print "</table\n>" . - "</div>\n"; + print "</table\n>"; my $taglist = git_read_refs("refs/tags"); if (defined @$taglist) { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") . "</div>\n"; - my $i = 10; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + my $i = 15; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; foreach my $entry (@$taglist) { my %tag = %$entry; - print "<tr>\n"; + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; if (--$i > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . @@ -774,8 +783,7 @@ sub git_summary { last; } } - print "</table\n>" . - "</div>\n"; + print "</table\n>"; } my $branchlist = git_read_refs("refs/heads"); @@ -783,12 +791,17 @@ sub git_summary { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") . "</div>\n"; - my $i = 10; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + my $i = 15; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; foreach my $entry (@$branchlist) { my %tag = %$entry; - print "<tr>\n"; + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; if (--$i > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . @@ -800,8 +813,7 @@ sub git_summary { last; } } - print "</table\n>" . - "</div>\n"; + print "</table\n>"; } git_footer_html(); } @@ -819,20 +831,24 @@ sub git_tags { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") . "</div>\n"; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; - print "<tr>\n" . - "<td><i>$tag{'age'}</i></td>\n" . + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" . "</tr>"; } } - print "</table\n>" . - "</div>\n"; + print "</table\n>"; git_footer_html(); } @@ -849,20 +865,24 @@ sub git_branches { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") . "</div>\n"; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; - print "<tr>\n" . - "<td><i>$tag{'age'}</i></td>\n" . + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" . "</tr>"; } } - print "</table\n>" . - "</div>\n"; + print "</table\n>"; git_footer_html(); } @@ -983,6 +1003,7 @@ sub git_tree { } print "<div class=\"page_body\">\n"; print "<table cellspacing=\"0\">\n"; + my $alternate = 0; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -991,8 +1012,13 @@ sub git_tree { my $t_hash = $3; my $t_name = $4; $file_key = ";f=$base$t_name"; - print "<tr>\n" . - "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { print "<td class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) . @@ -1004,7 +1030,8 @@ sub git_tree { } elsif ($t_type eq "tree") { print "<td class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . - "</td>\n"; + "</td>\n" . + "<td></td>\n"; } print "</tr>\n"; } @@ -1156,22 +1183,34 @@ sub git_commit { print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n"; print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n". - "<tr><td></td><td> $ad{'rfc2822'}"; + "<tr>" . + "<td></td><td> $ad{'rfc2822'}"; if ($ad{'hour_local'} < 6) { printf(" (<span style=\"color: #cc0000;\">%02d:%02d</span> %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } else { printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } - print "</td></tr>\n"; + print "</td>" . + "</tr>\n"; print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n"; - print "<tr><td>tree</td><td style=\"font-family:monospace\">" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, $co{'tree'}) . "</td></tr>\n"; + print "<tr>" . + "<td>tree</td>" . + "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) . "</td>" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + "</td>" . + "</tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "<tr><td>parent</td><td style=\"font-family:monospace\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "</td></tr>\n"; + print "<tr>" . + "<td>parent</td>" . + "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, "commit") . + " |" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") . + "</td>" . + "</tr>\n"; } print "</table>". "</div>\n"; @@ -1203,8 +1242,8 @@ sub git_commit { print(($#difftree + 1) . " files changed:\n"); } print "</div>\n"; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -1219,7 +1258,13 @@ sub git_commit { if ($type ne "blob") { next; } - print "<tr>\n"; + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<tr$alternate>\n"; if ($op eq "+") { my $mode_chng = ""; if (S_ISREG(oct $mode)) { @@ -1277,8 +1322,7 @@ sub git_commit { } print "</tr>\n"; } - print "</table><br/>\n" . - "</div>\n"; + print "</table>\n"; git_footer_html(); } @@ -1326,7 +1370,10 @@ sub git_commitdiff { if (!%co) { die_error(undef, "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed."); + if (!defined $hash_parent) { + $hash_parent = $co{'parent'}; + } + open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" || die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading diff-tree failed."); @@ -1431,8 +1478,8 @@ sub git_history { open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; my $commit; - print "<div class=\"page_body\">\n" . - "<table cellspacing=\"0\">\n"; + print "<table cellspacing=\"0\">\n"; + my $alternate = 0; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40}) /){ $commit = $1; @@ -1448,8 +1495,13 @@ sub git_history { if (!%co) { next; } - print "<tr>" . - "<td><i>$co{'age_string'}</i></td>\n" . + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td><i>$co{'age_string'}</i></td>\n" . "<td><i>$co{'author_name'}</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . @@ -1466,8 +1518,7 @@ sub git_history { undef $commit; } } - print "</table><br/>\n" . - "</div>\n"; + print "</table>\n"; close $fd; git_footer_html(); } From 7ab0d2b64619f0e9ca1eaecd333bd2dd68464dd8 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:25:54 +0200 Subject: [PATCH 062/148] v163 --- gitweb.cgi | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 078f25fa329..80e0d119a90 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "160"; +my $version = "163"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -256,9 +256,10 @@ sub die_error { git_header_html($status); print "<div class=\"page_body\">\n" . - "<br/><br/>\n"; - print "$status - $error\n"; - print "<br/></div>\n"; + "<br/><br/>\n" . + "$status - $error\n" . + "<br/>\n" . + "</div>\n"; git_footer_html(); exit; } @@ -304,9 +305,9 @@ sub git_read_tag { chomp $line; if ($line =~ m/^object ([0-9a-fA-F]{40})$/) { $tag{'object'} = $1; - } elsif ($line =~ m/^type (.*)$/) { + } elsif ($line =~ m/^type (.+)$/) { $tag{'type'} = $1; - } elsif ($line =~ m/^tag (.*)$/) { + } elsif ($line =~ m/^tag (.+)$/) { $tag{'name'} = $1; } } @@ -326,9 +327,9 @@ sub git_read_commit { while (my $line = <$fd>) { last if $line eq "\n"; chomp $line; - if ($line =~ m/^tree (.*)$/) { + if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) { $co{'tree'} = $1; - } elsif ($line =~ m/^parent (.*)$/) { + } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) { push @parents, $1; } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; @@ -554,9 +555,10 @@ sub git_project_list { } closedir($dh); } elsif (-f $projects_list) { - # read from file: - # 'git/git.git:Linus Torvalds' - # 'linux/hotplug/udev.git' + # read from file(url-encoded): + # 'git%2Fgit.git Linus+Torvalds' + # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin' + # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman' open my $fd , $projects_list || return undef; while (my $line = <$fd>) { chomp $line; @@ -640,8 +642,7 @@ sub git_project_list { "</td>\n" . "</tr>\n"; } - print "</table>\n" . - "<br/>\n"; + print "</table>\n"; git_footer_html(); } @@ -898,7 +899,7 @@ sub git_get_hash_by_path { close $fd || return undef; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' - $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; + $line =~ m/^([0-9]+)\t(.+)\t([0-9a-fA-F]{40})\t(.+)$/; my $t_mode = $1; my $t_type = $2; my $t_hash = $3; @@ -1006,7 +1007,7 @@ sub git_tree { my $alternate = 0; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' - $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; + $line =~ m/^([0-9]+)\t(.+)\t([0-9a-fA-F]{40})\t(.+)$/; my $t_mode = $1; my $t_type = $2; my $t_hash = $3; @@ -1030,8 +1031,10 @@ sub git_tree { } elsif ($t_type eq "tree") { print "<td class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . - "</td>\n" . - "<td></td>\n"; + "</td>\n"; + print "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . + "</td>\n"; } print "</tr>\n"; } @@ -1249,7 +1252,7 @@ sub git_commit { # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c' # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c' - $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; + $line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}|[0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/; my $op = $1; my $mode = $2; my $type = $3; @@ -1264,7 +1267,6 @@ sub git_commit { print "<tr>\n"; } $alternate ^= 1; - print "<tr$alternate>\n"; if ($op eq "+") { my $mode_chng = ""; if (S_ISREG(oct $mode)) { @@ -1414,7 +1416,7 @@ sub git_commitdiff { print "<br/>\n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' - $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; + $line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}|[0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/; my $op = $1; my $mode = $2; my $type = $3; @@ -1485,12 +1487,7 @@ sub git_history { $commit = $1; next; } - if ($line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/ && (defined $commit)) { - my $type = $3; - my $file = $5; - if ($file ne $file_name || $type ne "blob") { - next; - } + if ($line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/ && (defined $commit)) { my %co = git_read_commit($commit); if (!%co) { next; @@ -1507,11 +1504,11 @@ sub git_history { "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"}, "diff"); } print "</td>\n" . "</tr>\n"; From 2bf7a52c6195a52e12cb2b9821a9a026846e7b1c Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:26:03 +0200 Subject: [PATCH 063/148] v164 --- gitweb.cgi | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 80e0d119a90..8dc7a7350bc 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "163"; +my $version = "164"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -335,8 +335,11 @@ sub git_read_commit { $co{'author'} = $1; $co{'author_epoch'} = $2; $co{'author_tz'} = $3; - $co{'author_name'} = $co{'author'}; - $co{'author_name'} =~ s/ <.*//; + if ($co{'author'} =~ m/^([^<]+) </) { + $co{'author_name'} = $1; + } else { + $co{'author_name'} = $co{'author'}; + } } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { $co{'committer'} = $1; $co{'committer_epoch'} = $2; @@ -353,11 +356,7 @@ sub git_read_commit { $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; - $comment[0] =~ m/^(.{0,50}[^ \/\-_:\.]{0,10})/; - $co{'title'} = $1; - if ($comment[0] ne $co{'title'}) { - $co{'title'} .= " ..."; - } + $co{'title'} = chop_str($comment[0], 50); close $fd || return; my $age = time - $co{'committer_epoch'}; @@ -467,6 +466,18 @@ sub mode_str { } } +sub chop_str { + my $str = shift; + my $len = shift; + + $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,10})/; + my $chopped = $1; + if ($chopped ne $str) { + $chopped .= " ..."; + } + return $chopped; +} + sub file_type { my $mode = oct shift; @@ -614,6 +625,7 @@ sub git_project_list { next; } my $descr = git_read_description($proj{'path'}) || ""; + $descr = chop_str($descr, 30); # get directory owner if not already specified if (!defined $proj{'owner'}) { $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; @@ -626,7 +638,7 @@ sub git_project_list { $alternate ^= 1; print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . "<td>$descr</td>\n" . - "<td><i>$proj{'owner'}</i></td>\n"; + "<td><i>" . chop_str($proj{'owner'}, 20) . "</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>"; @@ -742,7 +754,7 @@ sub git_summary { $alternate ^= 1; if (--$i > 0) { print "<td><i>$co{'age_string'}</i></td>\n" . - "<td><i>$co{'author_name'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . @@ -1499,7 +1511,7 @@ sub git_history { } $alternate ^= 1; print "<td><i>$co{'age_string'}</i></td>\n" . - "<td><i>$co{'author_name'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . From 1f22c267772b2c707d5162cf3374a4332fdd7388 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:26:12 +0200 Subject: [PATCH 064/148] v165 --- gitweb.cgi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 8dc7a7350bc..75549a82e2f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "164"; +my $version = "165"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -1103,12 +1103,13 @@ sub git_log { git_header_html(); print "<div class=\"page_nav\">\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last 10") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=1"}, "day") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "last 10") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=1;h=$hash"}, "day") . + " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=log;t=7;h=$hash"}, "week") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=31;h=$hash"}, "month") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=365;h=$hash"}, "year") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0;h=$hash"}, "all") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$hash"}, "tree") . "<br/>\n"; print "<br/>\n" . "</div>\n"; From 198066916a8ea02b90430aa58e2cf5f5ad92ffdc Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:26:27 +0200 Subject: [PATCH 065/148] v203 --- gitweb.cgi | 809 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 583 insertions(+), 226 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 75549a82e2f..821766cc295 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -9,13 +9,13 @@ use strict; use warnings; -use CGI qw(:standard :escapeHTML); +use CGI qw(:standard :escapeHTML -nosticky); use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "165"; +my $version = "203"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -27,7 +27,7 @@ my $projectroot = "/pub/scm"; my $gitbin = "/usr/bin"; # location for temporary files needed for diffs -my $gittmp = "/tmp/gitweb"; +my $git_temp = "/tmp/gitweb"; # target of the home link on top of all pages my $home_link = $my_uri; @@ -42,7 +42,7 @@ my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); if (defined $action) { - if ($action =~ m/[^0-9a-zA-Z\.\-]+/) { + if ($action =~ m/[^0-9a-zA-Z\.\-_]+/) { undef $action; die_error(undef, "Invalid action parameter."); } @@ -74,7 +74,6 @@ if (defined $project) { } $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; - $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; } else { git_project_list(); exit; @@ -118,6 +117,16 @@ if (defined $time_back) { } } + +my $searchtext = $cgi->param('s'); +if (defined $searchtext) { + if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { + undef $searchtext; + die_error(undef, "Invalid search parameter."); + } + $searchtext = quotemeta $searchtext; +} + if ($action eq "summary") { git_summary(); exit; @@ -130,6 +139,9 @@ if ($action eq "summary") { } elsif ($action eq "blob") { git_blob(); exit; +} elsif ($action eq "blob_plain") { + git_blob_plain(); + exit; } elsif ($action eq "tree") { git_tree(); exit; @@ -145,12 +157,24 @@ if ($action eq "summary") { } elsif ($action eq "blobdiff") { git_blobdiff(); exit; +} elsif ($action eq "blobdiff_plain") { + git_blobdiff_plain(); + exit; } elsif ($action eq "commitdiff") { git_commitdiff(); exit; +} elsif ($action eq "commitdiff_plain") { + git_commitdiff_plain(); + exit; } elsif ($action eq "history") { git_history(); exit; +} elsif ($action eq "search") { + git_search(); + exit; +} elsif ($action eq "shortlog") { + git_shortlog(); + exit; } else { undef $action; die_error(undef, "Unknown action."); @@ -185,7 +209,7 @@ div.page_header a:visited { color:#0000cc; } div.page_header a:hover { color:#880000; } div.page_nav { padding:8px; } div.page_nav a:visited { color:#0000cc; } -div.page_path { font-weight:bold; padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} +div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; } div.page_footer_text { float:left; color:#555555; font-style:italic; } div.page_body { padding:8px; } @@ -207,11 +231,12 @@ a.list { text-decoration:none; color:#000000; } a.list:hover { color:#880000; } table { padding:8px 4px; } th { padding:2px 5px; font-size:12px; text-align:left; } -td { padding:2px 5px; font-size:12px; } +td { padding:2px 5px; font-size:12px; vertical-align:top; } td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } div.pre { font-family:monospace; font-size:12px; white-space:pre; } div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } +input.search { margin:4px 8px; position:absolute; top:56px; right:12px } a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; color:#ffffff; background-color:#ff6600; @@ -224,14 +249,27 @@ a.rss_logo:hover { background-color:#ee5500; } <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"http://kernel.org/pub/software/scm/git/docs/\">" . - "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/></a>"; + "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\">" . + "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . + "</a>\n"; print $cgi->a({-href => $home_link}, "projects") . " / "; if (defined $project) { print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, escapeHTML($project)); if (defined $action) { print " / $action"; } + print "\n"; + if (!defined $searchtext) { + $searchtext = ""; + } + $cgi->param("a", "search"); + # post search form, but fake get parameter in browser + #print $cgi->startform(-name => "search", -action => "$my_uri", + # -onsubmit => "document.search.action='?p=$project;a=search;s='+document.search.s.value") . + # $cgi->hidden(-name => "p") . "\n" . + # $cgi->hidden(-name => "a") . "\n" . + # $cgi->textfield(-name => "s", -value => $searchtext, -class => "search") . + # $cgi->end_form() . "\n"; } print "</div>\n"; } @@ -267,7 +305,7 @@ sub die_error { sub git_get_type { my $hash = shift; - open my $fd, "-|", "$gitbin/git-cat-file -t $hash" || return; + open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return; my $type = <$fd>; close $fd; chomp $type; @@ -277,7 +315,7 @@ sub git_get_type { sub git_read_hash { my $path = shift; - open my $fd, "$projectroot/$path" || return undef; + open my $fd, "$projectroot/$path" or return undef; my $head = <$fd>; close $fd; chomp $head; @@ -289,7 +327,7 @@ sub git_read_hash { sub git_read_description { my $path = shift; - open my $fd, "$projectroot/$path/description" || return undef; + open my $fd, "$projectroot/$path/description" or return undef; my $descr = <$fd>; close $fd; chomp $descr; @@ -300,7 +338,7 @@ sub git_read_tag { my $tag_id = shift; my %tag; - open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" || return; + open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return; while (my $line = <$fd>) { chomp $line; if ($line =~ m/^object ([0-9a-fA-F]{40})$/) { @@ -311,7 +349,7 @@ sub git_read_tag { $tag{'name'} = $1; } } - close $fd || return; + close $fd or return; if (!defined $tag{'name'}) { return }; @@ -319,14 +357,22 @@ sub git_read_tag { } sub git_read_commit { - my $commit = shift; + my $commit_id = shift; + my $commit_text = shift; + + my @commit_lines; my %co; my @parents; - open my $fd, "-|", "$gitbin/git-cat-file commit $commit" || return; - while (my $line = <$fd>) { + if (defined $commit_text) { + @commit_lines = @$commit_text; + } else { + open my $fd, "-|", "$gitbin/git-cat-file commit $commit_id" or return; + @commit_lines = map { chomp; $_ } <$fd>; + close $fd or return; + } + while (my $line = shift @commit_lines) { last if $line eq "\n"; - chomp $line; if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) { $co{'tree'} = $1; } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) { @@ -349,15 +395,36 @@ sub git_read_commit { } } if (!defined $co{'tree'}) { - close $fd; return undef }; + $co{'id'} = $commit_id; $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; - my (@comment) = map { chomp; $_ } <$fd>; - $co{'comment'} = \@comment; - $co{'title'} = chop_str($comment[0], 50); - close $fd || return; + $co{'comment'} = \@commit_lines; + foreach my $title (@commit_lines) { + if ($title ne "") { + $co{'title'} = chop_str($title, 80); + # remove leading stuff of merges to make the interesting part visible + if (length($title) > 50) { + $title =~ s/^Automatic //; + $title =~ s/^merge (of|with) /Merge ... /i; + if (length($title) > 50) { + $title =~ s/(http|rsync):\/\///; + } + if (length($title) > 50) { + $title =~ s/(master|www|rsync)\.//; + } + if (length($title) > 50) { + $title =~ s/kernel.org:?//; + } + if (length($title) > 50) { + $title =~ s/\/pub\/scm//; + } + } + $co{'title_short'} = chop_str($title, 50); + last; + } + } my $age = time - $co{'committer_epoch'}; $co{'age'} = $age; @@ -388,11 +455,12 @@ sub git_read_commit { return %co; } -sub git_diff_html { +sub git_diff_print { my $from = shift; my $from_name = shift; my $to = shift; my $to_name = shift; + my $format = shift || "html"; my $from_tmp = "/dev/null"; my $to_tmp = "/dev/null"; @@ -400,7 +468,7 @@ sub git_diff_html { # create tmp from-file if (defined $from) { - $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; + $from_tmp = "$git_temp/gitweb_" . $$ . "_from"; open my $fd2, "> $from_tmp"; open my $fd, "-|", "$gitbin/git-cat-file blob $from"; my @file = <$fd>; @@ -411,7 +479,7 @@ sub git_diff_html { # create tmp to-file if (defined $to) { - $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; + $to_tmp = "$git_temp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; open my $fd, "-|", "$gitbin/git-cat-file blob $to"; my @file = <$fd>; @@ -421,21 +489,33 @@ sub git_diff_html { } open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp"; - while (my $line = <$fd>) { - chomp($line); - my $char = substr($line, 0, 1); - my $color = ""; - if ($char eq '+') { - $color = " style=\"color:#008800;\""; - } elsif ($char eq '-') { - $color = " style=\"color:#cc0000;\""; - } elsif ($char eq '@') { - $color = " style=\"color:#990099;\""; - } elsif ($char eq '\\') { - # skip errors - next; + if ($format eq "plain") { + undef $/; + print <$fd>; + $/ = "\n"; + } else { + while (my $line = <$fd>) { + chomp($line); + my $char = substr($line, 0, 1); + my $color = ""; + if ($char eq '+') { + $color = " style=\"color:#008800;\""; + } elsif ($char eq "-") { + $color = " style=\"color:#cc0000;\""; + } elsif ($char eq "@") { + $color = " style=\"color:#990099;\""; + } elsif ($char eq "\\") { + # skip errors + next; + } + while ((my $pos = index($line, "\t")) != -1) { + if (my $count = (8 - (($pos-1) % 8))) { + my $spaces = ' ' x $count; + $line =~ s/\t/$spaces/; + } + } + print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n"; } - print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n"; } close $fd; @@ -469,8 +549,9 @@ sub mode_str { sub chop_str { my $str = shift; my $len = shift; + my $add_len = shift || 10; - $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,10})/; + $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})/; my $chopped = $1; if ($chopped ne $str) { $chopped .= " ..."; @@ -555,7 +636,7 @@ sub git_project_list { if (-d $projects_list) { # search in directory my $dir = $projects_list; - opendir my $dh, $dir || return undef; + opendir my $dh, $dir or return undef; while (my $dir = readdir($dh)) { if (-e "$projectroot/$dir/HEAD") { my $pr = { @@ -570,7 +651,7 @@ sub git_project_list { # 'git%2Fgit.git Linus+Torvalds' # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin' # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman' - open my $fd , $projects_list || return undef; + open my $fd , $projects_list or return undef; while (my $line = <$fd>) { chomp $line; my ($path, $owner) = split ' ', $line; @@ -619,13 +700,12 @@ sub git_project_list { 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'}) || ""; - $descr = chop_str($descr, 30); + $descr = chop_str($descr, 25, 5); # get directory owner if not already specified if (!defined $proj{'owner'}) { $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; @@ -638,7 +718,7 @@ sub git_project_list { $alternate ^= 1; print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . "<td>$descr</td>\n" . - "<td><i>" . chop_str($proj{'owner'}, 20) . "</i></td>\n"; + "<td><i>" . chop_str($proj{'owner'}, 15) . "</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>"; @@ -650,6 +730,7 @@ sub git_project_list { 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=shortlog"}, "shortlog") . " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") . "</td>\n" . "</tr>\n"; @@ -698,8 +779,6 @@ sub git_read_refs { sub git_summary { my $descr = git_read_description($project) || "none"; my $head = git_read_hash("$project/HEAD"); - $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; - $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; my %co = git_read_commit($head); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); @@ -724,23 +803,27 @@ sub git_summary { git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + "summary". + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . "<br/><br/>\n" . "</div>\n"; - print "<div class=\"title\">project</div>\n"; + print "<div class=\"title\"> </div>\n"; print "<table cellspacing=\"0\">\n" . "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" . "<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=16 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "commits") . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog", -class => "title"}, "shortlog") . "</div>\n"; - my $i = 15; + my $i = 16; print "<table cellspacing=\"0\">\n"; my $alternate = 0; foreach my $commit (@revlist) { @@ -752,17 +835,20 @@ sub git_summary { print "<tr>\n"; } $alternate ^= 1; - if (--$i > 0) { + if ($i-- > 0) { print "<td><i>$co{'age_string'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, + "<b>" . escapeHTML($co{'title_short'}) . "</b>") . + "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "...") . "</td>\n" . "</tr>"; last; } @@ -774,7 +860,7 @@ sub git_summary { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") . "</div>\n"; - my $i = 15; + my $i = 16; print "<table cellspacing=\"0\">\n"; my $alternate = 0; foreach my $entry (@$taglist) { @@ -785,10 +871,19 @@ sub git_summary { print "<tr>\n"; } $alternate ^= 1; - if (--$i > 0) { + if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . + escapeHTML($tag{'name'}) . "</b>") . + "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); + if ($tag{'type'} eq "commit") { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); + } + print "</td>\n" . "</tr>"; } else { print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" . @@ -804,7 +899,7 @@ sub git_summary { print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") . "</div>\n"; - my $i = 15; + my $i = 16; print "<table cellspacing=\"0\">\n"; my $alternate = 0; foreach my $entry (@$branchlist) { @@ -815,10 +910,16 @@ sub git_summary { print "<tr>\n"; } $alternate ^= 1; - if (--$i > 0) { + if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}", -class => "list"}, + "<b>" . escapeHTML($tag{'name'}) . "</b>") . + "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . + "</td>\n" . "</tr>"; } else { print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" . @@ -835,14 +936,17 @@ sub git_tags { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . - "<br/><br/>\n" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" . + "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/tags"); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") . + $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -856,8 +960,17 @@ sub git_tags { } $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "</td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, + "<b>" . escapeHTML($tag{'name'}) . "</b>") . + "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); + if ($tag{'type'} eq "commit") { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); + } + print "</td>\n" . "</tr>"; } } @@ -869,14 +982,17 @@ sub git_branches { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . - "<br/><br/>\n" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" . + "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/heads"); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") . + $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -890,8 +1006,13 @@ sub git_branches { } $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "</td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . + "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . + "</td>\n" . "</tr>"; } } @@ -901,17 +1022,17 @@ sub git_branches { sub git_get_hash_by_path { my $base = shift; - my $path = shift; + my $path = shift || return undef; my $tree = $base; my @parts = split '/', $path; while (my $part = shift @parts) { - open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error(undef, "Open git-ls-tree failed."); + open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd || return undef; + close $fd or return undef; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' - $line =~ m/^([0-9]+)\t(.+)\t([0-9a-fA-F]{40})\t(.+)$/; + $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/; my $t_mode = $1; my $t_type = $2; my $t_hash = $3; @@ -934,18 +1055,18 @@ sub git_blob { my $base = $hash_base || git_read_hash("$project/HEAD"); $hash = git_get_hash_by_path($base, $file_name, "blob"); } - open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed."); my $base = $file_name || ""; git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree"); - if (defined $file_name) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); - } - print "<br/><br/>\n" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" . "</div>\n"; print "<div>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . @@ -956,22 +1077,35 @@ sub git_blob { "<div class=\"title\">$hash</div>\n"; } if (defined $file_name) { - print "<div class=\"page_path\">/$file_name</div>\n"; + print "<div class=\"page_path\"><b>$file_name</b></div>\n"; } print "<div class=\"page_body\">\n"; my $nr; while (my $line = <$fd>) { chomp $line; $nr++; - print "<div class=\"pre\">"; - printf "<span style=\"color:#999999;\">%4i</span>", $nr; - print " " .escapeHTML($line) . "</div>\n"; + while ((my $pos = index($line, "\t")) != -1) { + if (my $count = (8 - ($pos % 8))) { + my $spaces = ' ' x $count; + $line =~ s/\t/$spaces/; + } + } + printf "<div class=\"pre\"><span style=\"color:#999999;\">%4i</span> %s</div>\n", $nr, escapeHTML($line); } - close $fd || print "Reading blob failed.\n"; + close $fd or print "Reading blob failed.\n"; print "</div>"; git_footer_html(); } +sub git_blob_plain { + print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return; + undef $/; + print <$fd>; + $/ = "\n"; + close $fd; +} + sub git_tree { if (!defined $hash) { $hash = git_read_hash("$project/HEAD"); @@ -983,9 +1117,9 @@ sub git_tree { $hash_base = git_read_hash("$project/HEAD"); } } - open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed."); + open my $fd, "-|", "$gitbin/git-ls-tree $hash" or die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading tree failed."); + close $fd or die_error(undef, "Reading tree failed."); git_header_html(); my $base_key = ""; @@ -994,10 +1128,12 @@ sub git_tree { if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash_base"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash_base"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . + " | tree" . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . @@ -1010,16 +1146,16 @@ sub git_tree { } if (defined $file_name) { $base = "$file_name/"; - print "<div class=\"page_path\">/$file_name</div>\n"; + print "<div class=\"page_path\"><b>/$file_name</b></div>\n"; } else { - print "<div class=\"page_path\">/</div>\n"; + print "<div class=\"page_path\"><b>/</b></div>\n"; } print "<div class=\"page_body\">\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' - $line =~ m/^([0-9]+)\t(.+)\t([0-9a-fA-F]{40})\t(.+)$/; + $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/; my $t_mode = $1; my $t_type = $2; my $t_hash = $3; @@ -1043,10 +1179,8 @@ sub git_tree { } elsif ($t_type eq "tree") { print "<td class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . - "</td>\n"; - print "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . - "</td>\n"; + "</td>\n" . + "<td></td>\n"; } print "</tr>\n"; } @@ -1056,68 +1190,85 @@ sub git_tree { } sub git_rss { - open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); + # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading rev-list failed."); + close $fd or die_error(undef, "Reading rev-list failed."); print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". - "<rss version=\"0.91\">\n"; + "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n"; print "<channel>\n"; print "<title>$project</title>\n". - "<link> $my_url/$project/log</link>\n". + "<link>" . escapeHTML("$my_url/$project/log") . "</link>\n". "<description>$project log</description>\n". "<language>en</language>\n"; foreach my $commit (@revlist) { my %co = git_read_commit($commit); - my %ad = date_str($co{'author_epoch'}); + my %cd = date_str($co{'committer_epoch'}); print "<item>\n" . - "\t<title>" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . - "\t<link> $my_url?p=$project;a=commit;h=$commit</link>\n" . - "\t<description>"; + "<title>" . + sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML($co{'title'}) . + "</title>\n" . + "<pubDate>$cd{'rfc2822'}</pubDate>\n" . + "<link>" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" . + "<description>" . escapeHTML($co{'title'}) . "</description>\n" . + "<content:encoded>" . + "<![CDATA[\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { - print escapeHTML($line) . "<br/>\n"; + print "$line<br/>\n"; } - print "\t</description>\n" . + print "]]>\n" . + "</content:encoded>\n" . "</item>\n"; } print "</channel></rss>"; } sub git_log { + my $head = git_read_hash("$project/HEAD"); if (!defined $hash) { - $hash = git_read_hash("$project/HEAD"); + $hash = $head; } my $limit_option = ""; if (!defined $time_back) { - $limit_option = "--max-count=10"; + $limit_option = "--max-count=100"; } elsif ($time_back > 0) { my $date = time - $time_back*24*60*60; $limit_option = "--max-age=$date"; } - open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading rev-list failed."); + close $fd or die_error(undef, "Reading rev-list failed."); git_header_html(); print "<div class=\"page_nav\">\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "last 10") . + print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . + " | log" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n"; + if ($hash ne $head) { + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD") . " ⋅ "; + } + print $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "100") . " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=1;h=$hash"}, "day") . " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=log;t=7;h=$hash"}, "week") . " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=31;h=$hash"}, "month") . " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=365;h=$hash"}, "year") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0;h=$hash"}, "all") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$hash"}, "tree") . "<br/>\n"; + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0;h=$hash"}, "all"); print "<br/>\n" . "</div>\n"; - if (!@revlist) { + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . + "</div>\n"; my %co = git_read_commit($hash); print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; } - foreach my $commit (@revlist) { my %co = git_read_commit($commit); next if !%co; @@ -1168,20 +1319,19 @@ sub git_commit { my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); my @difftree; - if (defined $co{'parent'}) { - open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed."); - @difftree = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading diff-tree failed."); - } else { - # fake git-diff-tree output for initial revision - open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error(undef, "Open failed."); - @difftree = map { chomp; "+" . $_ } <$fd>; - close $fd || die_error(undef, "Reading ls-tree failed."); + my $root = ""; + if (!defined $co{'parent'}) { + $root = " --root"; } + open my $fd, "-|", "$gitbin/git-diff-tree -r $root $co{'parent'} $hash" or die_error(undef, "Open failed."); + @difftree = map { chomp; $_ } <$fd>; + close $fd or die_error(undef, "Reading diff-tree failed."); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit"); + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . + " | commit"; if (defined $co{'parent'}) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); } @@ -1213,7 +1363,9 @@ sub git_commit { print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n"; print "<tr>" . "<td>tree</td>" . - "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) . "</td>" . + "<td style=\"font-family:monospace\">" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) . + "</td>" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "</td>" . "</tr>\n"; @@ -1261,49 +1413,40 @@ sub git_commit { print "<table cellspacing=\"0\">\n"; my $alternate = 0; foreach my $line (@difftree) { - # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' - # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' - # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c' - # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c' - $line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}|[0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/; - my $op = $1; - my $mode = $2; - my $type = $3; - my $id = $4; - my $file = $5; - if ($type ne "blob") { - next; - } + # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c' + # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c' + $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; + my $from_mode = $1; + my $to_mode = $2; + my $from_id = $3; + my $to_id = $4; + my $status = $5; + my $file = $6; + #print "$line ($status)<br/>\n"; if ($alternate) { print "<tr style=\"background-color:#f6f5ed\">\n"; } else { print "<tr>\n"; } $alternate ^= 1; - if ($op eq "+") { + if ($status eq "N") { my $mode_chng = ""; - if (S_ISREG(oct $mode)) { - $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777); + if (S_ISREG(oct $to_mode)) { + $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . - "<td><span style=\"color: #008000;\">[new " . file_type($mode) . "$mode_chng]</span></td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "</td>\n"; - } elsif ($op eq "-") { + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . "</td>\n"; + } elsif ($status eq "D") { print "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . - "<td><span style=\"color: #c00000;\">[deleted " . file_type($mode). "]</span></td>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + "<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "</td>\n" - } elsif ($op eq "*") { - $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - my $from_id = $1; - my $to_id = $2; - $mode =~ m/^([0-7]{6})->([0-7]{6})$/; - my $from_mode = $1; - my $to_mode = $2; + } elsif ($status eq "M" || $status eq "T") { my $mode_chnge = ""; if ($from_mode != $to_mode) { $mode_chnge = " <span style=\"color: #777777;\">[changed"; @@ -1342,18 +1485,18 @@ sub git_commit { } sub git_blobdiff { - mkdir($gittmp, 0700); + mkdir($git_temp, 0700); git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree"); - if (defined $file_name) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); - } - print "<br/><br/>\n" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . + "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "</div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . @@ -1364,9 +1507,7 @@ sub git_blobdiff { "<div class=\"title\">$hash vs $hash_parent</div>\n"; } if (defined $file_name) { - print "<div class=\"page_path\">\n" . - "/$file_name\n" . - "</div>\n"; + print "<div class=\"page_path\"><b>/$file_name</b></div>\n"; } print "<div class=\"page_body\">\n" . "<div class=\"diff_info\">blob:" . @@ -1374,13 +1515,19 @@ sub git_blobdiff { " -> blob:" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) . "</div>\n"; - git_diff_html($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); + git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); print "</div>"; git_footer_html(); } +sub git_blobdiff_plain { + mkdir($git_temp, 0700); + print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain"); +} + sub git_commitdiff { - mkdir($gittmp, 0700); + mkdir($git_temp, 0700); my %co = git_read_commit($hash); if (!%co) { die_error(undef, "Unknown commit object."); @@ -1388,17 +1535,20 @@ sub git_commitdiff { if (!defined $hash_parent) { $hash_parent = $co{'parent'}; } - open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading diff-tree failed."); + close $fd or die_error(undef, "Reading diff-tree failed."); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . - "<br/><br/></div>\n"; + " | commitdiff" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "\n" . + "</div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; @@ -1428,39 +1578,33 @@ sub git_commitdiff { } print "<br/>\n"; foreach my $line (@difftree) { - # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' - $line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}|[0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/; - my $op = $1; - my $mode = $2; - my $type = $3; - my $id = $4; - my $file = $5; - if ($type eq "blob") { - if ($op eq "+") { - print "<div class=\"diff_info\">" . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(new)" . - "</div>\n"; - git_diff_html(undef, "/dev/null", $id, "b/$file"); - } elsif ($op eq "-") { - print "<div class=\"diff_info\">" . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(deleted)" . - "</div>\n"; - git_diff_html($id, "a/$file", undef, "/dev/null"); - } elsif ($op eq "*") { - $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - my $from_id = $1; - my $to_id = $2; - $mode =~ m/([0-7]+)->([0-7]+)/; - my $from_mode = $1; - my $to_mode = $2; - if ($from_id ne $to_id) { - print "<div class=\"diff_info\">" . - file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . - " -> " . - file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id); - print "</div>\n"; - git_diff_html($from_id, "a/$file", $to_id, "b/$file"); - } + # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c' + # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c' + $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; + my $from_mode = $1; + my $to_mode = $2; + my $from_id = $3; + my $to_id = $4; + my $status = $5; + my $file = $6; + if ($status eq "N") { + print "<div class=\"diff_info\">" . file_type($to_mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" . + "</div>\n"; + git_diff_print(undef, "/dev/null", $to_id, "b/$file"); + } elsif ($status eq "D") { + print "<div class=\"diff_info\">" . file_type($from_mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . "(deleted)" . + "</div>\n"; + git_diff_print($from_id, "a/$file", undef, "/dev/null"); + } elsif ($status eq "M") { + if ($from_id ne $to_id) { + print "<div class=\"diff_info\">" . + file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . + " -> " . + file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id); + print "</div>\n"; + git_diff_print($from_id, "a/$file", $to_id, "b/$file"); } } } @@ -1469,6 +1613,29 @@ sub git_commitdiff { git_footer_html(); } +sub git_commitdiff_plain { + mkdir($git_temp, 0700); + open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed."); + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd or die_error(undef, "Reading diff-tree failed."); + + print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + foreach my $line (@difftree) { + $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; + my $from_id = $3; + my $to_id = $4; + my $status = $5; + my $file = $6; + if ($status eq "N") { + git_diff_print(undef, "/dev/null", $to_id, "b/$file", "plain"); + } elsif ($status eq "D") { + git_diff_print($from_id, "a/$file", undef, "/dev/null", "plain"); + } elsif ($status eq "M") { + git_diff_print($from_id, "a/$file", $to_id, "b/$file", "plain"); + } + } +} + sub git_history { if (!defined $hash) { $hash = git_read_hash("$project/HEAD"); @@ -1479,17 +1646,18 @@ sub git_history { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"page_path\">\n" . - "/$file_name<br/>\n"; - print "</div>\n"; + print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n"; open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; my $commit; @@ -1500,7 +1668,7 @@ sub git_history { $commit = $1; next; } - if ($line =~ m/^(.)(.+)\t(.+)\t([0-9a-fA-F]{40}->[0-9a-fA-F]{40})\t(.+)$/ && (defined $commit)) { + if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/ && (defined $commit)) { my %co = git_read_commit($commit); if (!%co) { next; @@ -1512,16 +1680,16 @@ sub git_history { } $alternate ^= 1; print "<td><i>$co{'age_string'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>") . "</td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . + escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"}, "diff"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"}, "diff to current"); } print "</td>\n" . "</tr>\n"; @@ -1532,3 +1700,192 @@ sub git_history { close $fd; git_footer_html(); } + +sub git_search { + if (!defined $searchtext) { + die_error("", "Text field empty."); + } + if (!defined $hash) { + $hash = git_read_hash("$project/HEAD"); + } + my %co = git_read_commit($hash); + if (!%co) { + die_error(undef, "Unknown commit object."); + } + git_header_html(); + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary;h=$hash"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + "<br/><br/>\n" . + "</div>\n"; + + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + "</div>\n"; + print "<table cellspacing=\"0\">\n"; + $/ = "\0"; + open my $fd, "-|", "$gitbin/git-rev-list --header $hash"; + my $alternate = 0; + while (my $commit_text = <$fd>) { + if (!grep m/$searchtext/, $commit_text) { + next; + } + my @commit_lines = split "\n", $commit_text; + my $commit = shift @commit_lines; + my %co = git_read_commit($commit, \@commit_lines); + if (!%co) { + next; + } + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/^(.*)($searchtext)(.*)$/) { + my $lead = escapeHTML($1) || ""; + $lead = chop_str($lead, 30, 10); + my $match = escapeHTML($2) || ""; + my $trail = escapeHTML($3) || ""; + $trail = chop_str($trail, 30, 10); + my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail"; + print chop_str($text, 80, 5) . "<br/>\n"; + } + } + print "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree"); + print "</td>\n" . + "</tr>\n"; + } + close $fd; + + $/ = "\n"; + open $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext"; + undef %co; + my @files; + while (my $line = <$fd>) { + if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) { + my %set; + $set{'file'} = $6; + $set{'from_id'} = $3; + $set{'to_id'} = $4; + $set{'id'} = $set{'to_id'}; + if ($set{'id'} =~ m/0{40}/) { + $set{'id'} = $set{'from_id'}; + } + if ($set{'id'} =~ m/0{40}/) { + next; + } + push @files, \%set; + } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){ + if (%co) { + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . + escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + while (my $setref = shift @files) { + my %set = %$setref; + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"}, + escapeHTML($set{'file'})) . "<br/>\n"; + } + print "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree"); + print "</td>\n" . + "</tr>\n"; + } + %co = git_read_commit($1); + } + } + print "</table>\n"; + close $fd; + git_footer_html(); +} + +sub git_shortlog { + my $head = git_read_hash("$project/HEAD"); + if (!defined $hash) { + $hash = $head; + } + + git_header_html(); + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | shortlog" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n"; + if ($hash ne $head) { + print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD") . " ⋅ "; + } + print $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "100") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=1;h=$hash"}, "day") . + " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=7;h=$hash"}, "week") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=31;h=$hash"}, "month") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=365;h=$hash"}, "year") . + " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=0;h=$hash"}, "all") . + "<br/>\n" . + "</div>\n"; + my $limit = ""; + if (defined $time_back) { + if ($time_back) { + $limit = sprintf(" --max-age=%i", time - 60*60*24*$time_back); + } + } else { + $limit = " --max-count=100"; + } + open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . + "</div>\n"; + print "<table cellspacing=\"0\">\n"; + if (!@revlist) { + my %co = git_read_commit($hash); + print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; + } + my $alternate = 0; + foreach my $commit (@revlist) { + my %co = git_read_commit($commit); + my %ad = date_str($co{'author_epoch'}); + if ($alternate) { + print "<tr style=\"background-color:#f6f5ed\">\n"; + } else { + print "<tr>\n"; + } + $alternate ^= 1; + print "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . + "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . + escapeHTML($co{'title_short'}) . "</b>") . "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . + "</td>\n" . + "</tr>"; + } + print "</table\n>"; + git_footer_html(); +} From dcea8d0b8478e6b108174cce8e1411b6432237ef Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:26:38 +0200 Subject: [PATCH 066/148] v205 --- gitweb.cgi | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 821766cc295..408d9d1e6ec 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "203"; +my $version = "205"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -1323,7 +1323,7 @@ sub git_commit { if (!defined $co{'parent'}) { $root = " --root"; } - open my $fd, "-|", "$gitbin/git-diff-tree -r $root $co{'parent'} $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $co{'parent'} $hash" or die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); git_header_html(); @@ -1376,7 +1376,7 @@ sub git_commit { "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, "commit") . - " |" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") . "</td>" . "</tr>\n"; } @@ -1415,13 +1415,14 @@ sub git_commit { foreach my $line (@difftree) { # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c' # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c' - $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; + $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/; my $from_mode = $1; my $to_mode = $2; my $from_id = $3; my $to_id = $4; my $status = $5; - my $file = $6; + my $percentage = int $6; + my $file = $7; #print "$line ($status)<br/>\n"; if ($alternate) { print "<tr style=\"background-color:#f6f5ed\">\n"; @@ -1477,6 +1478,23 @@ sub git_commit { } print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n"; print "</td>\n"; + } elsif ($status eq "R") { + my ($from_file, $to_file) = split "\t", $file; + my $mode_chng = ""; + if ($from_mode != $to_mode) { + $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777); + } + print "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML($to_file)) . "</td>\n" . + "<td><span style=\"color: #777777;\">[moved from " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML($from_file)) . + " with $percentage% similarity$mode_chng]</span></td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob"); + if ($to_id ne $from_id) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file"}, "diff"); + } + print "</td>\n"; } print "</tr>\n"; } From ea4a6df4089f6cfba0e6c6c50290ed18033f641b Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:26:49 +0200 Subject: [PATCH 067/148] v206 --- gitweb.cgi | 106 +++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 408d9d1e6ec..f096f40d934 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "205"; +my $version = "206"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -109,11 +109,11 @@ if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) { die_error(undef, "Invalid parent hash parameter."); } -my $time_back = $cgi->param('t'); -if (defined $time_back) { - if ($time_back =~ m/^[^0-9]+$/) { - undef $time_back; - die_error(undef, "Invalid time parameter."); +my $page = $cgi->param('pg'); +if (defined $page) { + if ($page =~ m/^[^0-9]+$/) { + undef $page; + die_error(undef, "Invalid page parameter."); } } @@ -1232,17 +1232,9 @@ sub git_log { if (!defined $hash) { $hash = $head; } - my $limit_option = ""; - if (!defined $time_back) { - $limit_option = "--max-count=100"; - } elsif ($time_back > 0) { - my $date = time - $time_back*24*60*60; - $limit_option = "--max-age=$date"; + if (!defined $page) { + $page = 0; } - open my $fd, "-|", "$gitbin/git-rev-list $limit_option $hash" or die_error(undef, "Open failed."); - my (@revlist) = map { chomp; $_ } <$fd>; - close $fd or die_error(undef, "Reading rev-list failed."); - git_header_html(); print "<div class=\"page_nav\">\n"; print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . @@ -1251,15 +1243,27 @@ sub git_log { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n"; - if ($hash ne $head) { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD") . " ⋅ "; + + my $limit = sprintf("--max-count=%i", (100 * ($page+1))); + open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + + if ($hash ne $head || $page) { + print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + } else { + print "HEAD"; + } + if ($page > 0) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p"}, "prev"); + } else { + print " ⋅ prev"; + } + if ($#revlist >= (100 * ($page+1)-1)) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n"}, "next"); + } else { + print " ⋅ next"; } - print $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "100") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=1;h=$hash"}, "day") . - " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=log;t=7;h=$hash"}, "week") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=31;h=$hash"}, "month") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=365;h=$hash"}, "year") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0;h=$hash"}, "all"); print "<br/>\n" . "</div>\n"; if (!@revlist) { @@ -1421,7 +1425,7 @@ sub git_commit { my $from_id = $3; my $to_id = $4; my $status = $5; - my $percentage = int $6; + my $similarity = $6; my $file = $7; #print "$line ($status)<br/>\n"; if ($alternate) { @@ -1488,7 +1492,7 @@ sub git_commit { $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML($to_file)) . "</td>\n" . "<td><span style=\"color: #777777;\">[moved from " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML($from_file)) . - " with $percentage% similarity$mode_chng]</span></td>\n" . + " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob"); if ($to_id ne $from_id) { @@ -1845,7 +1849,9 @@ sub git_shortlog { if (!defined $hash) { $hash = $head; } - + if (!defined $page) { + $page = 0; + } git_header_html(); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . @@ -1854,38 +1860,36 @@ sub git_shortlog { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n"; - if ($hash ne $head) { - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD") . " ⋅ "; - } - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "100") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=1;h=$hash"}, "day") . - " ⋅ " .$cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=7;h=$hash"}, "week") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=31;h=$hash"}, "month") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=365;h=$hash"}, "year") . - " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;t=0;h=$hash"}, "all") . - "<br/>\n" . - "</div>\n"; - my $limit = ""; - if (defined $time_back) { - if ($time_back) { - $limit = sprintf(" --max-age=%i", time - 60*60*24*$time_back); - } - } else { - $limit = " --max-count=100"; - } + + my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; + + if ($hash ne $head || $page) { + print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + } else { + print "HEAD"; + } + if ($page > 0) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p"}, "prev"); + } else { + print " ⋅ prev"; + } + if ($#revlist >= (100 * ($page+1)-1)) { + print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n"}, "next"); + } else { + print " ⋅ next"; + } + print "<br/>\n" . + "</div>\n"; print "<div>\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; - if (!@revlist) { - my %co = git_read_commit($hash); - print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; - } my $alternate = 0; - foreach my $commit (@revlist) { + for (my $i = ($page * 100); $i <= $#revlist; $i++) { + my $commit = $revlist[$i]; my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); if ($alternate) { From c994d620cc841e0eff036b6a89cdf31ca1a88950 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:27:18 +0200 Subject: [PATCH 068/148] v220 --- gitweb.cgi | 364 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 232 insertions(+), 132 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index f096f40d934..29a946a96e2 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -# gitweb.pl - simple web interface to track changes in git repositories +# 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> @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "206"; +my $version = "220"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -49,6 +49,9 @@ if (defined $action) { if ($action eq "git-logo.png") { git_logo(); exit; + } elsif ($action eq "opml") { + git_opml(); + exit; } } else { $action = "summary"; @@ -198,6 +201,8 @@ sub git_header_html { <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> --> <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"> @@ -228,16 +233,20 @@ div.log_link { } div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } a.list { text-decoration:none; color:#000000; } -a.list:hover { color:#880000; } +a.list:hover { text-decoration:underline; color:#880000; } table { padding:8px 4px; } th { padding:2px 5px; font-size:12px; text-align:left; } +tr.light:hover { background-color:#edece6; } +tr.dark { background-color:#f6f6f0; } +tr.dark:hover { background-color:#edece6; } td { padding:2px 5px; font-size:12px; vertical-align:top; } td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } div.pre { font-family:monospace; font-size:12px; white-space:pre; } div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } -input.search { margin:4px 8px; position:absolute; top:56px; right:12px } -a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; +div.search { margin:4px 8px; position:absolute; top:56px; right:12px } +a.rss_logo { + float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; color:#ffffff; background-color:#ff6600; font-weight:bold; font-family:sans-serif; font-size:10px; @@ -249,7 +258,7 @@ a.rss_logo:hover { background-color:#ee5500; } <body> EOF print "<div class=\"page_header\">\n" . - "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\">" . + "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" . "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . "</a>\n"; print $cgi->a({-href => $home_link}, "projects") . " / "; @@ -263,13 +272,13 @@ EOF $searchtext = ""; } $cgi->param("a", "search"); - # post search form, but fake get parameter in browser - #print $cgi->startform(-name => "search", -action => "$my_uri", - # -onsubmit => "document.search.action='?p=$project;a=search;s='+document.search.s.value") . - # $cgi->hidden(-name => "p") . "\n" . - # $cgi->hidden(-name => "a") . "\n" . - # $cgi->textfield(-name => "s", -value => $searchtext, -class => "search") . - # $cgi->end_form() . "\n"; + print $cgi->startform(-method => "get", -action => "$my_uri") . + "<div class=\"search\">\n" . + $cgi->hidden(-name => "p") . "\n" . + $cgi->hidden(-name => "a") . "\n" . + $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . + "</div>" . + $cgi->end_form() . "\n"; } print "</div>\n"; } @@ -282,6 +291,8 @@ sub git_footer_html { print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; } print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n"; + } else { + print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "RSS") . "\n"; } print "</div>\n" . "</body>\n" . @@ -630,7 +641,7 @@ sub get_file_owner { return $owner; } -sub git_project_list { +sub git_read_projects { my @list; if (-d $projects_list) { @@ -670,12 +681,15 @@ sub git_project_list { } close $fd; } + @list = sort {$a->{'path'} cmp $b->{'path'}} @list; + return @list; +} +sub git_project_list { + my @list = git_read_projects(); 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"; @@ -711,9 +725,9 @@ sub git_project_list { $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; } if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . @@ -830,9 +844,9 @@ sub git_summary { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; if ($i-- > 0) { @@ -866,9 +880,9 @@ sub git_summary { foreach my $entry (@$taglist) { my %tag = %$entry; if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; if ($i-- > 0) { @@ -905,9 +919,9 @@ sub git_summary { foreach my $entry (@$branchlist) { my %tag = %$entry; if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; if ($i-- > 0) { @@ -954,9 +968,9 @@ sub git_tags { foreach my $entry (@$taglist) { my %tag = %$entry; if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . @@ -1000,9 +1014,9 @@ sub git_branches { foreach my $entry (@$taglist) { my %tag = %$entry; if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . @@ -1162,17 +1176,17 @@ sub git_tree { my $t_name = $4; $file_key = ";f=$base$t_name"; if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { print "<td class=\"list\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) . - "</td>\n"; - print "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) . + "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . "</td>\n"; @@ -1180,7 +1194,9 @@ sub git_tree { print "<td class=\"list\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "</td>\n" . - "<td></td>\n"; + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, "tree") . + "</td>\n"; } print "</tr>\n"; } @@ -1227,6 +1243,40 @@ sub git_rss { print "</channel></rss>"; } +sub git_opml { + my @list = git_read_projects(); + + print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); + print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". + "<opml version=\"1.0\">\n". + "<head>". + " <title>Git OPML Export</title>\n". + "</head>\n". + "<body>\n". + "<outline text=\"git RSS feeds\">\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"; + my %co = git_read_commit($head); + if (!%co) { + next; + } + + my $path = escapeHTML(chop_str($proj{'path'}, 25, 5)); + my $rss = "$my_url?p=$proj{'path'};a=rss"; + my $html = "$my_url?p=$proj{'path'};a=log"; + print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n"; + } + print "</outline>\n". + "</body>\n". + "</opml>\n"; +} + sub git_log { my $head = git_read_hash("$project/HEAD"); if (!defined $hash) { @@ -1250,17 +1300,19 @@ sub git_log { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { - print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p"}, "prev"); + print " ⋅ " . + $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { - print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n"}, "next"); + print " ⋅ " . + $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } @@ -1273,7 +1325,8 @@ sub git_log { my %co = git_read_commit($hash); print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; } - foreach my $commit (@revlist) { + for (my $i = ($page * 100); $i <= $#revlist; $i++) { + my $commit = $revlist[$i]; my %co = git_read_commit($commit); next if !%co; my %ad = date_str($co{'author_epoch'}); @@ -1429,9 +1482,9 @@ sub git_commit { my $file = $7; #print "$line ($status)<br/>\n"; if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; if ($status eq "N") { @@ -1641,7 +1694,18 @@ sub git_commitdiff_plain { my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); + my %co = git_read_commit($hash); + my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + my $comment = $co{'comment'}; + print "Author: $co{'author'}\n" . + "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n". + "Source: $my_url?p=$project;a=commitdiff;h=$hash\n" . + "\n"; + foreach my $line (@$comment) {; + print " $line\n"; + } + print "\n"; foreach my $line (@difftree) { $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; my $from_id = $3; @@ -1696,9 +1760,9 @@ sub git_history { next; } if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; print "<td><i>$co{'age_string'}</i></td>\n" . @@ -1711,7 +1775,9 @@ sub git_history { my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"}, "diff to current"); + print " | " . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"}, + "diff to current"); } print "</td>\n" . "</tr>\n"; @@ -1734,6 +1800,20 @@ sub git_search { if (!%co) { die_error(undef, "Unknown commit object."); } + # pickaxe may take all resources of your box and run for several minutes + # with every query - so decide by yourself how public you make this feature :) + my $commit_search = 1; + my $author_search = 0; + my $committer_search = 0; + my $pickaxe_search = 0; + if ($searchtext =~ s/^author\\://i) { + $author_search = 1; + } elsif ($searchtext =~ s/^committer\\://i) { + $committer_search = 1; + } elsif ($searchtext =~ s/^pickaxe\\://i) { + $commit_search = 0; + $pickaxe_search = 1; + } git_header_html(); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary;h=$hash"}, "summary") . @@ -1749,98 +1829,109 @@ sub git_search { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<table cellspacing=\"0\">\n"; - $/ = "\0"; - open my $fd, "-|", "$gitbin/git-rev-list --header $hash"; my $alternate = 0; - while (my $commit_text = <$fd>) { - if (!grep m/$searchtext/, $commit_text) { - next; - } - my @commit_lines = split "\n", $commit_text; - my $commit = shift @commit_lines; - my %co = git_read_commit($commit, \@commit_lines); - if (!%co) { - next; - } - if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; - } else { - print "<tr>\n"; - } - $alternate ^= 1; - print "<td><i>$co{'age_string'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . - "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - if ($line =~ m/^(.*)($searchtext)(.*)$/) { - my $lead = escapeHTML($1) || ""; - $lead = chop_str($lead, 30, 10); - my $match = escapeHTML($2) || ""; - my $trail = escapeHTML($3) || ""; - $trail = chop_str($trail, 30, 10); - my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail"; - print chop_str($text, 80, 5) . "<br/>\n"; - } - } - print "</td>\n" . - "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree"); - print "</td>\n" . - "</tr>\n"; - } - close $fd; - - $/ = "\n"; - open $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext"; - undef %co; - my @files; - while (my $line = <$fd>) { - if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) { - my %set; - $set{'file'} = $6; - $set{'from_id'} = $3; - $set{'to_id'} = $4; - $set{'id'} = $set{'to_id'}; - if ($set{'id'} =~ m/0{40}/) { - $set{'id'} = $set{'from_id'}; - } - if ($set{'id'} =~ m/0{40}/) { + if ($commit_search) { + $/ = "\0"; + open my $fd, "-|", "$gitbin/git-rev-list --header $hash"; + while (my $commit_text = <$fd>) { + if (!grep m/$searchtext/i, $commit_text) { next; } - push @files, \%set; - } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){ - if (%co) { - if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; - } else { - print "<tr>\n"; - } - $alternate ^= 1; - print "<td><i>$co{'age_string'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . - "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . - escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); - while (my $setref = shift @files) { - my %set = %$setref; - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"}, - escapeHTML($set{'file'})) . "<br/>\n"; - } - print "</td>\n" . - "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree"); - print "</td>\n" . - "</tr>\n"; + if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) { + next; } - %co = git_read_commit($1); + if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) { + next; + } + my @commit_lines = split "\n", $commit_text; + my $commit = shift @commit_lines; + my %co = git_read_commit($commit, \@commit_lines); + if (!%co) { + next; + } + if ($alternate) { + print "<tr class=\"dark\">\n"; + } else { + print "<tr class=\"light\">\n"; + } + $alternate ^= 1; + print "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/^(.*)($searchtext)(.*)$/i) { + my $lead = escapeHTML($1) || ""; + $lead = chop_str($lead, 30, 10); + my $match = escapeHTML($2) || ""; + my $trail = escapeHTML($3) || ""; + $trail = chop_str($trail, 30, 10); + my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail"; + print chop_str($text, 80, 5) . "<br/>\n"; + } + } + print "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree"); + print "</td>\n" . + "</tr>\n"; } + close $fd; + } + + if ($pickaxe_search) { + $/ = "\n"; + open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext"; + undef %co; + my @files; + while (my $line = <$fd>) { + if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) { + my %set; + $set{'file'} = $6; + $set{'from_id'} = $3; + $set{'to_id'} = $4; + $set{'id'} = $set{'to_id'}; + if ($set{'id'} =~ m/0{40}/) { + $set{'id'} = $set{'from_id'}; + } + if ($set{'id'} =~ m/0{40}/) { + next; + } + push @files, \%set; + } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){ + if (%co) { + if ($alternate) { + print "<tr class=\"dark\">\n"; + } else { + print "<tr class=\"light\">\n"; + } + $alternate ^= 1; + print "<td><i>$co{'age_string'}</i></td>\n" . + "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . + escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + while (my $setref = shift @files) { + my %set = %$setref; + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"}, + "<span style=\"color:#e00000\">" . escapeHTML($set{'file'}) . "</span>") . + "<br/>\n"; + } + print "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree"); + print "</td>\n" . + "</tr>\n"; + } + %co = git_read_commit($1); + } + } + close $fd; } print "</table>\n"; - close $fd; git_footer_html(); } @@ -1872,12 +1963,14 @@ sub git_shortlog { print "HEAD"; } if ($page > 0) { - print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p"}, "prev"); + print " ⋅ " . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { - print " ⋅ " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n"}, "next"); + print " ⋅ " . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } @@ -1893,9 +1986,9 @@ sub git_shortlog { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); if ($alternate) { - print "<tr style=\"background-color:#f6f5ed\">\n"; + print "<tr class=\"dark\">\n"; } else { - print "<tr>\n"; + print "<tr class=\"light\">\n"; } $alternate ^= 1; print "<td><i>$co{'age_string'}</i></td>\n" . @@ -1908,6 +2001,13 @@ sub git_shortlog { "</td>\n" . "</tr>"; } + if ($#revlist >= (100 * ($page+1)-1)) { + print "<tr>\n" . + "<td>" . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -title => "Alt-n"}, "next") . + "</td>\n" . + "</tr>\n"; + } print "</table\n>"; git_footer_html(); } From 71be1e7948e1ce9ba91b40bf758666cd8f9db610 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:27:27 +0200 Subject: [PATCH 069/148] v225 --- gitweb.cgi | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 29a946a96e2..17737ff4198 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "220"; +my $version = "225"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -245,6 +245,7 @@ div.pre { font-family:monospace; font-size:12px; white-space:pre; } div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } div.search { margin:4px 8px; position:absolute; top:56px; right:12px } +a.linenr { color:#999999; text-decoration:none } a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; @@ -463,6 +464,14 @@ sub git_read_commit { } else { $co{'age_string'} .= " right now"; } + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'}); + if ($age > 60*60*24*7*2) { + $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday; + $co{'age_string_age'} = $co{'age_string'}; + } else { + $co{'age_string_date'} = $co{'age_string'}; + $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday; + } return %co; } @@ -1104,7 +1113,7 @@ sub git_blob { $line =~ s/\t/$spaces/; } } - printf "<div class=\"pre\"><span style=\"color:#999999;\">%4i</span> %s</div>\n", $nr, escapeHTML($line); + printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, escapeHTML($line); } close $fd or print "Reading blob failed.\n"; print "</div>"; @@ -1216,7 +1225,7 @@ sub git_rss { "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n"; print "<channel>\n"; print "<title>$project</title>\n". - "<link>" . escapeHTML("$my_url/$project/log") . "</link>\n". + "<link>" . escapeHTML("$my_url?p=$project;a=summary") . "</link>\n". "<description>$project log</description>\n". "<language>en</language>\n"; @@ -1269,7 +1278,7 @@ sub git_opml { my $path = escapeHTML(chop_str($proj{'path'}, 25, 5)); my $rss = "$my_url?p=$proj{'path'};a=rss"; - my $html = "$my_url?p=$proj{'path'};a=log"; + my $html = "$my_url?p=$proj{'path'};a=summary"; print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n"; } print "</outline>\n". @@ -1765,7 +1774,7 @@ sub git_history { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td><i>$co{'age_string'}</i></td>\n" . + print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . @@ -1855,7 +1864,7 @@ sub git_search { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td><i>$co{'age_string'}</i></td>\n" . + print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); @@ -1908,7 +1917,7 @@ sub git_search { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td><i>$co{'age_string'}</i></td>\n" . + print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . @@ -1991,7 +2000,7 @@ sub git_shortlog { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td><i>$co{'age_string'}</i></td>\n" . + print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title_short'}) . "</b>") . "</td>\n" . From 4fac5294de00025e1b5788140788b713a640a300 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:27:38 +0200 Subject: [PATCH 070/148] v227 --- gitweb.cgi | 70 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 17737ff4198..9a45684806e 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "225"; +my $version = "227"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -53,8 +53,6 @@ if (defined $action) { git_opml(); exit; } -} else { - $action = "summary"; } my $project = $cgi->param('p'); @@ -76,7 +74,7 @@ if (defined $project) { die_error(undef, "No such project."); } $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; - $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; + $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); exit; @@ -95,9 +93,15 @@ if (defined $file_name) { } my $hash = $cgi->param('h'); -if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { - undef $hash; - die_error(undef, "Invalid hash parameter."); +if (defined $hash) { + if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $hash; + die_error(undef, "Non-canonical hash parameter."); + } + if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { + undef $hash; + die_error(undef, "Invalid character in hash parameter."); + } } my $hash_parent = $cgi->param('hp'); @@ -120,7 +124,6 @@ if (defined $page) { } } - my $searchtext = $cgi->param('s'); if (defined $searchtext) { if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { @@ -130,7 +133,7 @@ if (defined $searchtext) { $searchtext = quotemeta $searchtext; } -if ($action eq "summary") { +if (!defined $action || $action eq "summary") { git_summary(); exit; } elsif ($action eq "branches") { @@ -722,7 +725,7 @@ sub git_project_list { if (!defined $head) { next; } - $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects"; + $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}"; my %co = git_read_commit($head); if (!%co) { next; @@ -766,8 +769,23 @@ sub git_read_refs { my $ref_dir = shift; my @reflist; + my @refs; opendir my $dh, "$projectroot/$project/$ref_dir"; - my @refs = grep !m/^\./, readdir $dh; + while (my $dir = readdir($dh)) { + if ($dir =~ m/^\./) { + next; + } + if (-d "$projectroot/$project/$ref_dir/$dir") { + opendir my $dh2, "$projectroot/$project/$ref_dir/$dir"; + my @subdirs = grep !m/^\./, readdir $dh2; + closedir($dh2); + foreach my $subdir (@subdirs) { + push @refs, "$dir/$subdir" + } + next; + } + push @refs, $dir; + } closedir($dh); foreach my $ref_file (@refs) { my $ref_id = git_read_hash("$project/$ref_dir/$ref_file"); @@ -897,14 +915,14 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'name'}"}, $tag{'type'}); if ($tag{'type'} eq "commit") { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log"); } print "</td>\n" . "</tr>"; @@ -936,12 +954,12 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}", -class => "list"}, + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") . "</td>\n" . "</tr>"; } else { @@ -984,14 +1002,14 @@ sub git_tags { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'name'}"}, $tag{'type'}); if ($tag{'type'} eq "commit") { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log"); } print "</td>\n" . "</tr>"; @@ -1030,11 +1048,11 @@ sub git_branches { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") . "</td>\n" . "</tr>"; } @@ -1270,7 +1288,7 @@ sub git_opml { if (!defined $head) { next; } - $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$proj{'path'}/objects"; + $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}"; my %co = git_read_commit($head); if (!%co) { next; From d05c19eeb2cc9341ba3e9b629d99b87cdb1e4bb9 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:27:49 +0200 Subject: [PATCH 071/148] v229 --- gitweb.cgi | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 9a45684806e..0e2a9602c44 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "227"; +my $version = "229"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -94,13 +94,24 @@ if (defined $file_name) { my $hash = $cgi->param('h'); if (defined $hash) { - if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) { - undef $hash; - die_error(undef, "Non-canonical hash parameter."); - } - if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { - undef $hash; - die_error(undef, "Invalid character in hash parameter."); + if (!($hash =~ m/^[0-9a-fA-F]{40}$/)) { + if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $hash; + die_error(undef, "Non-canonical hash parameter."); + } + if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { + undef $hash; + die_error(undef, "Invalid character in hash parameter."); + } + # replace branch-name with hash + my $branchlist = git_read_refs("refs/heads"); + foreach my $entry (@$branchlist) { + my %branch = %$entry; + if ($branch{'name'} eq $hash) { + $hash = $branch{'id'}; + last; + } + } } } @@ -915,14 +926,14 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'name'}", -class => "list"}, "<b>" . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'name'}"}, $tag{'type'}); + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); if ($tag{'type'} eq "commit") { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); } print "</td>\n" . "</tr>"; @@ -1002,14 +1013,14 @@ sub git_tags { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, + $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'name'}"}, $tag{'type'}); + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); if ($tag{'type'} eq "commit") { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); } print "</td>\n" . "</tr>"; @@ -1777,7 +1788,7 @@ sub git_history { print "<table cellspacing=\"0\">\n"; my $alternate = 0; while (my $line = <$fd>) { - if ($line =~ m/^([0-9a-fA-F]{40}) /){ + if ($line =~ m/^([0-9a-fA-F]{40})/){ $commit = $1; next; } From 1b1cd421826c07a98936385664934887f88ef159 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:28:01 +0200 Subject: [PATCH 072/148] v232 --- gitweb.cgi | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 0e2a9602c44..87088f9a28b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "229"; +my $version = "232"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -480,11 +480,11 @@ sub git_read_commit { } my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'}); if ($age > 60*60*24*7*2) { - $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday; + $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday; $co{'age_string_age'} = $co{'age_string'}; } else { $co{'age_string_date'} = $co{'age_string'}; - $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon, $mday; + $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday; } return %co; } @@ -1732,18 +1732,44 @@ sub git_commitdiff_plain { my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); + # try to figure out the next tag after this commit + my $tagname; + my %taghash; + my $tags = git_read_refs("refs/tags"); + foreach my $entry (@$tags) { + my %tag = %$entry; + $taghash{$tag{'id'}} = $tag{'name'}; + } + open $fd, "-|", "$gitbin/git-rev-list HEAD"; + while (my $commit = <$fd>) { + chomp $commit; + if ($taghash{$commit}) { + $tagname = $taghash{$commit}; + } + if ($commit eq $hash) { + last; + } + } + close $fd; + + print $cgi->header(-type => "text/plain", -charset => 'utf-8'); my %co = git_read_commit($hash); my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); - print $cgi->header(-type => "text/plain", -charset => 'utf-8'); my $comment = $co{'comment'}; - print "Author: $co{'author'}\n" . + print "From: $co{'author'}\n" . "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n". - "Source: $my_url?p=$project;a=commitdiff;h=$hash\n" . + "Subject: $co{'title'}\n"; + if (defined $tagname) { + print "X-Git-Tag: $tagname\n"; + } + print "X-Git-Url: $my_url?p=$project;a=commitdiff;h=$hash\n" . "\n"; + foreach my $line (@$comment) {; print " $line\n"; } - print "\n"; + print "---\n\n"; + foreach my $line (@difftree) { $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/; my $from_id = $3; From f6375b2452894f0e1ac156a1fcc30fcbaf54f360 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:28:33 +0200 Subject: [PATCH 073/148] v233 --- gitweb.cgi | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 87088f9a28b..6c4ed7472ac 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "232"; +my $version = "233"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -1496,7 +1496,9 @@ sub git_commit { print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { $signed = 0; - print escapeHTML($line) . "<br/>\n"; + $line = escapeHTML($line); + $line =~ s/ / /g; + print "$line<br/>\n"; } } print "</div>\n"; @@ -1525,7 +1527,7 @@ sub git_commit { print "<tr class=\"light\">\n"; } $alternate ^= 1; - if ($status eq "N") { + if ($status eq "A") { my $mode_chng = ""; if (S_ISREG(oct $to_mode)) { $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); @@ -1687,7 +1689,9 @@ sub git_commitdiff { } else { $empty = 0; } - print escapeHTML($line) . "<br/>\n"; + $line = escapeHTML($line); + $line =~ s/ / /g; + print "$line<br/>\n"; } print "<br/>\n"; foreach my $line (@difftree) { @@ -1700,7 +1704,7 @@ sub git_commitdiff { my $to_id = $4; my $status = $5; my $file = $6; - if ($status eq "N") { + if ($status eq "A") { print "<div class=\"diff_info\">" . file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" . "</div>\n"; @@ -1776,7 +1780,7 @@ sub git_commitdiff_plain { my $to_id = $4; my $status = $5; my $file = $6; - if ($status eq "N") { + if ($status eq "A") { git_diff_print(undef, "/dev/null", $to_id, "b/$file", "plain"); } elsif ($status eq "D") { git_diff_print($from_id, "a/$file", undef, "/dev/null", "plain"); From f49201a9957b9dd13cc4c68038e9d701369feee1 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:28:42 +0200 Subject: [PATCH 074/148] v234 --- gitweb.cgi | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 6c4ed7472ac..30a62529003 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "233"; +my $version = "234"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -607,6 +607,21 @@ sub file_type { } } +sub format_log_line_html { + my $line = shift; + + $line = escapeHTML($line); + $line =~ s/ / /g; + if ($line =~ m/([0-9a-fA-F]{40})/) { + my $hash_text = $1; + if (git_get_type($hash_text) eq "commit") { + my $link = $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text); + $line =~ s/$hash_text/$link/; + } + } + return $line; +} + sub date_str { my $epoch = shift; my $tz = shift || "-0000"; @@ -1395,7 +1410,7 @@ sub git_log { } else { $empty = 0; } - print escapeHTML($line) . "<br/>\n"; + print format_log_line_html($line) . "<br/>\n"; } if (!$empty) { print "<br/>\n"; @@ -1496,9 +1511,7 @@ sub git_commit { print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; } else { $signed = 0; - $line = escapeHTML($line); - $line =~ s/ / /g; - print "$line<br/>\n"; + print format_log_line_html($line) . "<br/>\n"; } } print "</div>\n"; @@ -1689,9 +1702,7 @@ sub git_commitdiff { } else { $empty = 0; } - $line = escapeHTML($line); - $line =~ s/ / /g; - print "$line<br/>\n"; + print format_log_line_html($line) . "<br/>\n"; } print "<br/>\n"; foreach my $line (@difftree) { From d8a20ba9bc6a065b929310d1319ddd190671ba0b Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:28:53 +0200 Subject: [PATCH 075/148] v235 --- gitweb.cgi | 134 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 110 insertions(+), 24 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 30a62529003..7803f4dd5fd 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "234"; +my $version = "235"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -192,6 +192,9 @@ if (!defined $action || $action eq "summary") { } elsif ($action eq "shortlog") { git_shortlog(); exit; +} elsif ($action eq "tag") { + git_tag(); + exit; } else { undef $action; die_error(undef, "Unknown action."); @@ -248,6 +251,9 @@ div.log_link { div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } a.list { text-decoration:none; color:#000000; } a.list:hover { text-decoration:underline; color:#880000; } +a.text { text-decoration:none; color:#0000cc; } +a.text:visited { text-decoration:none; color:#880000; } +a.text:hover { text-decoration:underline; color:#880000; } table { padding:8px 4px; } th { padding:2px 5px; font-size:12px; text-align:left; } tr.light:hover { background-color:#edece6; } @@ -333,7 +339,7 @@ sub git_get_type { open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return; my $type = <$fd>; - close $fd; + close $fd or return; chomp $type; return $type; } @@ -363,8 +369,10 @@ sub git_read_description { sub git_read_tag { my $tag_id = shift; my %tag; + my @comment; open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return; + $tag{'id'} = $tag_id; while (my $line = <$fd>) { chomp $line; if ($line =~ m/^object ([0-9a-fA-F]{40})$/) { @@ -373,8 +381,19 @@ sub git_read_tag { $tag{'type'} = $1; } elsif ($line =~ m/^tag (.+)$/) { $tag{'name'} = $1; + } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) { + $tag{'author'} = $1; + $tag{'epoch'} = $2; + $tag{'tz'} = $3; + } elsif ($line =~ m/--BEGIN/) { + push @comment, $line; + last; + } elsif ($line eq "") { + last; } } + push @comment, <$fd>; + $tag{'comment'} = \@comment; close $fd or return; if (!defined $tag{'name'}) { return @@ -615,7 +634,7 @@ sub format_log_line_html { if ($line =~ m/([0-9a-fA-F]{40})/) { my $hash_text = $1; if (git_get_type($hash_text) eq "commit") { - my $link = $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text); + my $link = $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text); $line =~ s/$hash_text/$link/; } } @@ -818,20 +837,23 @@ sub git_read_refs { my $type = git_get_type($ref_id) || next; my %ref_item; my %co; + $ref_item{'type'} = $type; + $ref_item{'id'} = $ref_id; if ($type eq "tag") { my %tag = git_read_tag($ref_id); + $ref_item{'comment'} = $tag{'comment'}; if ($tag{'type'} eq "commit") { %co = git_read_commit($tag{'object'}); } - $ref_item{'type'} = $tag{'type'}; + $ref_item{'reftype'} = $tag{'type'}; $ref_item{'name'} = $tag{'name'}; - $ref_item{'id'} = $tag{'object'}; + $ref_item{'refid'} = $tag{'object'}; } elsif ($type eq "commit"){ %co = git_read_commit($ref_id); - $ref_item{'type'} = "commit"; + $ref_item{'reftype'} = "commit"; $ref_item{'name'} = $ref_file; $ref_item{'title'} = $co{'title'}; - $ref_item{'id'} = $ref_id; + $ref_item{'refid'} = $ref_id; } $ref_item{'epoch'} = $co{'committer_epoch'} || 0; $ref_item{'age'} = $co{'age_string'} || "unknown"; @@ -932,6 +954,11 @@ sub git_summary { my $alternate = 0; foreach my $entry (@$taglist) { my %tag = %$entry; + my $comment_lines = $tag{'comment'}; + my $comment = shift @$comment_lines; + if (defined($comment)) { + $comment = chop_str($comment, 30, 5); + } if ($alternate) { print "<tr class=\"dark\">\n"; } else { @@ -941,14 +968,22 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "<b>" . - escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"}, + "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . - "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); - if ($tag{'type'} eq "commit") { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); + "<td>"; + if (defined($comment)) { + print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment); + } + print "</td>\n" . + "<td class=\"link\">"; + if ($tag{'type'} eq "tag") { + print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | "; + } + print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'}); + if ($tag{'reftype'} eq "commit") { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log"); } print "</td>\n" . "</tr>"; @@ -999,6 +1034,41 @@ sub git_summary { git_footer_html(); } +sub git_tag { + my $head = git_read_hash("$project/HEAD"); + git_header_html(); + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" . + "<br/>\n" . + "</div>\n"; + my %tag = git_read_tag($hash); + print "<div>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($tag{'name'})) . "\n" . + "</div>\n"; + print "<div class=\"title_text\">\n" . + "<table cellspacing=\"0\">\n" . + "<tr><td>$tag{'type'}</td><td>" . $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'object'}) . "</td></tr>\n"; + if (defined($tag{'author'})) { + my %ad = date_str($tag{'epoch'}, $tag{'tz'}); + print "<tr><td>author</td><td>" . escapeHTML($tag{'author'}) . "</td></tr>\n"; + print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n"; + } + print "</table>\n\n" . + "</div>\n"; + print "<div class=\"page_body\">"; + my $comment = $tag{'comment'}; + foreach my $line (@$comment) { + print escapeHTML($line) . "<br/>\n"; + } + print "</div>\n"; + git_footer_html(); +} + sub git_tags { my $head = git_read_hash("$project/HEAD"); git_header_html(); @@ -1020,6 +1090,11 @@ sub git_tags { if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; + my $comment_lines = $tag{'comment'}; + my $comment = shift @$comment_lines; + if (defined($comment)) { + $comment = chop_str($comment, 30, 5); + } if ($alternate) { print "<tr class=\"dark\">\n"; } else { @@ -1028,14 +1103,22 @@ sub git_tags { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'id'}", -class => "list"}, + $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . - "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}); - if ($tag{'type'} eq "commit") { + "<td>"; + if (defined($comment)) { + print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment); + } + print "</td>\n" . + "<td class=\"link\">"; + if ($tag{'type'} eq "tag") { + print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | "; + } + print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'}); + if ($tag{'reftype'} eq "commit") { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log"); } print "</td>\n" . "</tr>"; @@ -1430,10 +1513,12 @@ sub git_commit { my @difftree; my $root = ""; - if (!defined $co{'parent'}) { + my $parent = $co{'parent'}; + if (!defined $parent) { $root = " --root"; + $parent = ""; } - open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $co{'parent'} $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); git_header_html(); @@ -1525,7 +1610,9 @@ sub git_commit { foreach my $line (@difftree) { # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c' # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c' - $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/; + if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) { + next; + } my $from_mode = $1; my $to_mode = $2; my $from_id = $3; @@ -1533,7 +1620,6 @@ sub git_commit { my $status = $5; my $similarity = $6; my $file = $7; - #print "$line ($status)<br/>\n"; if ($alternate) { print "<tr class=\"dark\">\n"; } else { @@ -1753,7 +1839,7 @@ sub git_commitdiff_plain { my $tags = git_read_refs("refs/tags"); foreach my $entry (@$tags) { my %tag = %$entry; - $taghash{$tag{'id'}} = $tag{'name'}; + $taghash{$tag{'refid'}} = $tag{'name'}; } open $fd, "-|", "$gitbin/git-rev-list HEAD"; while (my $commit = <$fd>) { From d263a6bd453df849c9f9211f1966c830c3cf913a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 20:29:03 +0200 Subject: [PATCH 076/148] v236 --- gitweb.cgi | 71 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 7803f4dd5fd..695caddb8e5 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,13 +15,14 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "235"; +my $version = "236"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; # absolute fs-path which will be prepended to the project path my $projectroot = "/pub/scm"; +$projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries my $gitbin = "/usr/bin"; @@ -401,6 +402,37 @@ sub git_read_tag { return %tag } +sub age_string { + my $age = shift; + my $age_str; + + if ($age > 60*60*24*365*2) { + $age_str = (int $age/60/60/24/365); + $age_str .= " years ago"; + } elsif ($age > 60*60*24*(365/12)*2) { + $age_str = int $age/60/60/24/(365/12); + $age_str .= " months ago"; + } elsif ($age > 60*60*24*7*2) { + $age_str = int $age/60/60/24/7; + $age_str .= " weeks ago"; + } elsif ($age > 60*60*24*2) { + $age_str = int $age/60/60/24; + $age_str .= " days ago"; + } elsif ($age > 60*60*2) { + $age_str = int $age/60/60; + $age_str .= " hours ago"; + } elsif ($age > 60*2) { + $age_str = int $age/60; + $age_str .= " min ago"; + } elsif ($age > 2) { + $age_str = int $age; + $age_str .= " sec ago"; + } else { + $age_str .= " right now"; + } + return $age_str; +} + sub git_read_commit { my $commit_id = shift; my $commit_text = shift; @@ -473,30 +505,7 @@ sub git_read_commit { my $age = time - $co{'committer_epoch'}; $co{'age'} = $age; - if ($age > 60*60*24*365*2) { - $co{'age_string'} = (int $age/60/60/24/365); - $co{'age_string'} .= " years ago"; - } elsif ($age > 60*60*24*(365/12)*2) { - $co{'age_string'} = int $age/60/60/24/(365/12); - $co{'age_string'} .= " months ago"; - } elsif ($age > 60*60*24*7*2) { - $co{'age_string'} = int $age/60/60/24/7; - $co{'age_string'} .= " weeks ago"; - } elsif ($age > 60*60*24*2) { - $co{'age_string'} = int $age/60/60/24; - $co{'age_string'} .= " days ago"; - } elsif ($age > 60*60*2) { - $co{'age_string'} = int $age/60/60; - $co{'age_string'} .= " hours ago"; - } elsif ($age > 60*2) { - $co{'age_string'} = int $age/60; - $co{'age_string'} .= " min ago"; - } elsif ($age > 2) { - $co{'age_string'} = int $age; - $co{'age_string'} .= " sec ago"; - } else { - $co{'age_string'} .= " right now"; - } + $co{'age_string'} = age_string($age); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'}); if ($age > 60*60*24*7*2) { $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday; @@ -839,11 +848,19 @@ sub git_read_refs { my %co; $ref_item{'type'} = $type; $ref_item{'id'} = $ref_id; + $ref_item{'epoch'} = 0; + $ref_item{'age'} = "unknown"; if ($type eq "tag") { my %tag = git_read_tag($ref_id); $ref_item{'comment'} = $tag{'comment'}; if ($tag{'type'} eq "commit") { %co = git_read_commit($tag{'object'}); + $ref_item{'epoch'} = $co{'committer_epoch'}; + $ref_item{'age'} = $co{'age_string'}; + } elsif (defined($tag{'epoch'})) { + my $age = time - $tag{'epoch'}; + $ref_item{'epoch'} = $tag{'epoch'}; + $ref_item{'age'} = age_string($age); } $ref_item{'reftype'} = $tag{'type'}; $ref_item{'name'} = $tag{'name'}; @@ -854,9 +871,9 @@ sub git_read_refs { $ref_item{'name'} = $ref_file; $ref_item{'title'} = $co{'title'}; $ref_item{'refid'} = $ref_id; + $ref_item{'epoch'} = $co{'committer_epoch'}; + $ref_item{'age'} = $co{'age_string'}; } - $ref_item{'epoch'} = $co{'committer_epoch'} || 0; - $ref_item{'age'} = $co{'age_string'} || "unknown"; push @reflist, \%ref_item; } From f5dfb3f6a6655d4d60fdd0aaeef7b5b14226147f Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 7 Aug 2005 22:39:58 +0200 Subject: [PATCH 077/148] add README Two files are better than one. :) --- README | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 00000000000..3014d7320bc --- /dev/null +++ b/README @@ -0,0 +1,16 @@ +GIT web Interface + +The one working on: + http://www.kernel.org/git/ + +Get the gitweb.cgi by ftp: + ftp://ftp.kernel.org/pub/software/scm/gitweb/ + +It reqires the git-core binaries installed on the system: + http://www.kernel.org/git/?p=git/git.git;a=summary + +The gitweb repository is here: + http://www.kernel.org/git/?p=git/gitweb.git;a=summary + +Any comment/question/concern to: + Kay Sievers <kay.sievers@vrfy.org> From e4669df9a6f638299ebab57cc87318a2a9e24b0c Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay@mam.(none)> Date: Mon, 8 Aug 2005 00:02:39 +0200 Subject: [PATCH 078/148] Make the tag view look like commit header. --- gitweb.cgi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 695caddb8e5..973702f094e 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "236"; +my $version = "237"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -1069,7 +1069,11 @@ sub git_tag { "</div>\n"; print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n" . - "<tr><td>$tag{'type'}</td><td>" . $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'object'}) . "</td></tr>\n"; + "<tr>\n" . + "<td>object</td>\n" . + "<td>" . $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'object'}) . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'type'}) . "</td>\n" . + "</tr>\n"; if (defined($tag{'author'})) { my %ad = date_str($tag{'epoch'}, $tag{'tz'}); print "<tr><td>author</td><td>" . escapeHTML($tag{'author'}) . "</td></tr>\n"; From f7ab660c15b5e3cb7fee035191e0cd5160bf8299 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay@mam.(none)> Date: Wed, 10 Aug 2005 03:53:09 +0200 Subject: [PATCH 079/148] allow sorting of index page by project path, owner and age --- gitweb.cgi | 100 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 36 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 973702f094e..b0b515efbb5 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "237"; +my $version = "238"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -56,6 +56,14 @@ if (defined $action) { } } +my $order = $cgi->param('o'); +if (defined $order) { + if ($order =~ m/[^a-zA-Z0-9_]/) { + undef $order; + die_error(undef, "Invalid order parameter."); + } +} + my $project = $cgi->param('p'); if (defined $project) { if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) { @@ -314,7 +322,7 @@ sub git_footer_html { } print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n"; } else { - print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "RSS") . "\n"; + print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "OPML") . "\n"; } print "</div>\n" . "</body>\n" . @@ -753,9 +761,30 @@ sub git_read_projects { sub git_project_list { my @list = git_read_projects(); + my @projects; if (!@list) { die_error(undef, "No project found."); } + foreach my $pr (@list) { + my $head = git_read_hash("$pr->{'path'}/HEAD"); + if (!defined $head) { + next; + } + $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}"; + my %co = git_read_commit($head); + if (!%co) { + next; + } + $pr->{'commit'} = \%co; + if (!defined $pr->{'descr'}) { + my $descr = git_read_description($pr->{'path'}) || ""; + $pr->{'descr'} = chop_str($descr, 25, 5); + } + if (!defined $pr->{'owner'}) { + $pr->{'owner'} = get_file_owner("$projectroot/$pr->{'path'}") || ""; + } + push @projects, $pr; + } git_header_html(); if (-f $home_text) { print "<div class=\"index_include\">\n"; @@ -765,53 +794,52 @@ sub git_project_list { print "</div>\n"; } print "<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"; + if (defined($order) && ($order eq "project")) { + @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects; + print "<th>Project</th>\n"; + } else { + print "<th>" . $cgi->a({-class => "list", -href => "$my_uri?o=project"}, "Project") . "</th>\n"; + } + print "<th>Description</th>\n"; + if (defined($order) && ($order eq "owner")) { + @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects; + print "<th>Owner</th>\n"; + } else { + print "<th>" . $cgi->a({-class => "list", -href => "$my_uri?o=owner"}, "Owner") . "</th>\n"; + } + if (defined($order) && ($order eq "age")) { + @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects; + print "<th>last change</th>\n"; + } else { + print "<th>" . $cgi->a({-class => "list", -href => "$my_uri?o=age"}, "last change") . "</th>\n"; + } + print "<th></th>\n" . "</tr>\n"; my $alternate = 0; - foreach my $pr (@list) { - my %proj = %$pr; - my $head = git_read_hash("$proj{'path'}/HEAD"); - if (!defined $head) { - next; - } - $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}"; - my %co = git_read_commit($head); - if (!%co) { - next; - } - my $descr = git_read_description($proj{'path'}) || ""; - $descr = chop_str($descr, 25, 5); - # get directory owner if not already specified - if (!defined $proj{'owner'}) { - $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; - } + foreach my $pr (@projects) { if ($alternate) { print "<tr class=\"dark\">\n"; } else { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td>" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "</td>\n" . - "<td>$descr</td>\n" . - "<td><i>" . chop_str($proj{'owner'}, 15) . "</i></td>\n"; + print "<td>" . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=summary", -class => "list"}, escapeHTML($pr->{'path'})) . "</td>\n" . + "<td>$pr->{'descr'}</td>\n" . + "<td><i>" . chop_str($pr->{'owner'}, 15) . "</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>"; + if ($pr->{'commit'}{'age'} < 60*60*2) { + $colored_age = "<span style =\"color: #009900;\"><b><i>$pr->{'commit'}{'age_string'}</i></b></span>"; + } elsif ($pr->{'commit'}{'age'} < 60*60*24*2) { + $colored_age = "<span style =\"color: #009900;\"><i>$pr->{'commit'}{'age_string'}</i></span>"; } else { - $colored_age = "<i>$co{'age_string'}</i>"; + $colored_age = "<i>$pr->{'commit'}{'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=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") . + $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=summary"}, "summary") . + " | " . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=shortlog"}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=log"}, "log") . "</td>\n" . "</tr>\n"; } From d8d17b5debd37a3f0e42eba2d69d375b74f20fe9 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay@mam.(none)> Date: Fri, 12 Aug 2005 21:43:32 +0200 Subject: [PATCH 080/148] make index page sorting more visible and increase RSS item count The RSS feed now shows 30 items + all items more recent than 48 hours but not more than 150. Let's see how that works... --- gitweb.cgi | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index b0b515efbb5..378fe2ea88a 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "238"; +my $version = "239"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -236,7 +236,7 @@ body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d 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; } -div.page_header a:visited { color:#0000cc; } +div.page_header a:visited, a.header { color:#0000cc; } div.page_header a:hover { color:#880000; } div.page_nav { padding:8px; } div.page_nav a:visited { color:#0000cc; } @@ -795,24 +795,29 @@ sub git_project_list { } print "<table cellspacing=\"0\">\n" . "<tr>\n"; - if (defined($order) && ($order eq "project")) { + if (!defined($order) || (defined($order) && ($order eq "project"))) { @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects; print "<th>Project</th>\n"; } else { - print "<th>" . $cgi->a({-class => "list", -href => "$my_uri?o=project"}, "Project") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=project"}, "Project") . "</th>\n"; + } + if (defined($order) && ($order eq "descr")) { + @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects; + print "<th>Description</th>\n"; + } else { + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=descr"}, "Description") . "</th>\n"; } - print "<th>Description</th>\n"; if (defined($order) && ($order eq "owner")) { @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects; print "<th>Owner</th>\n"; } else { - print "<th>" . $cgi->a({-class => "list", -href => "$my_uri?o=owner"}, "Owner") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=owner"}, "Owner") . "</th>\n"; } if (defined($order) && ($order eq "age")) { @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects; - print "<th>last change</th>\n"; + print "<th>Last Change</th>\n"; } else { - print "<th>" . $cgi->a({-class => "list", -href => "$my_uri?o=age"}, "last change") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=age"}, "Last Change") . "</th>\n"; } print "<th></th>\n" . "</tr>\n"; @@ -1392,10 +1397,9 @@ sub git_tree { sub git_rss { # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ - open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_hash("$project/HEAD") or die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_hash("$project/HEAD") 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'); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n"; @@ -1405,9 +1409,17 @@ sub git_rss { "<description>$project log</description>\n". "<language>en</language>\n"; - foreach my $commit (@revlist) { + for (my $i = 0; $i <= $#revlist; $i++) { + my $commit = $revlist[$i]; my %co = git_read_commit($commit); + # we read 150, we always show 30 and the ones more recent than 48 hours + if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) { + last; + } my %cd = date_str($co{'committer_epoch'}); + open $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $co{'id'}" or next; + my @difftree = map { chomp; $_ } <$fd>; + close $fd or next; print "<item>\n" . "<title>" . sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML($co{'title'}) . @@ -1421,6 +1433,14 @@ sub git_rss { foreach my $line (@$comment) { print "$line<br/>\n"; } + print "<br/>\n"; + foreach my $line (@difftree) { + if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) { + next; + } + my $file = $7; + print "$file<br/>\n"; + } print "]]>\n" . "</content:encoded>\n" . "</item>\n"; From 53b89d8ddb0ec0643ab0c14d5c251d1e7ffbc8cb Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay@mam.(none)> Date: Fri, 12 Aug 2005 22:12:58 +0200 Subject: [PATCH 081/148] fix search parsing, later git does not print a trailing space --- gitweb.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 378fe2ea88a..8d4e4f70220 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "239"; +my $version = "240"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -2134,7 +2134,7 @@ sub git_search { next; } push @files, \%set; - } elsif ($line =~ m/^([0-9a-fA-F]{40}) /){ + } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){ if (%co) { if ($alternate) { print "<tr class=\"dark\">\n"; From e00c9e18a7382209b158efdc0c600165cde295a5 Mon Sep 17 00:00:00 2001 From: Yasushi SHOJI <yashi@atmark-techno.com> Date: Thu, 18 Aug 2005 18:24:28 +0200 Subject: [PATCH 082/148] Add <author> and <guid> to RSS feed From http://blogs.law.harvard.edu/tech/rss author - Email address of the author of the item. guid - A string that uniquely identifies the item. Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com> --- gitweb.cgi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitweb.cgi b/gitweb.cgi index 8d4e4f70220..e68368d56bb 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1424,7 +1424,9 @@ sub git_rss { "<title>" . sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML($co{'title'}) . "</title>\n" . + "<author>" . escapeHTML($co{'author'}) . "</author>\n" . "<pubDate>$cd{'rfc2822'}</pubDate>\n" . + "<guid isPermaLink=\"true\">" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" . "<link>" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" . "<description>" . escapeHTML($co{'title'}) . "</description>\n" . "<content:encoded>" . From a48e11ca90ff0cb01bff953ab4095a33a5561a70 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 31 Aug 2005 03:25:29 +0200 Subject: [PATCH 083/148] don't chop_str if adding ... is longer than the original Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index e68368d56bb..6ce9223334b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -21,8 +21,8 @@ my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; # absolute fs-path which will be prepended to the project path -my $projectroot = "/pub/scm"; -$projectroot = "/home/kay/public_html/pub/scm"; +#my $projectroot = "/pub/scm"; +my $projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries my $gitbin = "/usr/bin"; @@ -621,12 +621,15 @@ sub chop_str { my $len = shift; my $add_len = shift || 10; - $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})/; - my $chopped = $1; - if ($chopped ne $str) { - $chopped .= " ..."; + # allow only $len chars, but don't cut a word if it would fit in $add_len + # if it doesn't fit, cut it if it's still longer than the dots we would add + $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})(.*)/; + my $body = $1; + my $tail = $2; + if (length($tail) > 4) { + $tail = " ..."; } - return $chopped; + return "$body$tail"; } sub file_type { From c24fd7b7cc9178af7e1e02d4a0fde549533b56c6 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 31 Aug 2005 03:47:13 +0200 Subject: [PATCH 084/148] Show tooltips (like this one :)) containing full titles for truncated commit titles in the summary and shortlog views. Thanks for the patch to: Timo Hirvonen <tihirvon at gmail.com> --- gitweb.cgi | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 6ce9223334b..e58f246c4e6 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "240"; +my $version = "241"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -980,9 +980,14 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$co{'age_string'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . - "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, - "<b>" . escapeHTML($co{'title_short'}) . "</b>") . + "<td>"; + if (length($co{'title_short'}) < length($co{'title'})) { + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list", -title => "$co{'title'}"}, + "<b>" . escapeHTML($co{'title_short'}) . "</b>"); + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, + "<b>" . escapeHTML($co{'title'}) . "</b>"); + } "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . @@ -2232,8 +2237,15 @@ sub git_shortlog { $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . - escapeHTML($co{'title_short'}) . "</b>") . "</td>\n" . + "<td>"; + if (length($co{'title_short'}) < length($co{'title'})) { + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list", -title => "$co{'title'}"}, + "<b>" . escapeHTML($co{'title_short'}) . "</b>"); + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, + "<b>" . escapeHTML($co{'title_short'}) . "</b>"); + } + print "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . From 48c771f4a7c10e28bb1c14a59035df30169f5edf Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 31 Aug 2005 03:54:45 +0200 Subject: [PATCH 085/148] v241 Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index e58f246c4e6..47c458d8852 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -488,7 +488,7 @@ sub git_read_commit { $co{'comment'} = \@commit_lines; foreach my $title (@commit_lines) { if ($title ne "") { - $co{'title'} = chop_str($title, 80); + $co{'title'} = chop_str($title, 80, 5); # remove leading stuff of merges to make the interesting part visible if (length($title) > 50) { $title =~ s/^Automatic //; @@ -506,7 +506,7 @@ sub git_read_commit { $title =~ s/\/pub\/scm//; } } - $co{'title_short'} = chop_str($title, 50); + $co{'title_short'} = chop_str($title, 50, 5); last; } } From 76a8323ac7f543d5abb8849aa6f6a991cffc281f Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 31 Aug 2005 04:11:33 +0200 Subject: [PATCH 086/148] v242 fix typo Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 47c458d8852..0d22d328fc6 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "241"; +my $version = "242"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -988,7 +988,7 @@ sub git_summary { print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>"); } - "</td>\n" . + print "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . From c91da262b388c106d7f77831cc6ab2264396e793 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sat, 3 Sep 2005 14:50:33 +0200 Subject: [PATCH 087/148] common input validation to allow passing of textual hash id's --- gitweb.cgi | 78 ++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 0d22d328fc6..49fe43271e4 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -43,7 +43,7 @@ my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); if (defined $action) { - if ($action =~ m/[^0-9a-zA-Z\.\-_]+/) { + if ($action =~ m/[^0-9a-zA-Z\.\-_]/) { undef $action; die_error(undef, "Invalid action parameter."); } @@ -58,7 +58,7 @@ if (defined $action) { my $order = $cgi->param('o'); if (defined $order) { - if ($order =~ m/[^a-zA-Z0-9_]/) { + if ($order =~ m/[^0-9a-zA-Z_]/) { undef $order; die_error(undef, "Invalid order parameter."); } @@ -66,13 +66,9 @@ if (defined $order) { my $project = $cgi->param('p'); if (defined $project) { - if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) { - undef $project; - die_error(undef, "Non-canonical project parameter."); - } - if ($project =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { - undef $project; - die_error(undef, "Invalid character in project parameter."); + $project = validate_input($project); + if (!defined($project)) { + die_error(undef, "Invalid project parameter."); } if (!(-d "$projectroot/$project")) { undef $project; @@ -91,54 +87,39 @@ if (defined $project) { my $file_name = $cgi->param('f'); if (defined $file_name) { - if ($file_name =~ m/(^|\/)(|\.|\.\.)($|\/)/) { - undef $file_name; - die_error(undef, "Non-canonical file parameter."); - } - if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { - undef $file_name; - die_error(undef, "Invalid character in file parameter."); + $file_name = validate_input($file_name); + if (!defined($file_name)) { + die_error(undef, "Invalid file parameter."); } } my $hash = $cgi->param('h'); if (defined $hash) { - if (!($hash =~ m/^[0-9a-fA-F]{40}$/)) { - if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) { - undef $hash; - die_error(undef, "Non-canonical hash parameter."); - } - if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { - undef $hash; - die_error(undef, "Invalid character in hash parameter."); - } - # replace branch-name with hash - my $branchlist = git_read_refs("refs/heads"); - foreach my $entry (@$branchlist) { - my %branch = %$entry; - if ($branch{'name'} eq $hash) { - $hash = $branch{'id'}; - last; - } - } + $hash = validate_input($hash); + if (!defined($hash)) { + die_error(undef, "Invalid hash parameter."); } } my $hash_parent = $cgi->param('hp'); -if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { - undef $hash_parent; - die_error(undef, "Invalid hash_parent parameter."); +if (defined $hash_parent) { + $hash_parent = validate_input($hash_parent); + if (!defined($hash_parent)) { + die_error(undef, "Invalid hash parent parameter."); + } } my $hash_base = $cgi->param('hb'); -if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) { - undef $hash_base; - die_error(undef, "Invalid parent hash parameter."); +if (defined $hash_base) { + $hash_base = validate_input($hash_base); + if (!defined($hash_base)) { + die_error(undef, "Invalid hash base parameter."); + } } my $page = $cgi->param('pg'); if (defined $page) { - if ($page =~ m/^[^0-9]+$/) { + if ($page =~ m/[^0-9]$/) { undef $page; die_error(undef, "Invalid page parameter."); } @@ -153,6 +134,21 @@ if (defined $searchtext) { $searchtext = quotemeta $searchtext; } +sub validate_input { + my $input = shift; + + if ($input =~ m/^[0-9a-fA-F]{40}$/) { + return $input; + } + if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + return undef; + } + if ($input =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + return undef; + } + return $input; +} + if (!defined $action || $action eq "summary") { git_summary(); exit; From 86f5b8a098e60912a3396eb85481fa85c67133c9 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sat, 3 Sep 2005 14:51:13 +0200 Subject: [PATCH 088/148] v243 Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 49fe43271e4..94063aaa13f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "242"; +my $version = "243"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From f9127561461fe209171aaf81afd2bbe234756d7b Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 4 Sep 2005 01:37:25 +0200 Subject: [PATCH 089/148] translate reference into hash while reading a commit --- gitweb.cgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 94063aaa13f..6a61c655575 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -478,7 +478,16 @@ sub git_read_commit { if (!defined $co{'tree'}) { return undef }; - $co{'id'} = $commit_id; + if (!($commit_id =~ m/^[0-9a-fA-F]{40}$/)) { + # lookup hash by textual id + open my $fd, "-|", "$gitbin/git-rev-parse --verify $commit_id" or return; + my $hash_id = <$fd>; + close $fd or return; + chomp $hash_id; + $co{'id'} = $hash_id + } else { + $co{'id'} = $commit_id; + } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; $co{'comment'} = \@commit_lines; @@ -1630,7 +1639,7 @@ sub git_commit { "</tr>\n"; print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; - print "<tr><td>commit</td><td style=\"font-family:monospace\">$hash</td></tr>\n"; + print "<tr><td>commit</td><td style=\"font-family:monospace\">$co{'id'}</td></tr>\n"; print "<tr>" . "<td>tree</td>" . "<td style=\"font-family:monospace\">" . From 324d7cca6800a6c0bd6ea4ee4fcbcb5d79bc667f Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 6 Sep 2005 23:26:10 +0200 Subject: [PATCH 090/148] fix typo in link parameter of git_commit Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 6a61c655575..acf1b1ab96e 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1716,7 +1716,7 @@ sub git_commit { $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hp=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . "</td>\n"; } elsif ($status eq "D") { From 55d0b8e4f718e5b28deae474866a936375b584cc Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 6 Sep 2005 23:26:57 +0200 Subject: [PATCH 091/148] v244 Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index acf1b1ab96e..fa5b6355a6c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "243"; +my $version = "244"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 25f422fb87014107bffb265483809909f300c537 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 13 Sep 2005 02:21:59 +0200 Subject: [PATCH 092/148] switch to git-rev-list for commit reading This way we don't need to parse the "grafts". Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fa5b6355a6c..53980efeba3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -443,21 +443,28 @@ sub git_read_commit { my @commit_lines; my %co; - my @parents; if (defined $commit_text) { @commit_lines = @$commit_text; } else { - open my $fd, "-|", "$gitbin/git-cat-file commit $commit_id" or return; - @commit_lines = map { chomp; $_ } <$fd>; + $/ = "\0"; + open my $fd, "-|", "$gitbin/git-rev-list --header --parents --max-count=1 $commit_id" or return; + @commit_lines = split '\n', <$fd>; close $fd or return; + $/ = "\n"; + pop @commit_lines; } + my $header = shift @commit_lines; + if (!($header =~ m/^[0-9a-fA-F]{40}/)) { + return; + } + ($co{'id'}, my @parents) = split ' ', $header; + $co{'parents'} = \@parents; + $co{'parent'} = $parents[0]; while (my $line = shift @commit_lines) { last if $line eq "\n"; if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) { $co{'tree'} = $1; - } elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) { - push @parents, $1; } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; $co{'author_epoch'} = $2; @@ -476,21 +483,9 @@ sub git_read_commit { } } if (!defined $co{'tree'}) { - return undef + return; }; - if (!($commit_id =~ m/^[0-9a-fA-F]{40}$/)) { - # lookup hash by textual id - open my $fd, "-|", "$gitbin/git-rev-parse --verify $commit_id" or return; - my $hash_id = <$fd>; - close $fd or return; - chomp $hash_id; - $co{'id'} = $hash_id - } else { - $co{'id'} = $commit_id; - } - $co{'parents'} = \@parents; - $co{'parent'} = $parents[0]; - $co{'comment'} = \@commit_lines; + foreach my $title (@commit_lines) { if ($title ne "") { $co{'title'} = chop_str($title, 80, 5); @@ -515,6 +510,11 @@ sub git_read_commit { last; } } + # remove added spaces + foreach my $line (@commit_lines) { + $line =~ s/^ //; + } + $co{'comment'} = \@commit_lines; my $age = time - $co{'committer_epoch'}; $co{'age'} = $age; @@ -2081,7 +2081,7 @@ sub git_search { my $alternate = 0; if ($commit_search) { $/ = "\0"; - open my $fd, "-|", "$gitbin/git-rev-list --header $hash"; + open my $fd, "-|", "$gitbin/git-rev-list --header --parents $hash" or next; while (my $commit_text = <$fd>) { if (!grep m/$searchtext/i, $commit_text) { next; @@ -2093,8 +2093,7 @@ sub git_search { next; } my @commit_lines = split "\n", $commit_text; - my $commit = shift @commit_lines; - my %co = git_read_commit($commit, \@commit_lines); + my %co = git_read_commit(undef, \@commit_lines); if (!%co) { next; } @@ -2107,7 +2106,7 @@ sub git_search { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(.*)($searchtext)(.*)$/i) { @@ -2122,8 +2121,8 @@ sub git_search { } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$commit"}, "tree"); + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree"); print "</td>\n" . "</tr>\n"; } From bd4d3c92d7bbe527bfc24e1a0bc4aa42900e4c90 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 13 Sep 2005 02:22:51 +0200 Subject: [PATCH 093/148] v245 Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 53980efeba3..68d4bc389e4 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "244"; +my $version = "245"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From c39e47d98a05beb6f5194900b1b081ccc00d70e7 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sat, 17 Sep 2005 03:00:21 +0200 Subject: [PATCH 094/148] start searching at the current $hash value Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gitweb.cgi b/gitweb.cgi index 68d4bc389e4..3a89d826ed0 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -297,11 +297,19 @@ EOF if (!defined $searchtext) { $searchtext = ""; } + my $search_hash; + if (defined $hash) { + $search_hash = $hash; + } else { + $search_hash = "HEAD"; + } $cgi->param("a", "search"); + $cgi->param("h", $search_hash); print $cgi->startform(-method => "get", -action => "$my_uri") . "<div class=\"search\">\n" . $cgi->hidden(-name => "p") . "\n" . $cgi->hidden(-name => "a") . "\n" . + $cgi->hidden(-name => "h") . "\n" . $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . "</div>" . $cgi->end_form() . "\n"; From 972062bbb8d097186eee6772e7486f5a4a025d5a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 20 Sep 2005 10:25:01 +0200 Subject: [PATCH 095/148] v246 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 3a89d826ed0..9dea33489b9 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "245"; +my $version = "246"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From d8f1c5c2f37433ef9ce56847d81314ea2798ac3c Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 4 Oct 2005 01:12:47 +0200 Subject: [PATCH 096/148] rename "branches" to "heads" Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 9dea33489b9..fc91907885a 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -5,7 +5,7 @@ # (C) 2005, Kay Sievers <kay.sievers@vrfy.org> # (C) 2005, Christian Gierke <ch@gierke.de> # -# This program is licensed under the GPL v2, or a later version +# This program is licensed under the GPLv2 use strict; use warnings; @@ -152,8 +152,8 @@ sub validate_input { if (!defined $action || $action eq "summary") { git_summary(); exit; -} elsif ($action eq "branches") { - git_branches(); +} elsif ($action eq "heads") { + git_heads(); exit; } elsif ($action eq "tags") { git_tags(); @@ -1067,15 +1067,15 @@ sub git_summary { print "</table\n>"; } - my $branchlist = git_read_refs("refs/heads"); - if (defined @$branchlist) { + my $headlist = git_read_refs("refs/heads"); + if (defined @$headlist) { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") . + $cgi->a({-href => "$my_uri?p=$project;a=heads", -class => "title"}, "heads") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; my $alternate = 0; - foreach my $entry (@$branchlist) { + foreach my $entry (@$headlist) { my %tag = %$entry; if ($alternate) { print "<tr class=\"dark\">\n"; @@ -1095,7 +1095,7 @@ sub git_summary { "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=heads"}, "...") . "</td>\n" . "</tr>"; last; } @@ -1203,7 +1203,7 @@ sub git_tags { git_footer_html(); } -sub git_branches { +sub git_heads { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . From 0c3eb45fa414326564cb1a9692c7a22319939fc0 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 4 Oct 2005 01:13:22 +0200 Subject: [PATCH 097/148] v247 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index fc91907885a..ecbcd5b3c21 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "246"; +my $version = "247"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 9312944d35b571c4a7fdde266131b1a6f8d03241 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 17 Oct 2005 03:27:54 +0200 Subject: [PATCH 098/148] provide filename for "save as" in plaintext views Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index ecbcd5b3c21..a11f2974f45 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1281,7 +1281,6 @@ sub git_blob { $hash = git_get_hash_by_path($base, $file_name, "blob"); } open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed."); - my $base = $file_name || ""; git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . @@ -1291,9 +1290,13 @@ sub git_blob { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" . - "</div>\n"; - print "<div>" . + if (defined $file_name) { + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name"}, "plain") . "<br/>\n"; + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n"; + } + print "</div>\n". + "<div>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "</div>\n"; } else { @@ -1323,7 +1326,11 @@ sub git_blob { } sub git_blob_plain { - print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + my $save_as = "$hash.txt"; + if (defined $file_name) { + $save_as = $file_name; + } + print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"$save_as\""); open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return; undef $/; print <$fd>; @@ -1945,7 +1952,7 @@ sub git_commitdiff_plain { } close $fd; - print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\""); my %co = git_read_commit($hash); my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my $comment = $co{'comment'}; From 11044297b21e0ecabc22c055e43be7bfd3972dff Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 19 Oct 2005 03:18:45 +0200 Subject: [PATCH 099/148] add Expires: +1d header to commit and commitdiff pages Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index a11f2974f45..873b7ce12ee 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -208,6 +208,7 @@ if (!defined $action || $action eq "summary") { sub git_header_html { my $status = shift || "200 OK"; + my $expires = shift; my $title = "git"; if (defined $project) { @@ -216,7 +217,7 @@ sub git_header_html { $title .= "/$action"; } } - print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); + print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status, -expires => $expires); print <<EOF; <?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"> @@ -1620,7 +1621,13 @@ sub git_commit { open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); - git_header_html(); + + # non-textual hash id's can be cached + my $expires; + if ($hash =~ m/^[0-9a-fA-F]{40}$/) { + $expires = "+1d"; + } + git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . @@ -1852,7 +1859,12 @@ sub git_commitdiff { my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); - git_header_html(); + # non-textual hash id's can be cached + my $expires; + if ($hash =~ m/^[0-9a-fA-F]{40}$/) { + $expires = "+1d"; + } + git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . From 5b6dcc3fded7acd02c61c2a10a7f83ced31b4d3e Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 19 Oct 2005 03:24:27 +0200 Subject: [PATCH 100/148] v248 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 873b7ce12ee..b8f153788a8 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "247"; +my $version = "248"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From cc3245b6512a01d74c0fd460d762ba8a1e8b968a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 14 Nov 2005 05:43:02 +0100 Subject: [PATCH 101/148] add test files --- gitweb.cgi | 1 + test/file with spaces | 4 ++++ test/file+plus+sign | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 test/file with spaces create mode 100644 test/file+plus+sign diff --git a/gitweb.cgi b/gitweb.cgi index b8f153788a8..615af99e2ca 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -2047,6 +2047,7 @@ sub git_history { escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); diff --git a/test/file with spaces b/test/file with spaces new file mode 100644 index 00000000000..e6a87a60e47 --- /dev/null +++ b/test/file with spaces @@ -0,0 +1,4 @@ +This +filename +has +spaces. diff --git a/test/file+plus+sign b/test/file+plus+sign new file mode 100644 index 00000000000..ab8050ceb4e --- /dev/null +++ b/test/file+plus+sign @@ -0,0 +1,6 @@ +This +file +has ++ +plus +chars. From 85852d44e48c1d1c6d815cc5fccf1b580f2f2cad Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 14 Nov 2005 05:45:31 +0100 Subject: [PATCH 102/148] update the test files to have a diff --- test/file with spaces | 2 +- test/file+plus+sign | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/file with spaces b/test/file with spaces index e6a87a60e47..f108543c4e5 100644 --- a/test/file with spaces +++ b/test/file with spaces @@ -1,4 +1,4 @@ This filename -has +contains spaces. diff --git a/test/file+plus+sign b/test/file+plus+sign index ab8050ceb4e..fd05278808d 100644 --- a/test/file+plus+sign +++ b/test/file+plus+sign @@ -1,6 +1,6 @@ This -file -has +filename +contains + plus chars. From 353347b0b811fcdb7c7064a85d1729433c0b8d51 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 14 Nov 2005 05:47:18 +0100 Subject: [PATCH 103/148] escape '+' and ' ' in url's --- gitweb.cgi | 390 +++++++++++++++++++++++++++-------------------------- 1 file changed, 199 insertions(+), 191 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 615af99e2ca..c477bf1bab0 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -78,7 +78,8 @@ if (defined $project) { undef $project; die_error(undef, "No such project."); } - $rss_link = "<link rel=\"alternate\" title=\"$project log\" href=\"$my_uri?p=$project;a=rss\" type=\"application/rss+xml\"/>"; + $rss_link = "<link rel=\"alternate\" title=\"" . esc($project) . " log\" href=\"" . + esc("$my_uri?p=$project;a=rss") . "\" type=\"application/rss+xml\"/>"; $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); @@ -206,6 +207,13 @@ if (!defined $action || $action eq "summary") { exit; } +sub esc { + my $str = shift; + $str =~ s/ /\+/g; + $str =~ s/\+/%2b/g; + return $str; +} + sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; @@ -286,11 +294,11 @@ a.rss_logo:hover { background-color:#ee5500; } EOF print "<div class=\"page_header\">\n" . "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" . - "<img src=\"$my_uri?a=git-logo.png\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . + "<img src=\"" . esc("$my_uri?a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . "</a>\n"; - print $cgi->a({-href => $home_link}, "projects") . " / "; + print $cgi->a({-href => esc($home_link)}, "projects") . " / "; if (defined $project) { - print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, escapeHTML($project)); + print $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, escapeHTML($project)); if (defined $action) { print " / $action"; } @@ -306,7 +314,7 @@ EOF } $cgi->param("a", "search"); $cgi->param("h", $search_hash); - print $cgi->startform(-method => "get", -action => "$my_uri") . + print $cgi->startform(-method => "get", -action => $my_uri) . "<div class=\"search\">\n" . $cgi->hidden(-name => "p") . "\n" . $cgi->hidden(-name => "a") . "\n" . @@ -325,9 +333,9 @@ sub git_footer_html { if (defined $descr) { print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; } - print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n"; + print $cgi->a({-href => esc("$my_uri?p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n"; } else { - print $cgi->a({-href => "$my_uri?a=opml", -class => "rss_logo"}, "OPML") . "\n"; + print $cgi->a({-href => esc("$my_uri?a=opml"), -class => "rss_logo"}, "OPML") . "\n"; } print "</div>\n" . "</body>\n" . @@ -668,7 +676,7 @@ sub format_log_line_html { if ($line =~ m/([0-9a-fA-F]{40})/) { my $hash_text = $1; if (git_get_type($hash_text) eq "commit") { - my $link = $cgi->a({-class => "text", -href => "$my_uri?p=$project;a=commit;h=$hash_text"}, $hash_text); + my $link = $cgi->a({-class => "text", -href => esc("$my_uri?p=$project;a=commit;h=$hash_text")}, $hash_text); $line =~ s/$hash_text/$link/; } } @@ -816,25 +824,25 @@ sub git_project_list { @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects; print "<th>Project</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=project"}, "Project") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=project")}, "Project") . "</th>\n"; } if (defined($order) && ($order eq "descr")) { @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects; print "<th>Description</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=descr"}, "Description") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=descr")}, "Description") . "</th>\n"; } if (defined($order) && ($order eq "owner")) { @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects; print "<th>Owner</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=owner"}, "Owner") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=owner")}, "Owner") . "</th>\n"; } if (defined($order) && ($order eq "age")) { @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects; print "<th>Last Change</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?o=age"}, "Last Change") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=age")}, "Last Change") . "</th>\n"; } print "<th></th>\n" . "</tr>\n"; @@ -846,7 +854,7 @@ sub git_project_list { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td>" . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=summary", -class => "list"}, escapeHTML($pr->{'path'})) . "</td>\n" . + print "<td>" . $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=summary"), -class => "list"}, escapeHTML($pr->{'path'})) . "</td>\n" . "<td>$pr->{'descr'}</td>\n" . "<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n"; my $colored_age; @@ -859,9 +867,9 @@ sub git_project_list { } print "<td>$colored_age</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=log"}, "log") . + $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=log")}, "log") . "</td>\n" . "</tr>\n"; } @@ -960,11 +968,11 @@ sub git_summary { git_header_html(); print "<div class=\"page_nav\">\n" . "summary". - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div class=\"title\"> </div>\n"; @@ -977,7 +985,7 @@ sub git_summary { my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog", -class => "title"}, "shortlog") . + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog"), -class => "title"}, "shortlog") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -996,20 +1004,20 @@ sub git_summary { "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list", -title => "$co{'title'}"}, + print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, "<b>" . escapeHTML($co{'title_short'}) . "</b>"); } else { - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, + print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . escapeHTML($co{'title'}) . "</b>"); } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1019,7 +1027,7 @@ sub git_summary { my $taglist = git_read_refs("refs/tags"); if (defined @$taglist) { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") . + $cgi->a({-href => esc("$my_uri?p=$project;a=tags"), -class => "title"}, "tags") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1040,27 +1048,27 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"}, + $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td>"; if (defined($comment)) { - print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment); + print $cgi->a({-class => "list", -href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); } print "</td>\n" . "<td class=\"link\">"; if ($tag{'type'} eq "tag") { - print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | "; + print $cgi->a({-href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'}); + print $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log"); + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=tags")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1071,7 +1079,7 @@ sub git_summary { my $headlist = git_read_refs("refs/heads"); if (defined @$headlist) { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=heads", -class => "title"}, "heads") . + $cgi->a({-href => esc("$my_uri?p=$project;a=heads"), -class => "title"}, "heads") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1087,16 +1095,16 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") . + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=heads"}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=heads")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1110,24 +1118,24 @@ sub git_tag { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my %tag = git_read_tag($hash); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($tag{'name'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($tag{'name'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n" . "<tr>\n" . "<td>object</td>\n" . - "<td>" . $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'object'}) . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}"}, $tag{'type'}) . "</td>\n" . + "<td>" . $cgi->a({-class => "list", -href => esc("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" . "</tr>\n"; if (defined($tag{'author'})) { my %ad = date_str($tag{'epoch'}, $tag{'tz'}); @@ -1149,17 +1157,17 @@ sub git_tags { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/tags"); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -1179,22 +1187,22 @@ sub git_tags { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}", -class => "list"}, + $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td>"; if (defined($comment)) { - print $cgi->a({-class => "list", -href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, $comment); + print $cgi->a({-class => "list", -href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); } print "</td>\n" . "<td class=\"link\">"; if ($tag{'type'} eq "tag") { - print $cgi->a({-href => "$my_uri?p=$project;a=tag;h=$tag{'id'}"}, "tag") . " | "; + print $cgi->a({-href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'}); + print $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log"); + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "</td>\n" . "</tr>"; @@ -1208,17 +1216,17 @@ sub git_heads { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$head"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$head"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "tree") . "<br/>\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/heads"); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -1233,11 +1241,11 @@ sub git_heads { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}", -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'name'}"}, "log") . + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . "</td>\n" . "</tr>"; } @@ -1285,20 +1293,20 @@ sub git_blob { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n"; + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; if (defined $file_name) { - print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name"}, "plain") . "<br/>\n"; + print $cgi->a({-href => esc("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . "<br/>\n"; } else { - print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n"; + print $cgi->a({-href => esc("$my_uri?p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; } print "</div>\n". "<div>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, escapeHTML($co{'title'})) . "</div>\n"; } else { print "<div class=\"page_nav\">\n" . @@ -1361,16 +1369,16 @@ sub git_tree { if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash_base"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash_base"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash_base")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash_base")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . " | tree" . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n"; @@ -1403,18 +1411,18 @@ sub git_tree { print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { print "<td class=\"list\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key), -class => "list"}, $t_name) . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "blob") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key)}, "blob") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=history;h=$hash_base" . $file_key)}, "history") . "</td>\n"; } elsif ($t_type eq "tree") { print "<td class=\"list\">" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . + $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, $t_name) . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, "tree") . + $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, "tree") . "</td>\n"; } print "</tr>\n"; @@ -1523,12 +1531,12 @@ sub git_log { } git_header_html(); print "<div class=\"page_nav\">\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . + print $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . " | log" . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n"; + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); @@ -1536,19 +1544,19 @@ sub git_log { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "HEAD"); + print $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { print " ⋅ " . - $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev"); + $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { print " ⋅ " . - $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next"); + $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } @@ -1556,7 +1564,7 @@ sub git_log { "</div>\n"; if (!@revlist) { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; my %co = git_read_commit($hash); print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; @@ -1567,13 +1575,13 @@ sub git_log { next if !%co; my %ad = date_str($co{'author_epoch'}); print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "title"}, "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "<br/>\n" . "</div>\n" . "<i>" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" . @@ -1629,22 +1637,22 @@ sub git_commit { } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . " | commit"; if (defined $co{'parent'}) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff"); } - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" . + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" . "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } else { print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } print "<div class=\"title_text\">\n" . @@ -1665,19 +1673,19 @@ sub git_commit { print "<tr>" . "<td>tree</td>" . "<td style=\"font-family:monospace\">" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) . + $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) . "</td>" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "</td>" . "</tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "<tr>" . "<td>parent</td>" . - "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "</td>" . + "<td style=\"font-family:monospace\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par"}, "commitdiff") . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$par")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") . "</td>" . "</tr>\n"; } @@ -1738,16 +1746,16 @@ sub git_commit { $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)) . "</td>\n" . "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" . - "<td class=\"link\">" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . "</td>\n"; + "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n"; } elsif ($status eq "D") { print "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)) . "</td>\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)) . "</td>\n" . "<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, "blob") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "</td>\n" } elsif ($status eq "M" || $status eq "T") { my $mode_chnge = ""; @@ -1767,18 +1775,18 @@ sub git_commit { } print "<td>"; if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)); + print $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)); } else { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file", -class => "list"}, escapeHTML($file)); + print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)); } print "</td>\n" . "<td>$mode_chnge</td>\n" . "<td class=\"link\">"; - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob"); + print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob"); if ($to_id ne $from_id) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff"); + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff"); } - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "\n"; + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "\n"; print "</td>\n"; } elsif ($status eq "R") { my ($from_file, $to_file) = split "\t", $file; @@ -1787,14 +1795,14 @@ sub git_commit { $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file", -class => "list"}, escapeHTML($to_file)) . "</td>\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, escapeHTML($to_file)) . "</td>\n" . "<td><span style=\"color: #777777;\">[moved from " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file", -class => "list"}, escapeHTML($from_file)) . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, escapeHTML($from_file)) . " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"}, "blob"); + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); if ($to_id ne $from_id) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file"}, "diff"); + print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff"); } print "</td>\n"; } @@ -1809,17 +1817,17 @@ sub git_blobdiff { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . + print $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n" . @@ -1831,9 +1839,9 @@ sub git_blobdiff { } print "<div class=\"page_body\">\n" . "<div class=\"diff_info\">blob:" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) . " -> blob:" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) . "</div>\n"; git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); print "</div>"; @@ -1866,16 +1874,16 @@ sub git_commitdiff { } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . " | commitdiff" . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "<br/>\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent"}, "plain") . "\n" . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n"; + print $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; @@ -1914,20 +1922,20 @@ sub git_commitdiff { my $file = $6; if ($status eq "A") { print "<div class=\"diff_info\">" . file_type($to_mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id) . "(new)" . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" . "</div>\n"; git_diff_print(undef, "/dev/null", $to_id, "b/$file"); } elsif ($status eq "D") { print "<div class=\"diff_info\">" . file_type($from_mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . "(deleted)" . + $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" . "</div>\n"; git_diff_print($from_id, "a/$file", undef, "/dev/null"); } elsif ($status eq "M") { if ($from_id ne $to_id) { print "<div class=\"diff_info\">" . - file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . + file_type($from_mode) . ":" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . " -> " . - file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id); + file_type($to_mode) . ":" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id); print "</div>\n"; git_diff_print($from_id, "a/$file", $to_id, "b/$file"); } @@ -2008,16 +2016,16 @@ sub git_history { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n"; @@ -2043,17 +2051,17 @@ sub git_history { $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . - "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" . + "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob"); + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;hb=$commit;f=$file_name")}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { print " | " . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name"}, + $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")}, "diff to current"); } print "</td>\n" . @@ -2093,17 +2101,17 @@ sub git_search { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary;h=$hash"}, "summary") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary;h=$hash")}, "summary") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -2134,7 +2142,7 @@ sub git_search { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(.*)($searchtext)(.*)$/i) { @@ -2149,8 +2157,8 @@ sub git_search { } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree"); + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); print "</td>\n" . "</tr>\n"; } @@ -2187,18 +2195,18 @@ sub git_search { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}", -class => "list"}, "<b>" . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); while (my $setref = shift @files) { my %set = %$setref; - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}", class => "list"}, + print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"}, "<span style=\"color:#e00000\">" . escapeHTML($set{'file'}) . "</span>") . "<br/>\n"; } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$co{'id'}"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}"}, "tree"); + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); print "</td>\n" . "</tr>\n"; } @@ -2221,12 +2229,12 @@ sub git_shortlog { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . " | shortlog" . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$hash"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash;hb=$hash"}, "tree") . "<br/>\n"; + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); @@ -2234,26 +2242,26 @@ sub git_shortlog { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => "$my_uri?p=$project;a=shortlog"}, "HEAD"); + print $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { print " ⋅ " . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1), -accesskey => "p", -title => "Alt-p"}, "prev"); + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { print " ⋅ " . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -accesskey => "n", -title => "Alt-n"}, "next"); + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } print "<br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, " ") . + $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -2271,23 +2279,23 @@ sub git_shortlog { "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list", -title => "$co{'title'}"}, + print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, "<b>" . escapeHTML($co{'title_short'}) . "</b>"); } else { - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, + print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . escapeHTML($co{'title_short'}) . "</b>"); } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . + $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "</td>\n" . "</tr>"; } if ($#revlist >= (100 * ($page+1)-1)) { print "<tr>\n" . "<td>" . - $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1), -title => "Alt-n"}, "next") . + $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") . "</td>\n" . "</tr>\n"; } From 182167100f707eda8ab543b1b36e19f777ebe67a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 14 Nov 2005 06:10:07 +0100 Subject: [PATCH 104/148] make ' ' and '+' in filenames some kind of working --- gitweb.cgi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index c477bf1bab0..1482fecb505 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -144,7 +144,7 @@ sub validate_input { if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) { return undef; } - if ($input =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + if ($input =~ m/[^a-zA-Z0-9_ \.\/\-\+\#\~]/) { return undef; } return $input; @@ -209,8 +209,8 @@ if (!defined $action || $action eq "summary") { sub esc { my $str = shift; - $str =~ s/ /\+/g; - $str =~ s/\+/%2b/g; + $str =~ s/ /%20/g; + $str =~ s/\+/%2B/g; return $str; } @@ -580,7 +580,7 @@ sub git_diff_print { close $fd; } - open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp"; + open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp"; if ($format eq "plain") { undef $/; print <$fd>; @@ -2029,7 +2029,7 @@ sub git_history { "</div>\n"; print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; + open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin \'$file_name\'"; my $commit; print "<table cellspacing=\"0\">\n"; my $alternate = 0; From 7f2a645e4f0ca88184440980d64bf3ccb2ec8c97 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 14 Nov 2005 06:12:33 +0100 Subject: [PATCH 105/148] v249 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1482fecb505..a88c985b5e6 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "248"; +my $version = "249"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From a9e60b7d097c6f1a0ebca058ae24e544e231f91d Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 14 Nov 2005 15:15:12 +0100 Subject: [PATCH 106/148] escape ' ' with '+' in url's --- gitweb.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index a88c985b5e6..0822cb1e323 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -209,8 +209,8 @@ if (!defined $action || $action eq "summary") { sub esc { my $str = shift; - $str =~ s/ /%20/g; $str =~ s/\+/%2B/g; + $str =~ s/ /\+/g; return $str; } @@ -2167,7 +2167,7 @@ sub git_search { if ($pickaxe_search) { $/ = "\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S$searchtext"; + open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S\'$searchtext\'"; undef %co; my @files; while (my $line = <$fd>) { From 40c138134f183e635712ceace33d04e10744607f Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sat, 19 Nov 2005 17:41:29 +0100 Subject: [PATCH 107/148] replace invalid utf8 sequences by UTF-8 REPLACEMENT CHARACTER (efbfbd) I still strongly disagree with the git maintainers not to hint people, to use the only sane default encoding for a distributed project, which is utf8. I'm tired of hearing filesystem development arguments. Git is a software offered to merge forth and back across the world and not to provide a content neutral filesystem. Btw: I have nothing against the ability to run git in a closed environment, with a different encoding, that's fine, sure. But that is obviously not the case for the projects on kernel.org. It's about sane defaults, nothing else. You have to make decisions guy, as always in life. The problems to allow random encoded garbage in commit messages _without_ storing the encoding, just makes zero sense. Eighter you introduce a per-commit encoding field, if you insist on this craziness, or you define a default encoding. Everything else is just lazy and does not solve any problem, besides that you can claim now, that you are not responsible for the mess in the repository. Gitweb shows several commits at once, you allow various encodings committed to the same repository, without any hint what that garbage from the individual commits is encoded with. No idea why you don't get the problem - it's unsolvable. If you merge different peoples work, you have to speak a common language! Kay Sievers <kay.sievers@vrfy.org> --- gitweb.cgi | 473 +++++++++++++++++++++++++++-------------------------- 1 file changed, 241 insertions(+), 232 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 0822cb1e323..f2a1526da6e 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -12,17 +12,18 @@ use warnings; use CGI qw(:standard :escapeHTML -nosticky); use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); +use Encode; use Fcntl ':mode'; my $cgi = new CGI; my $version = "249"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +my $rss_link = ""; # absolute fs-path which will be prepended to the project path #my $projectroot = "/pub/scm"; -my $projectroot = "/home/kay/public_html/pub/scm"; +my $projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries my $gitbin = "/usr/bin"; @@ -37,8 +38,8 @@ my $home_link = $my_uri; my $home_text = "indextext.html"; # source of projects list -#my $projects_list = $projectroot; -my $projects_list = "index/index.aux"; +#my $projects_list = $projectroot; +my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); @@ -78,8 +79,8 @@ if (defined $project) { undef $project; die_error(undef, "No such project."); } - $rss_link = "<link rel=\"alternate\" title=\"" . esc($project) . " log\" href=\"" . - esc("$my_uri?p=$project;a=rss") . "\" type=\"application/rss+xml\"/>"; + $rss_link = "<link rel=\"alternate\" title=\"" . esc_url($project) . " log\" href=\"" . + esc_url("$my_uri?p=$project;a=rss") . "\" type=\"application/rss+xml\"/>"; $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); @@ -207,13 +208,20 @@ if (!defined $action || $action eq "summary") { exit; } -sub esc { +sub esc_url { my $str = shift; $str =~ s/\+/%2B/g; $str =~ s/ /\+/g; return $str; } +sub esc_html { + my $str = shift; + $str = escapeHTML($str); + $str = decode("utf8", $str, Encode::FB_DEFAULT); + return $str; +} + sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; @@ -294,11 +302,11 @@ a.rss_logo:hover { background-color:#ee5500; } EOF print "<div class=\"page_header\">\n" . "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" . - "<img src=\"" . esc("$my_uri?a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . + "<img src=\"" . esc_url("$my_uri?a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . "</a>\n"; - print $cgi->a({-href => esc($home_link)}, "projects") . " / "; + print $cgi->a({-href => esc_url($home_link)}, "projects") . " / "; if (defined $project) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, escapeHTML($project)); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, esc_html($project)); if (defined $action) { print " / $action"; } @@ -331,11 +339,11 @@ sub git_footer_html { if (defined $project) { my $descr = git_read_description($project); if (defined $descr) { - print "<div class=\"page_footer_text\">" . escapeHTML($descr) . "</div>\n"; + print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n"; } - print $cgi->a({-href => esc("$my_uri?p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n"; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n"; } else { - print $cgi->a({-href => esc("$my_uri?a=opml"), -class => "rss_logo"}, "OPML") . "\n"; + print $cgi->a({-href => esc_url("$my_uri?a=opml"), -class => "rss_logo"}, "OPML") . "\n"; } print "</div>\n" . "</body>\n" . @@ -606,7 +614,7 @@ sub git_diff_print { $line =~ s/\t/$spaces/; } } - print "<div class=\"pre\"$color>" . escapeHTML($line) . "</div>\n"; + print "<div class=\"pre\"$color>" . esc_html($line) . "</div>\n"; } } close $fd; @@ -671,12 +679,12 @@ sub file_type { sub format_log_line_html { my $line = shift; - $line = escapeHTML($line); + $line = esc_html($line); $line =~ s/ / /g; if ($line =~ m/([0-9a-fA-F]{40})/) { my $hash_text = $1; if (git_get_type($hash_text) eq "commit") { - my $link = $cgi->a({-class => "text", -href => esc("$my_uri?p=$project;a=commit;h=$hash_text")}, $hash_text); + my $link = $cgi->a({-class => "text", -href => esc_url("$my_uri?p=$project;a=commit;h=$hash_text")}, $hash_text); $line =~ s/$hash_text/$link/; } } @@ -824,25 +832,25 @@ sub git_project_list { @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects; print "<th>Project</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=project")}, "Project") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=project")}, "Project") . "</th>\n"; } if (defined($order) && ($order eq "descr")) { @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects; print "<th>Description</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=descr")}, "Description") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=descr")}, "Description") . "</th>\n"; } if (defined($order) && ($order eq "owner")) { @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects; print "<th>Owner</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=owner")}, "Owner") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=owner")}, "Owner") . "</th>\n"; } if (defined($order) && ($order eq "age")) { @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects; print "<th>Last Change</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc("$my_uri?o=age")}, "Last Change") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=age")}, "Last Change") . "</th>\n"; } print "<th></th>\n" . "</tr>\n"; @@ -854,7 +862,7 @@ sub git_project_list { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td>" . $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=summary"), -class => "list"}, escapeHTML($pr->{'path'})) . "</td>\n" . + print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" . "<td>$pr->{'descr'}</td>\n" . "<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n"; my $colored_age; @@ -867,9 +875,9 @@ sub git_project_list { } print "<td>$colored_age</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$pr->{'path'};a=log")}, "log") . + $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=log")}, "log") . "</td>\n" . "</tr>\n"; } @@ -968,16 +976,16 @@ sub git_summary { git_header_html(); print "<div class=\"page_nav\">\n" . "summary". - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree")}, "tree") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div class=\"title\"> </div>\n"; print "<table cellspacing=\"0\">\n" . - "<tr><td>description</td><td>" . escapeHTML($descr) . "</td></tr>\n" . + "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" . "<tr><td>owner</td><td>$owner</td></tr>\n" . "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" . "</table>\n"; @@ -985,7 +993,7 @@ sub git_summary { my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog"), -class => "title"}, "shortlog") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog"), -class => "title"}, "shortlog") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1001,23 +1009,23 @@ sub git_summary { $alternate ^= 1; if ($i-- > 0) { print "<td><i>$co{'age_string'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . + "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "<b>" . escapeHTML($co{'title_short'}) . "</b>"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, + "<b>" . esc_html($co{'title_short'}) . "</b>"); } else { - print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, - "<b>" . escapeHTML($co{'title'}) . "</b>"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, + "<b>" . esc_html($co{'title'}) . "</b>"); } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1027,7 +1035,7 @@ sub git_summary { my $taglist = git_read_refs("refs/tags"); if (defined @$taglist) { print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=tags"), -class => "title"}, "tags") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=tags"), -class => "title"}, "tags") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1048,27 +1056,27 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, - "<b>" . escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, + "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td>"; if (defined($comment)) { - print $cgi->a({-class => "list", -href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); + print $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); } print "</td>\n" . "<td class=\"link\">"; if ($tag{'type'} eq "tag") { - print $cgi->a({-href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; } - print $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=tags")}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tags")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1079,7 +1087,7 @@ sub git_summary { my $headlist = git_read_refs("refs/heads"); if (defined @$headlist) { print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=heads"), -class => "title"}, "heads") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=heads"), -class => "title"}, "heads") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1095,16 +1103,16 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, - "<b>" . escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, + "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=heads")}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=heads")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1118,28 +1126,28 @@ sub git_tag { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my %tag = git_read_tag($hash); print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($tag{'name'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($tag{'name'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n" . "<tr>\n" . "<td>object</td>\n" . - "<td>" . $cgi->a({-class => "list", -href => esc("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" . + "<td>" . $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" . "</tr>\n"; if (defined($tag{'author'})) { my %ad = date_str($tag{'epoch'}, $tag{'tz'}); - print "<tr><td>author</td><td>" . escapeHTML($tag{'author'}) . "</td></tr>\n"; + print "<tr><td>author</td><td>" . esc_html($tag{'author'}) . "</td></tr>\n"; print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n"; } print "</table>\n\n" . @@ -1147,7 +1155,7 @@ sub git_tag { print "<div class=\"page_body\">"; my $comment = $tag{'comment'}; foreach my $line (@$comment) { - print escapeHTML($line) . "<br/>\n"; + print esc_html($line) . "<br/>\n"; } print "</div>\n"; git_footer_html(); @@ -1157,17 +1165,17 @@ sub git_tags { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/tags"); print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -1187,22 +1195,22 @@ sub git_tags { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, - "<b>" . escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, + "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td>"; if (defined($comment)) { - print $cgi->a({-class => "list", -href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); + print $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); } print "</td>\n" . "<td class=\"link\">"; if ($tag{'type'} eq "tag") { - print $cgi->a({-href => esc("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; } - print $cgi->a({-href => esc("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "</td>\n" . "</tr>"; @@ -1216,17 +1224,17 @@ sub git_heads { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/heads"); print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -1241,11 +1249,11 @@ sub git_heads { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . escapeHTML($tag{'name'}) . "</b>") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . "</td>\n" . "</tr>"; } @@ -1293,20 +1301,20 @@ sub git_blob { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; if (defined $file_name) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . "<br/>\n"; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . "<br/>\n"; } else { - print $cgi->a({-href => esc("$my_uri?p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; } print "</div>\n". "<div>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, escapeHTML($co{'title'})) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "</div>\n"; } else { print "<div class=\"page_nav\">\n" . @@ -1327,7 +1335,7 @@ sub git_blob { $line =~ s/\t/$spaces/; } } - printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, escapeHTML($line); + printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html($line); } close $fd or print "Reading blob failed.\n"; print "</div>"; @@ -1369,16 +1377,16 @@ sub git_tree { if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash_base")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash_base")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash_base")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash_base")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . " | tree" . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n"; @@ -1411,15 +1419,15 @@ sub git_tree { print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { print "<td class=\"list\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key), -class => "list"}, $t_name) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key), -class => "list"}, $t_name) . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key)}, "blob") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=history;h=$hash_base" . $file_key)}, "history") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key)}, "blob") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash_base" . $file_key)}, "history") . "</td>\n"; } elsif ($t_type eq "tree") { print "<td class=\"list\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, $t_name) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, $t_name) . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, "tree") . @@ -1442,7 +1450,7 @@ sub git_rss { "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n"; print "<channel>\n"; print "<title>$project</title>\n". - "<link>" . escapeHTML("$my_url?p=$project;a=summary") . "</link>\n". + "<link>" . esc_html("$my_url?p=$project;a=summary") . "</link>\n". "<description>$project log</description>\n". "<language>en</language>\n"; @@ -1459,17 +1467,18 @@ sub git_rss { close $fd or next; print "<item>\n" . "<title>" . - sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . escapeHTML($co{'title'}) . + sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html($co{'title'}) . "</title>\n" . - "<author>" . escapeHTML($co{'author'}) . "</author>\n" . + "<author>" . esc_html($co{'author'}) . "</author>\n" . "<pubDate>$cd{'rfc2822'}</pubDate>\n" . - "<guid isPermaLink=\"true\">" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" . - "<link>" . escapeHTML("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" . - "<description>" . escapeHTML($co{'title'}) . "</description>\n" . + "<guid isPermaLink=\"true\">" . esc_html("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" . + "<link>" . esc_html("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" . + "<description>" . esc_html($co{'title'}) . "</description>\n" . "<content:encoded>" . "<![CDATA[\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { + $line = decode("utf8", $line, Encode::FB_DEFAULT); print "$line<br/>\n"; } print "<br/>\n"; @@ -1511,7 +1520,7 @@ sub git_opml { next; } - my $path = escapeHTML(chop_str($proj{'path'}, 25, 5)); + my $path = esc_html(chop_str($proj{'path'}, 25, 5)); my $rss = "$my_url?p=$proj{'path'};a=rss"; my $html = "$my_url?p=$proj{'path'};a=summary"; print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n"; @@ -1531,12 +1540,12 @@ sub git_log { } git_header_html(); print "<div class=\"page_nav\">\n"; - print $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . " | log" . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); @@ -1544,19 +1553,19 @@ sub git_log { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "HEAD"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { print " ⋅ " . - $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { print " ⋅ " . - $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } @@ -1564,7 +1573,7 @@ sub git_log { "</div>\n"; if (!@revlist) { print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; my %co = git_read_commit($hash); print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; @@ -1575,16 +1584,16 @@ sub git_log { next if !%co; my %ad = date_str($co{'author_epoch'}); print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "title"}, - "<span class=\"age\">$co{'age_string'}</span>" . escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "title"}, + "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "<br/>\n" . "</div>\n" . - "<i>" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" . + "<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" . "</div>\n" . "<div class=\"log_body\">\n"; my $comment = $co{'comment'}; @@ -1637,27 +1646,27 @@ sub git_commit { } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . " | commit"; if (defined $co{'parent'}) { - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff"); + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff"); } - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" . + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" . "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } else { print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n"; - print "<tr><td>author</td><td>" . escapeHTML($co{'author'}) . "</td></tr>\n". + print "<tr><td>author</td><td>" . esc_html($co{'author'}) . "</td></tr>\n". "<tr>" . "<td></td><td> $ad{'rfc2822'}"; if ($ad{'hour_local'} < 6) { @@ -1667,25 +1676,25 @@ sub git_commit { } print "</td>" . "</tr>\n"; - print "<tr><td>committer</td><td>" . escapeHTML($co{'committer'}) . "</td></tr>\n"; + print "<tr><td>committer</td><td>" . esc_html($co{'committer'}) . "</td></tr>\n"; print "<tr><td></td><td> $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "</td></tr>\n"; print "<tr><td>commit</td><td style=\"font-family:monospace\">$co{'id'}</td></tr>\n"; print "<tr>" . "<td>tree</td>" . "<td style=\"font-family:monospace\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) . "</td>" . - "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . + "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "</td>" . "</tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "<tr>" . "<td>parent</td>" . - "<td style=\"font-family:monospace\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" . + "<td style=\"font-family:monospace\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$par")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$par")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") . "</td>" . "</tr>\n"; } @@ -1707,7 +1716,7 @@ sub git_commit { } if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { $signed = 1; - print "<span style=\"color: #888888\">" . escapeHTML($line) . "</span><br/>\n"; + print "<span style=\"color: #888888\">" . esc_html($line) . "</span><br/>\n"; } else { $signed = 0; print format_log_line_html($line) . "<br/>\n"; @@ -1746,16 +1755,16 @@ sub git_commit { $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)) . "</td>\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" . "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" . - "<td class=\"link\">" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n"; + "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n"; } elsif ($status eq "D") { print "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)) . "</td>\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" . "<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "</td>\n" } elsif ($status eq "M" || $status eq "T") { my $mode_chnge = ""; @@ -1775,18 +1784,18 @@ sub git_commit { } print "<td>"; if ($to_id ne $from_id) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)); } else { - print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, escapeHTML($file)); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)); } print "</td>\n" . "<td>$mode_chnge</td>\n" . "<td class=\"link\">"; - print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob"); if ($to_id ne $from_id) { - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff"); + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff"); } - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "\n"; + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "\n"; print "</td>\n"; } elsif ($status eq "R") { my ($from_file, $to_file) = split "\t", $file; @@ -1795,14 +1804,14 @@ sub git_commit { $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, escapeHTML($to_file)) . "</td>\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html($to_file)) . "</td>\n" . "<td><span style=\"color: #777777;\">[moved from " . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, escapeHTML($from_file)) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) . " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); + $cgi->a({-href => esc_uresc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); if ($to_id ne $from_id) { - print " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff"); + print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff"); } print "</td>\n"; } @@ -1817,17 +1826,17 @@ sub git_blobdiff { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; - print $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n" . @@ -1839,9 +1848,9 @@ sub git_blobdiff { } print "<div class=\"page_body\">\n" . "<div class=\"diff_info\">blob:" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) . " -> blob:" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) . "</div>\n"; git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); print "</div>"; @@ -1874,16 +1883,16 @@ sub git_commitdiff { } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . " | commitdiff" . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n"; - print $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n"; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; @@ -1922,20 +1931,20 @@ sub git_commitdiff { my $file = $6; if ($status eq "A") { print "<div class=\"diff_info\">" . file_type($to_mode) . ":" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" . "</div>\n"; git_diff_print(undef, "/dev/null", $to_id, "b/$file"); } elsif ($status eq "D") { print "<div class=\"diff_info\">" . file_type($from_mode) . ":" . - $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" . "</div>\n"; git_diff_print($from_id, "a/$file", undef, "/dev/null"); } elsif ($status eq "M") { if ($from_id ne $to_id) { print "<div class=\"diff_info\">" . - file_type($from_mode) . ":" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . + file_type($from_mode) . ":" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . " -> " . - file_type($to_mode) . ":" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id); + file_type($to_mode) . ":" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id); print "</div>\n"; git_diff_print($from_id, "a/$file", $to_id, "b/$file"); } @@ -2016,16 +2025,16 @@ sub git_history { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n"; @@ -2050,18 +2059,18 @@ sub git_history { } $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . - "<td>" . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . - escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . + "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . + "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . + esc_html(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;hb=$commit;f=$file_name")}, "blob"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;hb=$commit;f=$file_name")}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { print " | " . - $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")}, + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")}, "diff to current"); } print "</td>\n" . @@ -2101,17 +2110,17 @@ sub git_search { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary;h=$hash")}, "summary") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary;h=$hash")}, "summary") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -2140,16 +2149,16 @@ sub git_search { } $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . + "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>"); my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(.*)($searchtext)(.*)$/i) { - my $lead = escapeHTML($1) || ""; + my $lead = esc_html($1) || ""; $lead = chop_str($lead, 30, 10); - my $match = escapeHTML($2) || ""; - my $trail = escapeHTML($3) || ""; + my $match = esc_html($2) || ""; + my $trail = esc_html($3) || ""; $trail = chop_str($trail, 30, 10); my $text = "$lead<span style=\"color:#e00000\">$match</span>$trail"; print chop_str($text, 80, 5) . "<br/>\n"; @@ -2157,8 +2166,8 @@ sub git_search { } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); print "</td>\n" . "</tr>\n"; } @@ -2193,20 +2202,20 @@ sub git_search { } $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . + "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . - escapeHTML(chop_str($co{'title'}, 50)) . "</b><br/>"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . + esc_html(chop_str($co{'title'}, 50)) . "</b><br/>"); while (my $setref = shift @files) { my %set = %$setref; - print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"}, - "<span style=\"color:#e00000\">" . escapeHTML($set{'file'}) . "</span>") . + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"}, + "<span style=\"color:#e00000\">" . esc_html($set{'file'}) . "</span>") . "<br/>\n"; } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); print "</td>\n" . "</tr>\n"; } @@ -2229,12 +2238,12 @@ sub git_shortlog { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . " | shortlog" . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); @@ -2242,26 +2251,26 @@ sub git_shortlog { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "HEAD"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { print " ⋅ " . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { print " ⋅ " . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } print "<br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -2276,26 +2285,26 @@ sub git_shortlog { } $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . - "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . + "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { - print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "<b>" . escapeHTML($co{'title_short'}) . "</b>"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, + "<b>" . esc_html($co{'title_short'}) . "</b>"); } else { - print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, - "<b>" . escapeHTML($co{'title_short'}) . "</b>"); + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, + "<b>" . esc_html($co{'title_short'}) . "</b>"); } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "</td>\n" . "</tr>"; } if ($#revlist >= (100 * ($page+1)-1)) { print "<tr>\n" . "<td>" . - $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") . "</td>\n" . "</tr>\n"; } From b8470d86e5e8d8ef50304fea534e985e5d4a16f0 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sat, 19 Nov 2005 17:56:29 +0100 Subject: [PATCH 108/148] v250 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index f2a1526da6e..a71d07032d3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -16,7 +16,7 @@ use Encode; use Fcntl ':mode'; my $cgi = new CGI; -my $version = "249"; +my $version = "250"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From afeaa5d8da4c4f1abde1a01285f6d612919c64ee Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 20 Nov 2005 02:03:09 +0100 Subject: [PATCH 109/148] add missing esc() rename Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index a71d07032d3..afdae92e1f0 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1308,7 +1308,8 @@ sub git_blob { " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; if (defined $file_name) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . "<br/>\n"; + print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . + " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n"; } else { print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; } @@ -1430,7 +1431,7 @@ sub git_tree { $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, $t_name) . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, "tree") . + $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, "tree") . "</td>\n"; } print "</tr>\n"; From d81caf21e98d2ac42268c7d8660db7692ef3c006 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 20 Nov 2005 02:03:29 +0100 Subject: [PATCH 110/148] v251 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index afdae92e1f0..a797a5f843d 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -16,7 +16,7 @@ use Encode; use Fcntl ':mode'; my $cgi = new CGI; -my $version = "250"; +my $version = "251"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 440c8a2ad0105b3c2010d5fd5c0bab11698b8105 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 20 Nov 2005 02:12:45 +0100 Subject: [PATCH 111/148] fix another typo Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index a797a5f843d..915e2091096 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1810,7 +1810,7 @@ sub git_commit { $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) . " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_uresc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); + $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); if ($to_id ne $from_id) { print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff"); } From 5b7a14fb4d1d38e73026e69608f11f0016f0870a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Sun, 20 Nov 2005 02:13:08 +0100 Subject: [PATCH 112/148] v252 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 915e2091096..e0e71ce9f5d 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -16,7 +16,7 @@ use Encode; use Fcntl ':mode'; my $cgi = new CGI; -my $version = "251"; +my $version = "252"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 10bb9036604006979c3a168760b01812e5dbbb40 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 23 Nov 2005 04:26:40 +0100 Subject: [PATCH 113/148] fix utf8 decoding Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index e0e71ce9f5d..dc4435c0907 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,9 +14,10 @@ use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); use Encode; use Fcntl ':mode'; +binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "252"; +my $version = "253"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -217,8 +218,8 @@ sub esc_url { sub esc_html { my $str = shift; - $str = escapeHTML($str); $str = decode("utf8", $str, Encode::FB_DEFAULT); + $str = escapeHTML($str); return $str; } From 2fe8f1c04a7fb2ffd37be9f2ff15244cc4a6ab7a Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 23 Nov 2005 15:09:59 +0100 Subject: [PATCH 114/148] add ut8 test file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It contains Märchen. (\xc3a4) --- test/Märchen | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/Märchen diff --git a/test/Märchen b/test/Märchen new file mode 100644 index 00000000000..ebce8df8daa --- /dev/null +++ b/test/Märchen @@ -0,0 +1 @@ +Märchen From 7597763d5becf151e5b0629206f24d789f5615c3 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 23 Nov 2005 15:16:49 +0100 Subject: [PATCH 115/148] add broken latin encoding to test file --- test/Märchen | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Märchen b/test/Märchen index ebce8df8daa..8f7a1d3e9c7 100644 --- a/test/Märchen +++ b/test/Märchen @@ -1 +1,2 @@ Märchen +M�rchen From 8f1deb5f53f606ac60563175c988b676627e31ce Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 23 Nov 2005 16:02:13 +0100 Subject: [PATCH 116/148] set logo output to raw mode --- gitweb.cgi | 1 + 1 file changed, 1 insertion(+) diff --git a/gitweb.cgi b/gitweb.cgi index dc4435c0907..aaf79ccd2c3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -719,6 +719,7 @@ sub date_str { # git-logo (cached in browser for one day) sub git_logo { + binmode STDOUT, ':raw'; print $cgi->header(-type => 'image/png', -expires => '+1d'); # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g' print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" . From e13dd505c5e60341177ac0bd7fcdc5f4955d3f02 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 23 Nov 2005 18:00:34 +0100 Subject: [PATCH 117/148] v253 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index aaf79ccd2c3..fdecffca025 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "253"; +my $version = "254"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 232ff5536c6d2016e1ac14c3f1c8703b54a69ad8 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 16:56:55 +0100 Subject: [PATCH 118/148] allow utf8 characters in url parameter escape Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 428 +++++++++++++++++++++++++++-------------------------- 1 file changed, 222 insertions(+), 206 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fdecffca025..d1314d84899 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -80,8 +80,8 @@ if (defined $project) { undef $project; die_error(undef, "No such project."); } - $rss_link = "<link rel=\"alternate\" title=\"" . esc_url($project) . " log\" href=\"" . - esc_url("$my_uri?p=$project;a=rss") . "\" type=\"application/rss+xml\"/>"; + $rss_link = "<link rel=\"alternate\" title=\"" . esc_param($project) . " log\" href=\"" . + "$my_uri?" . esc_param("p=$project;a=rss") . "\" type=\"application/rss+xml\"/>"; $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); @@ -146,7 +146,7 @@ sub validate_input { if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) { return undef; } - if ($input =~ m/[^a-zA-Z0-9_ \.\/\-\+\#\~]/) { + if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \.\/\-\+\#\~\%]/) { return undef; } return $input; @@ -209,13 +209,17 @@ if (!defined $action || $action eq "summary") { exit; } -sub esc_url { +# quote unsafe chars, but keep the slash, even when it's not +# correct, but quoted slashes look too horrible in bookmarks +sub esc_param { my $str = shift; + $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg; $str =~ s/\+/%2B/g; $str =~ s/ /\+/g; return $str; } +# replace invalid utf8 character with SUBSTITUTION sequence sub esc_html { my $str = shift; $str = decode("utf8", $str, Encode::FB_DEFAULT); @@ -223,6 +227,16 @@ sub esc_html { return $str; } +# git may return quoted and escaped filenames +sub unquote { + my $str = shift; + if ($str =~ m/^"(.*)"$/) { + $str = $1; + $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg; + } + return $str; +} + sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; @@ -303,11 +317,11 @@ a.rss_logo:hover { background-color:#ee5500; } EOF print "<div class=\"page_header\">\n" . "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" . - "<img src=\"" . esc_url("$my_uri?a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . + "<img src=\"$my_uri?" . esc_param("a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" . "</a>\n"; - print $cgi->a({-href => esc_url($home_link)}, "projects") . " / "; + print $cgi->a({-href => esc_param($home_link)}, "projects") . " / "; if (defined $project) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, esc_html($project)); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, esc_html($project)); if (defined $action) { print " / $action"; } @@ -342,9 +356,9 @@ sub git_footer_html { if (defined $descr) { print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n"; } - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n"; + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n"; } else { - print $cgi->a({-href => esc_url("$my_uri?a=opml"), -class => "rss_logo"}, "OPML") . "\n"; + print $cgi->a({-href => "$my_uri?" . esc_param("a=opml"), -class => "rss_logo"}, "OPML") . "\n"; } print "</div>\n" . "</body>\n" . @@ -685,7 +699,7 @@ sub format_log_line_html { if ($line =~ m/([0-9a-fA-F]{40})/) { my $hash_text = $1; if (git_get_type($hash_text) eq "commit") { - my $link = $cgi->a({-class => "text", -href => esc_url("$my_uri?p=$project;a=commit;h=$hash_text")}, $hash_text); + my $link = $cgi->a({-class => "text", -href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_text")}, $hash_text); $line =~ s/$hash_text/$link/; } } @@ -834,25 +848,25 @@ sub git_project_list { @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects; print "<th>Project</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=project")}, "Project") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=project")}, "Project") . "</th>\n"; } if (defined($order) && ($order eq "descr")) { @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects; print "<th>Description</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=descr")}, "Description") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=descr")}, "Description") . "</th>\n"; } if (defined($order) && ($order eq "owner")) { @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects; print "<th>Owner</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=owner")}, "Owner") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=owner")}, "Owner") . "</th>\n"; } if (defined($order) && ($order eq "age")) { @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects; print "<th>Last Change</th>\n"; } else { - print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=age")}, "Last Change") . "</th>\n"; + print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=age")}, "Last Change") . "</th>\n"; } print "<th></th>\n" . "</tr>\n"; @@ -864,7 +878,7 @@ sub git_project_list { print "<tr class=\"light\">\n"; } $alternate ^= 1; - print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" . + print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" . "<td>$pr->{'descr'}</td>\n" . "<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n"; my $colored_age; @@ -877,9 +891,9 @@ sub git_project_list { } print "<td>$colored_age</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=log")}, "log") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=log")}, "log") . "</td>\n" . "</tr>\n"; } @@ -978,11 +992,11 @@ sub git_summary { git_header_html(); print "<div class=\"page_nav\">\n" . "summary". - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree")}, "tree") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div class=\"title\"> </div>\n"; @@ -995,7 +1009,7 @@ sub git_summary { my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog"), -class => "title"}, "shortlog") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog"), -class => "title"}, "shortlog") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1014,20 +1028,20 @@ sub git_summary { "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, "<b>" . esc_html($co{'title_short'}) . "</b>"); } else { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . esc_html($co{'title'}) . "</b>"); } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1037,7 +1051,7 @@ sub git_summary { my $taglist = git_read_refs("refs/tags"); if (defined @$taglist) { print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=tags"), -class => "title"}, "tags") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags"), -class => "title"}, "tags") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1058,27 +1072,27 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td>"; if (defined($comment)) { - print $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); + print $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, $comment); } print "</td>\n" . "<td class=\"link\">"; if ($tag{'type'} eq "tag") { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; } - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tags")}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1089,7 +1103,7 @@ sub git_summary { my $headlist = git_read_refs("refs/heads"); if (defined @$headlist) { print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=heads"), -class => "title"}, "heads") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads"), -class => "title"}, "heads") . "</div>\n"; my $i = 16; print "<table cellspacing=\"0\">\n"; @@ -1105,16 +1119,16 @@ sub git_summary { if ($i-- > 0) { print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'name'}")}, "log") . "</td>\n" . "</tr>"; } else { - print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=heads")}, "...") . "</td>\n" . + print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads")}, "...") . "</td>\n" . "</tr>"; last; } @@ -1128,24 +1142,24 @@ sub git_tag { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my %tag = git_read_tag($hash); print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($tag{'name'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($tag{'name'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<table cellspacing=\"0\">\n" . "<tr>\n" . "<td>object</td>\n" . - "<td>" . $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" . - "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" . + "<td>" . $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" . "</tr>\n"; if (defined($tag{'author'})) { my %ad = date_str($tag{'epoch'}, $tag{'tz'}); @@ -1167,17 +1181,17 @@ sub git_tags { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/tags"); print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -1197,22 +1211,22 @@ sub git_tags { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td>"; if (defined($comment)) { - print $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment); + print $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, $comment); } print "</td>\n" . "<td class=\"link\">"; if ($tag{'type'} eq "tag") { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | "; } - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'}); if ($tag{'reftype'} eq "commit") { - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log"); + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log"); } print "</td>\n" . "</tr>"; @@ -1226,17 +1240,17 @@ sub git_heads { my $head = git_read_hash("$project/HEAD"); git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" . "<br/>\n" . "</div>\n"; my $taglist = git_read_refs("refs/heads"); print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -1251,11 +1265,11 @@ sub git_heads { $alternate ^= 1; print "<td><i>$tag{'age'}</i></td>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'name'}")}, "log") . "</td>\n" . "</tr>"; } @@ -1303,21 +1317,21 @@ sub git_blob { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; if (defined $file_name) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n"; } else { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; } print "</div>\n". "<div>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "</div>\n"; } else { print "<div class=\"page_nav\">\n" . @@ -1325,7 +1339,7 @@ sub git_blob { "<div class=\"title\">$hash</div>\n"; } if (defined $file_name) { - print "<div class=\"page_path\"><b>$file_name</b></div>\n"; + print "<div class=\"page_path\"><b>" . esc_html($file_name) . "</b></div>\n"; } print "<div class=\"page_body\">\n"; my $nr; @@ -1369,27 +1383,28 @@ sub git_tree { $hash_base = git_read_hash("$project/HEAD"); } } - open my $fd, "-|", "$gitbin/git-ls-tree $hash" or die_error(undef, "Open git-ls-tree failed."); - my (@entries) = map { chomp; $_ } <$fd>; + $/ = "\0"; + open my $fd, "-|", "$gitbin/git-ls-tree -z $hash" or die_error(undef, "Open git-ls-tree failed."); + chomp (my (@entries) = <$fd>); close $fd or die_error(undef, "Reading tree failed."); + $/ = "\n"; git_header_html(); my $base_key = ""; - my $file_key = ""; my $base = ""; if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash_base")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash_base")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash_base")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash_base")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . " | tree" . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n"; @@ -1397,8 +1412,8 @@ sub git_tree { print "<div class=\"title\">$hash</div>\n"; } if (defined $file_name) { - $base = "$file_name/"; - print "<div class=\"page_path\"><b>/$file_name</b></div>\n"; + $base = esc_html("$file_name/"); + print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b></div>\n"; } else { print "<div class=\"page_path\"><b>/</b></div>\n"; } @@ -1412,7 +1427,7 @@ sub git_tree { my $t_type = $2; my $t_hash = $3; my $t_name = $4; - $file_key = ";f=$base$t_name"; + my $t_name = validate_input($4); if ($alternate) { print "<tr class=\"dark\">\n"; } else { @@ -1422,18 +1437,18 @@ sub git_tree { print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n"; if ($t_type eq "blob") { print "<td class=\"list\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key), -class => "list"}, $t_name) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name"), -class => "list"}, esc_html($t_name)) . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key)}, "blob") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash_base" . $file_key)}, "history") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . "</td>\n"; } elsif ($t_type eq "tree") { print "<td class=\"list\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, $t_name) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, esc_html($t_name)) . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, "tree") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") . "</td>\n"; } print "</tr>\n"; @@ -1489,7 +1504,8 @@ sub git_rss { if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) { next; } - my $file = $7; + my $file = validate_input(unquote($7)); + $file = decode("utf8", $file, Encode::FB_DEFAULT); print "$file<br/>\n"; } print "]]>\n" . @@ -1543,12 +1559,12 @@ sub git_log { } git_header_html(); print "<div class=\"page_nav\">\n"; - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") . " | log" . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); @@ -1556,19 +1572,19 @@ sub git_log { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "HEAD"); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { print " ⋅ " . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { print " ⋅ " . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } @@ -1576,7 +1592,7 @@ sub git_log { "</div>\n"; if (!@revlist) { print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; my %co = git_read_commit($hash); print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n"; @@ -1587,13 +1603,13 @@ sub git_log { next if !%co; my %ad = date_str($co{'author_epoch'}); print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "title"}, + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"}, "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "<br/>\n" . "</div>\n" . "<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" . @@ -1649,22 +1665,22 @@ sub git_commit { } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") . " | commit"; if (defined $co{'parent'}) { - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff"); + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff"); } - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" . + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" . "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } else { print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } print "<div class=\"title_text\">\n" . @@ -1685,19 +1701,19 @@ sub git_commit { print "<tr>" . "<td>tree</td>" . "<td style=\"font-family:monospace\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) . "</td>" . - "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "</td>" . "</tr>\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "<tr>" . "<td>parent</td>" . - "<td style=\"font-family:monospace\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" . + "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$par")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") . "</td>" . "</tr>\n"; } @@ -1745,7 +1761,7 @@ sub git_commit { my $to_id = $4; my $status = $5; my $similarity = $6; - my $file = $7; + my $file = validate_input(unquote($7)); if ($alternate) { print "<tr class=\"dark\">\n"; } else { @@ -1758,16 +1774,16 @@ sub git_commit { $mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" . "<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" . - "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n"; + "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n"; } elsif ($status eq "D") { print "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" . "<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash;f=$file")}, "history") . "</td>\n" } elsif ($status eq "M" || $status eq "T") { my $mode_chnge = ""; @@ -1787,18 +1803,18 @@ sub git_commit { } print "<td>"; if ($to_id ne $from_id) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)); } else { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)); } print "</td>\n" . "<td>$mode_chnge</td>\n" . "<td class=\"link\">"; - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob"); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob"); if ($to_id ne $from_id) { - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff"); + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff"); } - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "\n"; + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash;f=$file")}, "history") . "\n"; print "</td>\n"; } elsif ($status eq "R") { my ($from_file, $to_file) = split "\t", $file; @@ -1807,14 +1823,14 @@ sub git_commit { $mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777); } print "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html($to_file)) . "</td>\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html($to_file)) . "</td>\n" . "<td><span style=\"color: #777777;\">[moved from " . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) . " with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob"); if ($to_id ne $from_id) { - print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff"); + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff"); } print "</td>\n"; } @@ -1829,17 +1845,17 @@ sub git_blobdiff { git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n" . @@ -1847,13 +1863,13 @@ sub git_blobdiff { "<div class=\"title\">$hash vs $hash_parent</div>\n"; } if (defined $file_name) { - print "<div class=\"page_path\"><b>/$file_name</b></div>\n"; + print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b></div>\n"; } print "<div class=\"page_body\">\n" . "<div class=\"diff_info\">blob:" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) . " -> blob:" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) . "</div>\n"; git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash); print "</div>"; @@ -1886,16 +1902,16 @@ sub git_commitdiff { } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") . " | commitdiff" . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n"; - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n"; + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; @@ -1931,23 +1947,23 @@ sub git_commitdiff { my $from_id = $3; my $to_id = $4; my $status = $5; - my $file = $6; + my $file = validate_input(unquote($6)); if ($status eq "A") { print "<div class=\"diff_info\">" . file_type($to_mode) . ":" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" . "</div>\n"; git_diff_print(undef, "/dev/null", $to_id, "b/$file"); } elsif ($status eq "D") { print "<div class=\"diff_info\">" . file_type($from_mode) . ":" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" . "</div>\n"; git_diff_print($from_id, "a/$file", undef, "/dev/null"); } elsif ($status eq "M") { if ($from_id ne $to_id) { print "<div class=\"diff_info\">" . - file_type($from_mode) . ":" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . + file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . " -> " . - file_type($to_mode) . ":" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id); + file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id); print "</div>\n"; git_diff_print($from_id, "a/$file", $to_id, "b/$file"); } @@ -2028,18 +2044,18 @@ sub git_history { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; - print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n"; + print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b><br/></div>\n"; open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin \'$file_name\'"; my $commit; @@ -2063,17 +2079,17 @@ sub git_history { $alternate ^= 1; print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . - "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . + "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;hb=$commit;f=$file_name")}, "blob"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=$commit;f=$file_name")}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { print " | " . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")}, + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")}, "diff to current"); } print "</td>\n" . @@ -2113,17 +2129,17 @@ sub git_search { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary;h=$hash")}, "summary") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary;h=$hash")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -2154,7 +2170,7 @@ sub git_search { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>"); my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(.*)($searchtext)(.*)$/i) { @@ -2169,8 +2185,8 @@ sub git_search { } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); print "</td>\n" . "</tr>\n"; } @@ -2207,18 +2223,18 @@ sub git_search { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>"); while (my $setref = shift @files) { my %set = %$setref; - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"}, + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"}, "<span style=\"color:#e00000\">" . esc_html($set{'file'}) . "</span>") . "<br/>\n"; } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree"); print "</td>\n" . "</tr>\n"; } @@ -2241,12 +2257,12 @@ sub git_shortlog { } git_header_html(); print "<div class=\"page_nav\">\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . " | shortlog" . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); @@ -2254,26 +2270,26 @@ sub git_shortlog { close $fd; if ($hash ne $head || $page) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "HEAD"); + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "HEAD"); } else { print "HEAD"; } if ($page > 0) { print " ⋅ " . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev"); } else { print " ⋅ prev"; } if ($#revlist >= (100 * ($page+1)-1)) { print " ⋅ " . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next"); } else { print " ⋅ next"; } print "<br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") . "</div>\n"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; @@ -2291,23 +2307,23 @@ sub git_shortlog { "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, "<b>" . esc_html($co{'title_short'}) . "</b>"); } else { - print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . esc_html($co{'title_short'}) . "</b>"); } print "</td>\n" . "<td class=\"link\">" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") . - " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . "</td>\n" . "</tr>"; } if ($#revlist >= (100 * ($page+1)-1)) { print "<tr>\n" . "<td>" . - $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") . "</td>\n" . "</tr>\n"; } From 3957fa17798f2cfdfac69bef43fb768d1a5dc276 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 17:15:30 +0100 Subject: [PATCH 119/148] v254 --- gitweb.cgi | 1 - 1 file changed, 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index d1314d84899..5fb496a532f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1426,7 +1426,6 @@ sub git_tree { my $t_mode = $1; my $t_type = $2; my $t_hash = $3; - my $t_name = $4; my $t_name = validate_input($4); if ($alternate) { print "<tr class=\"dark\">\n"; From 6dc05fa7496fe2f87f50e77395c63b143f289bcd Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 17:30:38 +0100 Subject: [PATCH 120/148] v255 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 5fb496a532f..cbddd3e8402 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "254"; +my $version = "255"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From ae78620525445407cca9830b7395668388769db6 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 18:14:25 +0100 Subject: [PATCH 121/148] fix quoted filename lookup Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index cbddd3e8402..e81064f1458 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1294,7 +1294,7 @@ sub git_get_hash_by_path { my $t_mode = $1; my $t_type = $2; my $t_hash = $3; - my $t_name = $4; + my $t_name = validate_input(unquote($4)); if ($t_name eq $part) { if (!(@parts)) { return $t_hash; @@ -1311,7 +1311,7 @@ sub git_get_hash_by_path { sub git_blob { if (!defined $hash && defined $file_name) { my $base = $hash_base || git_read_hash("$project/HEAD"); - $hash = git_get_hash_by_path($base, $file_name, "blob"); + $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."); git_header_html(); From e7e470c9b80bd1a77ae263f3446c81b81848fbf7 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 18:14:44 +0100 Subject: [PATCH 122/148] v256 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index e81064f1458..fb0ff761aa8 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "255"; +my $version = "256"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From f5ac835a58c7487b2e4d5a93a5cf4aab3dcf0d08 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 19:43:53 +0100 Subject: [PATCH 123/148] fix "rename" output Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index fb0ff761aa8..1e19c3117fe 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -146,7 +146,7 @@ sub validate_input { if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) { return undef; } - if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \.\/\-\+\#\~\%]/) { + if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \t\.\/\-\+\#\~\%]/) { return undef; } return $input; From 94140c7ab0eac7a8ec57b003620d00c00eb63861 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 24 Nov 2005 19:44:28 +0100 Subject: [PATCH 124/148] v257 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1e19c3117fe..da1746e3d3d 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "256"; +my $version = "257"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 6a928415e25da49b0f19b6924b6d9bbf1f8d5a4b Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 09:44:06 +0100 Subject: [PATCH 125/148] show tags in lists Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 59 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index da1746e3d3d..01920b003f8 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -311,6 +311,10 @@ a.rss_logo { text-align:center; text-decoration:none; } a.rss_logo:hover { background-color:#ee5500; } +span.tag { + padding:0px 4px; font-size:10px; + background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc; +} </style> </head> <body> @@ -901,6 +905,20 @@ sub git_project_list { git_footer_html(); } +sub read_info_ref { + my %refs; + # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11 + # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{} + open my $fd, "$projectroot/$project/info/refs" or return; + while (my $line = <$fd>) { + if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) { + $refs{$1} = $2; + } + } + close $fd or return; + return \%refs; +} + sub git_read_refs { my $ref_dir = shift; my @reflist; @@ -989,6 +1007,7 @@ sub git_summary { $owner = get_file_owner("$projectroot/$project"); } + my $refs = read_info_ref(); git_header_html(); print "<div class=\"page_nav\">\n" . "summary". @@ -1034,6 +1053,9 @@ sub git_summary { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . esc_html($co{'title'}) . "</b>"); } + if (defined $refs->{$commit}) { + print " <span class=\"tag\">$refs->{$commit}</span>"; + } print "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . @@ -1556,6 +1578,7 @@ sub git_log { if (!defined $page) { $page = 0; } + my $refs = read_info_ref(); git_header_html(); print "<div class=\"page_nav\">\n"; print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -1598,13 +1621,17 @@ sub git_log { } for (my $i = ($page * 100); $i <= $#revlist; $i++) { my $commit = $revlist[$i]; + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + } my %co = git_read_commit($commit); next if !%co; my %ad = date_str($co{'author_epoch'}); print "<div>\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"}, - "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'})) . "\n" . - "</div>\n"; + "<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'}) . $ref) . "\n"; + print "</div>\n"; print "<div class=\"title_text\">\n" . "<div class=\"log_link\">\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . @@ -1981,23 +2008,18 @@ sub git_commitdiff_plain { # try to figure out the next tag after this commit my $tagname; - my %taghash; - my $tags = git_read_refs("refs/tags"); - foreach my $entry (@$tags) { - my %tag = %$entry; - $taghash{$tag{'refid'}} = $tag{'name'}; - } + my $refs = read_info_ref(); open $fd, "-|", "$gitbin/git-rev-list HEAD"; - while (my $commit = <$fd>) { - chomp $commit; - if ($taghash{$commit}) { - $tagname = $taghash{$commit}; + chomp (my (@commits) = <$fd>); + close $fd; + foreach my $commit (@commits) { + if (defined $refs->{$commit}) { + $tagname = $refs->{$commit} } if ($commit eq $hash) { last; } } - close $fd; print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\""); my %co = git_read_commit($hash); @@ -2041,6 +2063,7 @@ sub git_history { if (!%co) { die_error(undef, "Unknown commit object."); } + my $refs = read_info_ref(); git_header_html(); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -2070,6 +2093,10 @@ sub git_history { if (!%co) { next; } + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + } if ($alternate) { print "<tr class=\"dark\">\n"; } else { @@ -2079,7 +2106,7 @@ sub git_history { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . - esc_html(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" . + esc_html(chop_str($co{'title'}, 50)) . "</b>") . "$ref</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . @@ -2254,6 +2281,7 @@ sub git_shortlog { if (!defined $page) { $page = 0; } + my $refs = read_info_ref(); git_header_html(); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -2312,6 +2340,9 @@ sub git_shortlog { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . esc_html($co{'title_short'}) . "</b>"); } + if (defined $refs->{$commit}) { + print " <span class=\"tag\">$refs->{$commit}</span>"; + } print "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . From 4cdd1f9031fefce45423de13ad987bbde45e363e Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 09:47:34 +0100 Subject: [PATCH 126/148] v258 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 01920b003f8..605e4b5015f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "257"; +my $version = "258"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 045e531a8f2ef75605ec839d66d80abe126647b4 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 10:12:55 +0100 Subject: [PATCH 127/148] show multiple tags Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 605e4b5015f..ad8c6deea1c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -912,7 +912,11 @@ sub read_info_ref { open my $fd, "$projectroot/$project/info/refs" or return; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) { - $refs{$1} = $2; + if (defined $refs{$1}) { + $refs{$1} .= " / $2"; + } else { + $refs{$1} = $2; + } } } close $fd or return; From 70dd8acb9a9c0964efcea114e68fea47021fdd37 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 10:13:19 +0100 Subject: [PATCH 128/148] v259 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index ad8c6deea1c..49206b11d7f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "258"; +my $version = "259"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 4df11910716b25bc7720ee25950c6b81734a2674 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 10:51:42 +0100 Subject: [PATCH 129/148] attach tag to the link Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 49206b11d7f..f56d3036901 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -312,7 +312,7 @@ a.rss_logo { } a.rss_logo:hover { background-color:#ee5500; } span.tag { - padding:0px 4px; font-size:10px; + padding:0px 4px; font-size:10px; font-weight:normal; background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc; } </style> @@ -906,12 +906,13 @@ sub git_project_list { } sub read_info_ref { + my $type = shift || ""; my %refs; # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{} open my $fd, "$projectroot/$project/info/refs" or return; while (my $line = <$fd>) { - if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) { + if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\^]+)/) { if (defined $refs{$1}) { $refs{$1} .= " / $2"; } else { @@ -1047,18 +1048,19 @@ sub git_summary { } $alternate ^= 1; if ($i-- > 0) { + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + } print "<td><i>$co{'age_string'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "<b>" . esc_html($co{'title_short'}) . "</b>"); + "<b>" . esc_html($co{'title_short'}) . "$ref</b>"); } else { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, - "<b>" . esc_html($co{'title'}) . "</b>"); - } - if (defined $refs->{$commit}) { - print " <span class=\"tag\">$refs->{$commit}</span>"; + "<b>" . esc_html($co{'title'}) . "$ref</b>"); } print "</td>\n" . "<td class=\"link\">" . @@ -2012,7 +2014,7 @@ sub git_commitdiff_plain { # try to figure out the next tag after this commit my $tagname; - my $refs = read_info_ref(); + my $refs = read_info_ref("tags"); open $fd, "-|", "$gitbin/git-rev-list HEAD"; chomp (my (@commits) = <$fd>); close $fd; @@ -2110,7 +2112,7 @@ sub git_history { print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" . "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" . - esc_html(chop_str($co{'title'}, 50)) . "</b>") . "$ref</td>\n" . + esc_html(chop_str($co{'title'}, 50)) . "$ref</b>") . "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . @@ -2326,6 +2328,10 @@ sub git_shortlog { my $alternate = 0; for (my $i = ($page * 100); $i <= $#revlist; $i++) { my $commit = $revlist[$i]; + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + } my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); if ($alternate) { @@ -2339,13 +2345,10 @@ sub git_shortlog { "<td>"; if (length($co{'title_short'}) < length($co{'title'})) { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "<b>" . esc_html($co{'title_short'}) . "</b>"); + "<b>" . esc_html($co{'title_short'}) . "$ref</b>"); } else { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, - "<b>" . esc_html($co{'title_short'}) . "</b>"); - } - if (defined $refs->{$commit}) { - print " <span class=\"tag\">$refs->{$commit}</span>"; + "<b>" . esc_html($co{'title_short'}) . "$ref</b>"); } print "</td>\n" . "<td class=\"link\">" . From 4e8c09a331ca3917c45dfe646213b604af19db95 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 10:51:59 +0100 Subject: [PATCH 130/148] v260 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index f56d3036901..9222ca0fe7a 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "259"; +my $version = "260"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From edde3735d06e2581647308966a6b7a77d09a1427 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 16:10:01 +0100 Subject: [PATCH 131/148] more tags Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 9222ca0fe7a..1f5a409bf1f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1050,7 +1050,7 @@ sub git_summary { if ($i-- > 0) { my $ref = ""; if (defined $refs->{$commit}) { - $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + $ref = " <span class=\"tag\">" . esc_html($refs->{$commit}) . "</span>"; } print "<td><i>$co{'age_string'}</i></td>\n" . "<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" . @@ -1417,6 +1417,11 @@ sub git_tree { close $fd or die_error(undef, "Reading tree failed."); $/ = "\n"; + my $refs = read_info_ref(); + my $ref = ""; + if (defined $refs->{$hash_base}) { + $ref = " <span class=\"tag\">" . esc_html($refs->{$hash_base}) . "</span>"; + } git_header_html(); my $base_key = ""; my $base = ""; @@ -1432,7 +1437,7 @@ sub git_tree { "<br/><br/>\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" . "</div>\n"; } else { print "<div class=\"page_nav\">\n"; @@ -1629,7 +1634,7 @@ sub git_log { my $commit = $revlist[$i]; my $ref = ""; if (defined $refs->{$commit}) { - $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + $ref = " <span class=\"tag\">" . esc_html($refs->{$commit}) . "</span>"; } my %co = git_read_commit($commit); next if !%co; @@ -1695,6 +1700,11 @@ sub git_commit { if ($hash =~ m/^[0-9a-fA-F]{40}$/) { $expires = "+1d"; } + my $refs = read_info_ref(); + my $ref = ""; + if (defined $refs->{$hash}) { + $ref = " <span class=\"tag\">" . esc_html($refs->{$hash}) . "</span>"; + } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -1708,7 +1718,7 @@ sub git_commit { "<br/><br/></div>\n"; if (defined $co{'parent'}) { print "<div>\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" . "</div>\n"; } else { print "<div>\n" . @@ -1932,6 +1942,11 @@ sub git_commitdiff { if ($hash =~ m/^[0-9a-fA-F]{40}$/) { $expires = "+1d"; } + my $refs = read_info_ref(); + my $ref = ""; + if (defined $refs->{$hash}) { + $ref = " <span class=\"tag\">" . esc_html($refs->{$hash}) . "</span>"; + } git_header_html(undef, $expires); print "<div class=\"page_nav\">\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -1943,7 +1958,7 @@ sub git_commitdiff { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . "</div>\n"; print "<div>\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" . "</div>\n"; print "<div class=\"page_body\">\n"; my $comment = $co{'comment'}; @@ -2101,7 +2116,7 @@ sub git_history { } my $ref = ""; if (defined $refs->{$commit}) { - $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + $ref = " <span class=\"tag\">" . esc_html($refs->{$commit}) . "</span>"; } if ($alternate) { print "<tr class=\"dark\">\n"; @@ -2330,7 +2345,7 @@ sub git_shortlog { my $commit = $revlist[$i]; my $ref = ""; if (defined $refs->{$commit}) { - $ref = " <span class=\"tag\">$refs->{$commit}</span>"; + $ref = " <span class=\"tag\">" . esc_html($refs->{$commit}) . "</span>"; } my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); From c2488d064bb5225e8d816f9ca8e8ee904bf6eb92 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 16:32:51 +0100 Subject: [PATCH 132/148] fix leading whitespace in commit text Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1f5a409bf1f..1c93192fc35 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -531,6 +531,7 @@ sub git_read_commit { }; 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 @@ -912,6 +913,7 @@ sub read_info_ref { # 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"; @@ -2056,7 +2058,7 @@ sub git_commitdiff_plain { "\n"; foreach my $line (@$comment) {; - print " $line\n"; + print "$line\n"; } print "---\n\n"; From fdeb2fb6166904adc6396c6eeb5b89f6f81b5ef7 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Wed, 7 Dec 2005 16:33:08 +0100 Subject: [PATCH 133/148] v261 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1c93192fc35..d025320027f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "260"; +my $version = "261"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 8240accb65872589f9721dab681708055adc3c1c Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 19 Dec 2005 04:09:02 +0100 Subject: [PATCH 134/148] define default colors Thanks to Kir Kolyshkin for pointing it out. Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index d025320027f..63a01693959 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -260,7 +260,10 @@ sub git_header_html { <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; } From 212848746e2cdfab6bd262a99376214b660e61b8 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 19 Dec 2005 04:09:32 +0100 Subject: [PATCH 135/148] v262 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 63a01693959..3735535c8ba 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "261"; +my $version = "262"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From d3a6fd94863b618893f300b98588c47921c9cf86 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Thu, 22 Dec 2005 22:58:29 +0100 Subject: [PATCH 136/148] resolve textual hashes when looking up "refs" Thanks to Jon Nelson for the patch. Signed-off-by: Kay Sievers <kay.sievers@suse.de> --- gitweb.cgi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 3735535c8ba..1814f7f2b37 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1707,8 +1707,8 @@ sub git_commit { } 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" . @@ -1949,8 +1949,8 @@ sub git_commitdiff { } 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" . From df2c37a5a1087b445589e366f6673ded8fdef7f0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano <junkio@cox.net> Date: Mon, 9 Jan 2006 13:13:39 +0100 Subject: [PATCH 137/148] allow working in repositories with textual symref HEAD --- gitweb.cgi | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1814f7f2b37..26c73958ffe 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -396,6 +396,23 @@ sub git_get_type { 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; + chomp $head; + if ($head =~ m/^[0-9a-fA-F]{40}$/) { + $retval = $head; + } + } + $ENV{'GIT_DIR'} = $oENV; + return $retval; +} + sub git_read_hash { my $path = shift; @@ -823,7 +840,7 @@ sub git_project_list { 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; } @@ -994,7 +1011,7 @@ sub git_read_refs { 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'}); @@ -1034,7 +1051,7 @@ sub git_summary { "<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" . @@ -1172,7 +1189,7 @@ sub git_summary { } 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") . @@ -1211,7 +1228,7 @@ sub git_tag { } 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") . @@ -1270,7 +1287,7 @@ sub git_tags { } 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") . @@ -1343,7 +1360,7 @@ sub git_get_hash_by_path { 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."); @@ -1407,13 +1424,13 @@ sub git_blob_plain { 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"; @@ -1497,7 +1514,7 @@ sub git_tree { 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'); @@ -1566,7 +1583,7 @@ sub git_opml { 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; } @@ -1587,7 +1604,7 @@ sub git_opml { } sub git_log { - my $head = git_read_hash("$project/HEAD"); + my $head = git_read_head($project); if (!defined $hash) { $hash = $head; } @@ -2083,7 +2100,7 @@ sub git_commitdiff_plain { 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) { @@ -2159,7 +2176,7 @@ sub git_search { 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) { @@ -2300,7 +2317,7 @@ sub git_search { } sub git_shortlog { - my $head = git_read_hash("$project/HEAD"); + my $head = git_read_head($project); if (!defined $hash) { $hash = $head; } From f76ddc20159256a1bc6e3ba81910ae94faaf2fa8 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 9 Jan 2006 13:14:00 +0100 Subject: [PATCH 138/148] v263 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 26c73958ffe..986d7dacd60 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "262"; +my $version = "263"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 2c5c008b462fd5d2e32318077aaa3bc4e67c84fd Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 17 Jan 2006 03:50:20 +0100 Subject: [PATCH 139/148] fix: Use of uninitialized value The subroutine did not check the case where HEAD does not verify. Patch from Junio C Hamano <junkio@cox.net> --- gitweb.cgi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 986d7dacd60..cb033733b9e 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -404,12 +404,13 @@ sub git_read_head { if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") { my $head = <$fd>; close $fd; - chomp $head; - if ($head =~ m/^[0-9a-fA-F]{40}$/) { - $retval = $head; + if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) { + $retval = $1; } } - $ENV{'GIT_DIR'} = $oENV; + if (defined $oENV) { + $ENV{'GIT_DIR'} = $oENV; + } return $retval; } From 2326acfa95ac86a53804ca8eeeb482c2f9265e34 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 17 Jan 2006 03:50:44 +0100 Subject: [PATCH 140/148] v264 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index cb033733b9e..c1bb62459d7 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "263"; +my $version = "264"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 281bf0cf4e1646237daa15ab6b032d6dd9aee0c9 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 1 May 2006 03:40:22 +0200 Subject: [PATCH 141/148] handle utf8 characters from /etc/passwd --- gitweb.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index c1bb62459d7..9056a7fda9a 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -787,7 +787,7 @@ sub get_file_owner { } my $owner = $gcos; $owner =~ s/[,;].*$//; - return $owner; + return decode("utf8", $owner, Encode::FB_DEFAULT); } sub git_read_projects { @@ -823,7 +823,7 @@ 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 } @@ -1025,7 +1025,7 @@ sub git_summary { $pr = unescape($pr); $ow = unescape($ow); if ($pr eq $project) { - $owner = $ow; + $owner = decode("utf8", $ow, Encode::FB_DEFAULT); last; } } From 8872653e5a75a2bfdb0955191575236f199549e6 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 1 May 2006 03:40:54 +0200 Subject: [PATCH 142/148] v265 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 9056a7fda9a..92cb0794eea 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "264"; +my $version = "265"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 00cd07943a8868eed41ac9debb03f3bbc1a512c3 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 22 May 2006 14:30:47 +0200 Subject: [PATCH 143/148] remove Christian's email address --- gitweb.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 92cb0794eea..6f79eafa94c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -2,8 +2,8 @@ # 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 @@ -253,7 +253,7 @@ sub git_header_html { <?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"/> From 9e4f7d9a5dc724a94ef9452e22b654e510a710e9 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Mon, 22 May 2006 14:31:09 +0200 Subject: [PATCH 144/148] v266 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 6f79eafa94c..016045e2ab1 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "265"; +my $version = "266"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From bfb689bcf33addfe3fdfe8cb214a661c9d6d4b19 Mon Sep 17 00:00:00 2001 From: Rocco Rutte <pdmef@gmx.net> Date: Tue, 30 May 2006 14:40:10 +0200 Subject: [PATCH 145/148] prepend '--' to filelist when calling git-diff-tree --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 016045e2ab1..9ee24b8c4bf 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -2123,7 +2123,7 @@ sub git_history { "</div>\n"; print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b><br/></div>\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin \'$file_name\'"; + open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -- \'$file_name\'"; my $commit; print "<table cellspacing=\"0\">\n"; my $alternate = 0; From 1130ef362fc8d9c3422c23f5d5a833e93d3f5c13 Mon Sep 17 00:00:00 2001 From: Kay Sievers <kay.sievers@suse.de> Date: Tue, 30 May 2006 14:41:04 +0200 Subject: [PATCH 146/148] v267 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 9ee24b8c4bf..ea21fbe88a9 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "266"; +my $version = "267"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; From 52ba03cbb1c718093946f5254187082bd7b32845 Mon Sep 17 00:00:00 2001 From: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Date: Sat, 10 Jun 2006 16:13:41 +0200 Subject: [PATCH 147/148] Built-in git-get-tar-commit-id By being an internal command git-get-commit-id can make use of struct ustar_header and other stuff and stops wasting precious disk space. Note: I recycled one of the two "tar-tree" entries instead of splitting that cleanup into a separate patch. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <junkio@cox.net> --- Makefile | 4 ++-- builtin-tar-tree.c | 25 +++++++++++++++++++++++++ builtin.h | 1 + get-tar-commit-id.c | 30 ------------------------------ git.c | 2 +- 5 files changed, 29 insertions(+), 33 deletions(-) delete mode 100644 get-tar-commit-id.c diff --git a/Makefile b/Makefile index 5226fa1881b..2a1e6392ddd 100644 --- a/Makefile +++ b/Makefile @@ -144,7 +144,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ # The ones that do not have to link with lcrypto, lz nor xdiff. SIMPLE_PROGRAMS = \ - git-get-tar-commit-id$X git-mailsplit$X \ + git-mailsplit$X \ git-stripspace$X git-daemon$X # ... and all the rest that could be moved out of bindir to gitexecdir @@ -169,7 +169,7 @@ BUILT_INS = git-log$X git-whatchanged$X git-show$X \ git-grep$X git-add$X git-rm$X git-rev-list$X \ git-check-ref-format$X git-rev-parse$X \ git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \ - git-ls-files$X git-ls-tree$X \ + git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \ git-read-tree$X git-commit-tree$X \ git-apply$X git-show-branch$X git-diff-files$X \ git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c index 7663b9bd8e5..58a8ccd4d6a 100644 --- a/builtin-tar-tree.c +++ b/builtin-tar-tree.c @@ -402,3 +402,28 @@ int cmd_tar_tree(int argc, const char **argv, char **envp) return remote_tar(argc, argv); return generate_tar(argc, argv, envp); } + +/* ustar header + extended global header content */ +#define HEADERSIZE (2 * RECORDSIZE) + +int cmd_get_tar_commit_id(int argc, const char **argv, char **envp) +{ + char buffer[HEADERSIZE]; + struct ustar_header *header = (struct ustar_header *)buffer; + char *content = buffer + RECORDSIZE; + ssize_t n; + + n = xread(0, buffer, HEADERSIZE); + if (n < HEADERSIZE) + die("git-get-tar-commit-id: read error"); + if (header->typeflag[0] != 'g') + return 1; + if (memcmp(content, "52 comment=", 11)) + return 1; + + n = xwrite(1, content + 11, 41); + if (n < 41) + die("git-get-tar-commit-id: write error"); + + return 0; +} diff --git a/builtin.h b/builtin.h index ffa9340c377..b9f36beb660 100644 --- a/builtin.h +++ b/builtin.h @@ -32,6 +32,7 @@ extern int cmd_check_ref_format(int argc, const char **argv, char **envp); extern int cmd_init_db(int argc, const char **argv, char **envp); extern int cmd_tar_tree(int argc, const char **argv, char **envp); extern int cmd_upload_tar(int argc, const char **argv, char **envp); +extern int cmd_get_tar_commit_id(int argc, const char **argv, char **envp); extern int cmd_ls_files(int argc, const char **argv, char **envp); extern int cmd_ls_tree(int argc, const char **argv, char **envp); extern int cmd_read_tree(int argc, const char **argv, char **envp); diff --git a/get-tar-commit-id.c b/get-tar-commit-id.c deleted file mode 100644 index 416629035c1..00000000000 --- a/get-tar-commit-id.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2005 Rene Scharfe - */ -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#define HEADERSIZE 1024 - -int main(int argc, char **argv) -{ - char buffer[HEADERSIZE]; - ssize_t n; - - n = read(0, buffer, HEADERSIZE); - if (n < HEADERSIZE) { - fprintf(stderr, "read error\n"); - return 3; - } - if (buffer[156] != 'g') - return 1; - if (memcmp(&buffer[512], "52 comment=", 11)) - return 1; - n = write(1, &buffer[523], 41); - if (n < 41) { - fprintf(stderr, "write error\n"); - return 2; - } - return 0; -} diff --git a/git.c b/git.c index 6db8f2bc23a..9469d44b4bc 100644 --- a/git.c +++ b/git.c @@ -163,7 +163,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "add", cmd_add }, { "rev-list", cmd_rev_list }, { "init-db", cmd_init_db }, - { "tar-tree", cmd_tar_tree }, + { "get-tar-commit-id", cmd_get_tar_commit_id }, { "upload-tar", cmd_upload_tar }, { "check-ref-format", cmd_check_ref_format }, { "ls-files", cmd_ls_files }, From 41292ddd37202ff6dce34986c87a6000c5d3fbfa Mon Sep 17 00:00:00 2001 From: Junio C Hamano <junkio@cox.net> Date: Sat, 10 Jun 2006 12:41:54 -0700 Subject: [PATCH 148/148] GIT 1.4.0 Signed-off-by: Junio C Hamano <junkio@cox.net> --- GIT-VERSION-GEN | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index a461518cdee..5d25b7e12b8 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.3.GIT +DEF_VER=v1.4.GIT # First try git-describe, then see if there is a version file # (included in release tarballs), then default