X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/b714336e52b0c1baed460c23ea54c2519d989061ff1113bb5b6bb7049a738484..b6fd76222eb509ba29552c1df7ad05e8df856e8dee500e63062552f85f89ced8:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index 30a7b98..83435a3 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 = "164"; 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; } @@ -258,9 +256,10 @@ sub die_error { git_header_html($status); print "
\n" . - "

\n"; - print "$status - $error\n"; - print "
\n"; + "

\n" . + "$status - $error\n" . + "
\n" . + "\n"; git_footer_html(); exit; } @@ -306,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; } } @@ -328,16 +327,19 @@ 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; $co{'author_epoch'} = $2; $co{'author_tz'} = $3; - $co{'author_name'} = $co{'author'}; - $co{'author_name'} =~ s/ <.*//; + if ($co{'author'} =~ m/^([^<]+) ; $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'}; @@ -468,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; @@ -556,9 +566,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; @@ -592,8 +603,7 @@ sub git_project_list { close $fd; print "\n"; } - print "

\n" . - "\n" . + print "
\n" . "\n" . "\n" . "\n" . @@ -601,6 +611,7 @@ sub git_project_list { "\n" . "\n" . "\n"; + my $alternate = 0; foreach my $pr (@list) { my %proj = %$pr; my $head = git_read_hash("$proj{'path'}/HEAD"); @@ -614,14 +625,20 @@ 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'}") || ""; } - print "\n" . - "\n" . + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; + print "\n" . "\n" . - "\n"; + "\n"; my $colored_age; if ($co{'age'} < 60*60*2) { $colored_age = "$co{'age_string'}"; @@ -637,9 +654,7 @@ sub git_project_list { "\n" . "\n"; } - print "
ProjectDescriptionlast change
" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "
" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "$descr$proj{'owner'}" . chop_str($proj{'owner'}, 20) . "
\n" . - "
\n" . - "
\n"; + print "\n"; git_footer_html(); } @@ -714,29 +729,32 @@ sub git_summary { "

\n" . "\n"; print "
project
\n"; - print "
\n" . - "\n" . + print "
\n" . "\n" . "\n" . "\n" . - "
description" . escapeHTML($descr) . "
owner$owner
last change$cd{'rfc2822'}
\n" . - "
\n"; - open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); + "\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 "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "commits") . "
\n"; - my $i = 10; - print "
\n" . - "\n"; + my $i = 15; + print "
\n"; + my $alternate = 0; foreach my $commit (@revlist) { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); - print "\n"; + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; if (--$i > 0) { print "\n" . - "\n" . + "\n" . "\n" . "
$co{'age_string'}$co{'author_name'}" . escapeHTML(chop_str($co{'author_name'}, 10)) . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "" . escapeHTML($co{'title'}) . "") . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . @@ -749,20 +767,24 @@ sub git_summary { last; } } - print "" . - "\n"; + print ""; my $taglist = git_read_refs("refs/tags"); if (defined @$taglist) { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "tags") . "
\n"; - my $i = 10; - print "
\n" . - "\n"; + my $i = 15; + print "
\n"; + my $alternate = 0; foreach my $entry (@$taglist) { my %tag = %$entry; - print "\n"; + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; if (--$i > 0) { print "\n" . "\n" . @@ -774,8 +796,7 @@ sub git_summary { last; } } - print "" . - "\n"; + print ""; } my $branchlist = git_read_refs("refs/heads"); @@ -783,12 +804,17 @@ sub git_summary { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=branches", -class => "title"}, "branches") . "
\n"; - my $i = 10; - print "
\n" . - "
$tag{'age'}" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}", -class => "list"}, "" . escapeHTML($tag{'name'}) . "") . "
\n"; + my $i = 15; + print "
\n"; + my $alternate = 0; foreach my $entry (@$branchlist) { my %tag = %$entry; - print "\n"; + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; if (--$i > 0) { print "\n" . "\n" . @@ -800,8 +826,7 @@ sub git_summary { last; } } - print "" . - "\n"; + print ""; } git_footer_html(); } @@ -819,20 +844,24 @@ sub git_tags { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "tags") . "
\n"; - print "
\n" . - "
$tag{'age'}" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "" . escapeHTML($tag{'name'}) . "") . "
\n"; + print "
\n"; + my $alternate = 0; if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; - print "\n" . - "\n" . + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; + print "\n" . "\n" . "\n" . ""; } } - print "" . - "\n"; + print ""; git_footer_html(); } @@ -849,20 +878,24 @@ sub git_branches { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary", -class => "title"}, "branches") . "
\n"; - print "
\n" . - "
$tag{'age'}
$tag{'age'}" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "" . escapeHTML($tag{'name'}) . "") . "" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, $tag{'type'}) . "
\n"; + print "
\n"; + my $alternate = 0; if (defined @$taglist) { foreach my $entry (@$taglist) { my %tag = %$entry; - print "\n" . - "\n" . + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; + print "\n" . "\n" . "\n" . ""; } } - print "" . - "\n"; + print ""; git_footer_html(); } @@ -878,7 +911,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; @@ -983,16 +1016,22 @@ sub git_tree { } print "
\n"; print "
$tag{'age'}
$tag{'age'}" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}", -class => "list"}, "" . escapeHTML($tag{'name'}) . "") . "" . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'id'}"}, "log") . "
\n"; + 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; my $t_name = $4; $file_key = ";f=$base$t_name"; - print "\n" . - "\n"; + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; + print "\n"; if ($t_type eq "blob") { print "\n"; + print "\n"; } print "\n"; } @@ -1156,22 +1198,34 @@ sub git_commit { print "
\n" . "
" . mode_str($t_mode) . "
" . mode_str($t_mode) . "" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key, -class => "list"}, $t_name) . @@ -1005,6 +1044,9 @@ sub git_tree { print "" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . + "
\n"; print "\n". - "" . + "\n"; + print "" . + "\n"; print "\n"; print "\n"; print "\n"; - print "\n"; + print "" . + "" . + "" . + "" . + "\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "\n"; + print "" . + "" . + "" . + "" . + "\n"; } 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 { printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } - print "
committer" . escapeHTML($co{'committer'}) . "
$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'}) . "
tree" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", class => "list"}, $co{'tree'}) . "" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . + "
parent" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
parent" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par", class => "list"}, $par) . "" . + $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") . + "
". "
\n"; @@ -1203,14 +1257,14 @@ sub git_commit { print(($#difftree + 1) . " files changed:\n"); } print "\n"; - print "
\n" . - "\n"; + print "
\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(.*)\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; @@ -1219,7 +1273,12 @@ sub git_commit { if ($type ne "blob") { next; } - print "\n"; + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; if ($op eq "+") { my $mode_chng = ""; if (S_ISREG(oct $mode)) { @@ -1277,8 +1336,7 @@ sub git_commit { } print "\n"; } - print "

\n" . - "
\n"; + print "
\n"; git_footer_html(); } @@ -1326,7 +1384,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."); @@ -1367,7 +1428,7 @@ sub git_commitdiff { print "
\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; @@ -1431,43 +1492,42 @@ sub git_history { open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; my $commit; - print "
\n" . - "\n"; + print "
\n"; + my $alternate = 0; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40}) /){ $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; } - print "" . - "\n" . - "\n" . + if ($alternate) { + print "\n"; + } else { + print "\n"; + } + $alternate ^= 1; + print "\n" . + "\n" . "\n" . "\n" . "\n"; undef $commit; } } - print "
$co{'age_string'}$co{'author_name'}
$co{'age_string'}" . escapeHTML(chop_str($co{'author_name'}, 10)) . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "" . escapeHTML($co{'title'}) . "") . "" . $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 "

\n" . - "
\n"; + print "\n"; close $fd; git_footer_html(); }