X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=gitweb.cgi;h=a7a7edf720e792bf76c89732e536f4a3eb99bb5c;hb=a4d26ef062e68d276f94fa8be9130375a3b9ebe8;hp=619db534a3c1a74880c0bbd16ca35a1f679a7b12;hpb=c07ad4b97128d26949ed34a2fd4a3a7039278fe8;p=git.git diff --git a/gitweb.cgi b/gitweb.cgi index 619db534..a7a7edf7 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 = "133"; +my $version = "154"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -29,12 +30,14 @@ 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"; # 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'); @@ -48,7 +51,7 @@ if (defined $action) { exit; } } else { - $action = "log"; + $action = "summary"; } my $project = $cgi->param('p'); @@ -70,9 +73,10 @@ if (defined $project) { die_error(undef, "No such project."); } $rss_link = ""; + $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; } else { - git_project_list($projects_list); + git_project_list(); exit; } @@ -114,7 +118,16 @@ if (defined $time_back) { } } -if ($action eq "blob") { +if ($action eq "summary") { + git_summary(); + exit; +} elsif ($action eq "branches") { + git_branches(); + exit; +} elsif ($action eq "tags") { + git_tags(); + exit; +} elsif ($action eq "blob") { git_blob(); exit; } elsif ($action eq "tree") { @@ -183,19 +196,19 @@ 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; } -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; } @@ -205,6 +218,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,11 +231,11 @@ a.rss_logo:hover { background-color:#ee5500; }
EOF print "Project | \n" . "Description | \n" . "Owner | \n" . "last change | \n" . + "\n" . " | ||
---|---|---|---|---|---|---|
" . $cgi->a({-href => "$my_uri?p=" . $proj{'path'} . ";a=log"}, escapeHTML($proj{'path'})) . " | \n" . + "" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, escapeHTML($proj{'path'})) . " | \n" . "$descr | \n" . "$proj{'owner'} | \n"; + my $colored_age; if ($co{'age'} < 60*60*2) { - print "$co{'age_string'} | \n"; + $colored_age = "$co{'age_string'}"; } elsif ($co{'age'} < 60*60*24*2) { - print "$co{'age_string'} | \n"; + $colored_age = "$co{'age_string'}"; } else { - print "$co{'age_string'} | \n"; + $colored_age = "$co{'age_string'}"; } - print "$colored_age | \n" . + "" . + $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") . + " | \n" . + "\n"; } print "
description | " . escapeHTML($descr) . " |
owner | $owner |
last change | $cd{'rfc2822'} |
$co{'age_string'} | \n" . + "$co{'author_name'} | \n" . + "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . " | \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") . + " | \n" . + "" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . " | \n" . + ""; + last; + } + } + print "
$tag{'age'} | \n" . + "" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, escapeHTML($tag{'name'})) . " | \n" . + "" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . " | \n" . + ""; + last; + } + } + print "
$tag{'age'} | \n" . + "" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, escapeHTML($tag{'name'})) . " | \n" . + "" . $cgi->a({-href => "$my_uri?p=$project;a=branches"}, "...") . " | \n" . + ""; + last; + } + } + print "
author | " . escapeHTML($co{'author'}) . " |
" . $ad{'rfc2822'}; + " | |
$ad{'rfc2822'}"; if ($ad{'hour_local'} < 6) { printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } else { @@ -886,10 +1158,10 @@ sub git_commit { } print " | |
committer | " . escapeHTML($co{'committer'}) . " |
" . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . " | |
$cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . " | |
commit | $hash |
tree | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . " |
parent | " .
@@ -911,7 +1183,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 "" . escapeHTML($line) . " \n"; } else { @@ -944,9 +1216,9 @@ sub git_commit { } print " \n" .
$cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"},
- escapeHTML($file) . " [new " . file_type($mode) . $mode_chng . "]") . "\n" .
+ escapeHTML($file) . " [new " . file_type($mode) . "$mode_chng]") . "\n" .
" \n";
- print "\n" .
+ print " ";
- print "\n" .
$cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" .
" \n";
} elsif ($op eq "-") {
@@ -954,7 +1226,7 @@ sub git_commit {
$cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"},
escapeHTML($file) . " [deleted " . file_type($mode) . "]") . "\n" .
"\n" .
+ print " \n";
}
- print "\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" .
" \n";
@@ -967,7 +1239,7 @@ sub git_commit {
my $to_mode = $2;
my $mode_chnge = "";
if ($from_mode != $to_mode) {
- $mode_chnge = " [changed";
+ $mode_chnge = " [changed";
if (((oct $from_mode) & S_IFMT) != ((oct $to_mode) & S_IFMT)) {
$mode_chnge .= " from " . file_type($from_mode) . " to " . file_type($to_mode);
}
@@ -990,7 +1262,7 @@ sub git_commit {
escapeHTML($file) . $mode_chnge) . "\n" .
"\n";
+ print " \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") . " | ";
}
@@ -1008,9 +1280,10 @@ sub git_blobdiff {
git_header_html();
if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
print " \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");
+ " | " . $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");
}
@@ -1046,20 +1319,45 @@ 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.");
git_header_html();
print " \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") .
" \n";
print "\n" .
$cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
" \n";
print "\n";
+ my $comment = $co{'comment'};
+ my $empty = 0;
+ my $signed = 0;
+ my @log = @$comment;
+ # remove first and empty lines after that
+ 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;
+ }
+ if ($line eq "") {
+ if ($empty) {
+ next;
+ }
+ $empty = 1;
+ } else {
+ $empty = 0;
+ }
+ print escapeHTML($line) . " \n"; + } + print " \n"; foreach my $line (@difftree) { # '*100644->100644 blob 8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154 Makefile' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; @@ -1104,7 +1402,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) { @@ -1114,7 +1412,7 @@ sub git_history { print " \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") .
" \n";
print "\n" . " \n" .
@@ -1142,16 +1440,16 @@ sub git_history {
}
print " \n" .
$cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"},
- "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" .
+ "$co{'age_string'}" . escapeHTML($co{'title'})) . "\n" .
" \n";
- print "\n" .
+ print " \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 " \n";
\n" . " |