From: Junio C Hamano Date: Fri, 28 Jul 2006 20:19:38 +0000 (-0700) Subject: Merge branch 'lt/web' X-Git-Tag: v1.4.2-rc3~40 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/556032566e96580e0ea0063a9aead0b380f9c8f7?ds=inline;hp=-c Merge branch 'lt/web' --- 556032566e96580e0ea0063a9aead0b380f9c8f7 diff --combined gitweb/gitweb.cgi index 30cb624b2a,4106cb8eb6..243a2921f8 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@@ -795,7 -795,7 +795,7 @@@ sub git_read_projects if (-d $projects_list) { # search in directory my $dir = $projects_list; - opendir my $dh, $dir or return undef; + opendir my ($dh), $dir or return undef; while (my $dir = readdir($dh)) { if (-e "$projectroot/$dir/HEAD") { my $pr = { @@@ -810,7 -810,7 +810,7 @@@ # 'git%2Fgit.git Linus+Torvalds' # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin' # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman' - open my $fd , $projects_list or return undef; + open my ($fd), $projects_list or return undef; while (my $line = <$fd>) { chomp $line; my ($path, $owner) = split ' ', $line; @@@ -1138,7 -1138,7 +1138,7 @@@ sub git_summary "\n" . ""; if (defined($comment)) { - print $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("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'}")}, esc_html($comment)); } print "\n" . ""; @@@ -1199,6 -1199,20 +1199,20 @@@ git_footer_html(); } + sub git_print_page_path { + my $name = shift; + my $type = shift; + + if (!defined $name) { + print "
/
\n"; + } elsif ($type =~ "blob") { + print "
" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$file_name")}, esc_html($name)) . "
\n"; + } else { + print "
" . esc_html($name) . "
\n"; + } + } + sub git_tag { my $head = git_read_head($project); git_header_html(); @@@ -1266,7 -1280,7 +1280,7 @@@ sub git_blame "
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "
\n"; - print "
" . esc_html($file_name) . "
\n"; + git_print_page_path($file_name); print "
\n"; print < @@@ -1531,6 -1545,14 +1545,14 @@@ sub git_blob_plain_mimetype } sub git_blob_plain { + if (!defined $hash) { + if (defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file."); + } else { + die_error(undef, "No file name defined."); + } + } my $type = shift; open my $fd, "-|", "$GIT cat-file blob $hash" or die_error("Couldn't cat $file_name, $hash"); @@@ -1554,10 -1576,14 +1576,14 @@@ } 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") || die_error(undef, "Error lookup file."); - } + if (!defined $hash) { + if (defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file."); + } else { + die_error(undef, "No file name defined."); + } + } my $have_blame = git_get_project_config_bool ('blame'); open my $fd, "-|", "$GIT cat-file blob $hash" or die_error(undef, "Open failed."); my $mimetype = git_blob_plain_mimetype($fd, $file_name); @@@ -1592,9 -1618,7 +1618,7 @@@ "

\n" . "
$hash
\n"; } - if (defined $file_name) { - print "
" . esc_html($file_name) . "
\n"; - } + git_print_page_path($file_name, "blob"); print "
\n"; my $nr; while (my $line = <$fd>) { @@@ -1659,10 -1683,8 +1683,8 @@@ sub git_tree } if (defined $file_name) { $base = esc_html("$file_name/"); - print "
/" . esc_html($file_name) . "
\n"; - } else { - print "
/
\n"; } + git_print_page_path($file_name); print "
\n"; print "\n"; my $alternate = 0; @@@ -1687,7 -1709,7 +1709,7 @@@ "\n"; } elsif ($t_type eq "tree") { @@@ -1696,7 -1718,7 +1718,7 @@@ "\n" . "\n"; } print "\n"; @@@ -2041,7 -2063,7 +2063,7 @@@ sub git_commit "\n" . "\n" } elsif ($status eq "M" || $status eq "T") { my $mode_chnge = ""; @@@ -2072,7 -2094,7 +2094,7 @@@ if ($to_id ne $from_id) { 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 => "$my_uri?" . esc_param("p=$project;a=history;h=$hash;f=$file")}, "history") . "\n"; + print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;hb=$hash;f=$file")}, "history") . "\n"; print "\n"; } elsif ($status eq "R") { my ($from_file, $to_file) = split "\t", $file; @@@ -2120,9 -2142,7 +2142,7 @@@ sub git_blobdiff "

\n" . "
$hash vs $hash_parent
\n"; } - if (defined $file_name) { - print "
/" . esc_html($file_name) . "
\n"; - } + git_print_page_path($file_name, "blob"); print "
\n" . "
blob:" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) . @@@ -2293,10 -2313,11 +2313,11 @@@ sub git_commitdiff_plain } sub git_history { - if (!defined $hash) { - $hash = git_read_head($project); + if (!defined $hash_base) { + $hash_base = git_read_head($project); } - my %co = git_read_commit($hash); + my $ftype; + my %co = git_read_commit($hash_base); if (!%co) { die_error(undef, "Unknown commit object."); } @@@ -2306,18 -2327,24 +2327,24 @@@ $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") . + " | " . $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") . "

\n" . "
\n"; print "
\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_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . "
\n"; - print "
/" . esc_html($file_name) . "
\n"; + if (!defined $hash && defined $file_name) { + $hash = git_get_hash_by_path($hash_base, $file_name); + } + if (defined $hash) { + $ftype = git_get_type($hash); + } + git_print_page_path($file_name, $ftype); open my $fd, "-|", - "$GIT rev-list --full-history $hash -- \'$file_name\'"; + "$GIT rev-list --full-history $hash_base -- \'$file_name\'"; print "
" . $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=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$t_hash;hb=$hash_base;f=$base$t_name")}, "history") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;hb=$hash_base;f=$base$t_name")}, "history") . "
[deleted " . file_type($from_mode). "]" . $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") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;hb=$hash;f=$file")}, "history") . "
\n"; my $alternate = 0; while (my $line = <$fd>) { @@@ -2345,7 -2372,7 +2372,7 @@@ $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 = git_get_hash_by_path($hash_base, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { print " | " .