3 # gitweb - simple web interface to track changes in git repositories
5 # (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
6 # (C) 2005, Christian Gierke
8 # This program is licensed under the GPLv2
12 use CGI
qw(:standard :escapeHTML -nosticky);
13 use CGI
::Util
qw(unescape);
14 use CGI
::Carp
qw(fatalsToBrowser);
18 use File
::Basename
qw(basename);
19 binmode STDOUT
, ':utf8';
22 our $version = "++GIT_VERSION++";
23 our $my_url = $cgi->url();
24 our $my_uri = $cgi->url(-absolute
=> 1);
26 # core git executable to use
27 # this can just be "git" if your webserver has a sensible PATH
28 our $GIT = "++GIT_BINDIR++/git";
30 # absolute fs-path which will be prepended to the project path
31 #our $projectroot = "/pub/scm";
32 our $projectroot = "++GITWEB_PROJECTROOT++";
34 # location for temporary files needed for diffs
35 our $git_temp = "/tmp/gitweb";
37 # target of the home link on top of all pages
38 our $home_link = $my_uri || "/";
40 # string of the home link on top of all pages
41 our $home_link_str = "++GITWEB_HOME_LINK_STR++";
43 # name of your site or organization to appear in page titles
44 # replace this with something more descriptive for clearer bookmarks
45 our $site_name = "++GITWEB_SITENAME++" || $ENV{'SERVER_NAME'} || "Untitled";
47 # html text to include at home page
48 our $home_text = "++GITWEB_HOMETEXT++";
50 # URI of default stylesheet
51 our $stylesheet = "++GITWEB_CSS++";
53 our $logo = "++GITWEB_LOGO++";
55 # source of projects list
56 our $projects_list = "++GITWEB_LIST++";
58 # list of git base URLs used for URL to where fetch project from,
59 # i.e. full URL is "$git_base_url/$project"
60 our @git_base_url_list = ("++GITWEB_BASE_URL++");
62 # default blob_plain mimetype and default charset for text/plain blob
63 our $default_blob_plain_mimetype = 'text/plain';
64 our $default_text_plain_charset = undef;
66 # file to use for guessing MIME types before trying /etc/mime.types
67 # (relative to the current git repository)
68 our $mimetypes_file = undef;
70 # You define site-wide feature defaults here; override them with
71 # $GITWEB_CONFIG as necessary.
73 # feature => {'sub' => feature-sub, 'override' => allow-override, 'default' => [ default options...]
74 # if feature is overridable, feature-sub will be called with default options;
75 # return value indicates if to enable specified feature
78 'sub' => \
&feature_blame
,
83 'sub' => \
&feature_snapshot
,
85 # => [content-encoding, suffix, program]
86 'default' => ['x-gzip', 'gz', 'gzip']},
89 sub gitweb_check_feature
{
91 return undef unless exists $feature{$name};
92 my ($sub, $override, @defaults) = (
93 $feature{$name}{'sub'},
94 $feature{$name}{'override'},
95 @
{$feature{$name}{'default'}});
96 if (!$override) { return @defaults; }
97 return $sub->(@defaults);
100 # To enable system wide have in $GITWEB_CONFIG
101 # $feature{'blame'}{'default'} = [1];
102 # To have project specific config enable override in $GITWEB_CONFIG
103 # $feature{'blame'}{'override'} = 1;
104 # and in project config gitweb.blame = 0|1;
107 my ($val) = git_get_project_config
('blame', '--bool');
109 if ($val eq 'true') {
111 } elsif ($val eq 'false') {
118 # To disable system wide have in $GITWEB_CONFIG
119 # $feature{'snapshot'}{'default'} = [undef];
120 # To have project specific config enable override in $GITWEB_CONFIG
121 # $feature{'blame'}{'override'} = 1;
122 # and in project config gitweb.snapshot = none|gzip|bzip2
124 sub feature_snapshot
{
125 my ($ctype, $suffix, $command) = @_;
127 my ($val) = git_get_project_config
('snapshot');
129 if ($val eq 'gzip') {
130 return ('x-gzip', 'gz', 'gzip');
131 } elsif ($val eq 'bzip2') {
132 return ('x-bzip2', 'bz2', 'bzip2');
133 } elsif ($val eq 'none') {
137 return ($ctype, $suffix, $command);
140 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
141 require $GITWEB_CONFIG if -e
$GITWEB_CONFIG;
143 # version of the core git binary
144 our $git_version = qx($GIT --version
) =~ m/git version (.*)$/ ?
$1 : "unknown";
146 $projects_list ||= $projectroot;
147 if (! -d
$git_temp) {
148 mkdir($git_temp, 0700) || die_error
(undef, "Couldn't mkdir $git_temp");
151 # ======================================================================
152 # input validation and dispatch
153 our $action = $cgi->param('a');
154 if (defined $action) {
155 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
156 die_error
(undef, "Invalid action parameter");
160 our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
161 if (defined $project) {
164 $project = undef unless $project;
166 if (defined $project) {
167 if (!validate_input
($project)) {
168 die_error
(undef, "Invalid project parameter");
170 if (!(-d
"$projectroot/$project")) {
171 die_error
(undef, "No such directory");
173 if (!(-e
"$projectroot/$project/HEAD")) {
174 die_error
(undef, "No such project");
176 $ENV{'GIT_DIR'} = "$projectroot/$project";
179 our $file_name = $cgi->param('f');
180 if (defined $file_name) {
181 if (!validate_input
($file_name)) {
182 die_error
(undef, "Invalid file parameter");
186 our $file_parent = $cgi->param('fp');
187 if (defined $file_parent) {
188 if (!validate_input
($file_parent)) {
189 die_error
(undef, "Invalid file parent parameter");
193 our $hash = $cgi->param('h');
195 if (!validate_input
($hash)) {
196 die_error
(undef, "Invalid hash parameter");
200 our $hash_parent = $cgi->param('hp');
201 if (defined $hash_parent) {
202 if (!validate_input
($hash_parent)) {
203 die_error
(undef, "Invalid hash parent parameter");
207 our $hash_base = $cgi->param('hb');
208 if (defined $hash_base) {
209 if (!validate_input
($hash_base)) {
210 die_error
(undef, "Invalid hash base parameter");
214 our $page = $cgi->param('pg');
216 if ($page =~ m/[^0-9]$/) {
217 die_error
(undef, "Invalid page parameter");
221 our $searchtext = $cgi->param('s');
222 if (defined $searchtext) {
223 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\
-\
+\
:\@
]/) {
224 die_error
(undef, "Invalid search parameter");
226 $searchtext = quotemeta $searchtext;
231 "blame" => \
&git_blame2
,
232 "blobdiff" => \
&git_blobdiff
,
233 "blobdiff_plain" => \
&git_blobdiff_plain
,
234 "blob" => \
&git_blob
,
235 "blob_plain" => \
&git_blob_plain
,
236 "commitdiff" => \
&git_commitdiff
,
237 "commitdiff_plain" => \
&git_commitdiff_plain
,
238 "commit" => \
&git_commit
,
239 "heads" => \
&git_heads
,
240 "history" => \
&git_history
,
243 "search" => \
&git_search
,
244 "shortlog" => \
&git_shortlog
,
245 "summary" => \
&git_summary
,
247 "tags" => \
&git_tags
,
248 "tree" => \
&git_tree
,
249 "snapshot" => \
&git_snapshot
,
250 # those below don't need $project
251 "opml" => \
&git_opml
,
252 "project_list" => \
&git_project_list
,
255 if (defined $project) {
256 $action ||= 'summary';
258 $action ||= 'project_list';
260 if (!defined($actions{$action})) {
261 die_error
(undef, "Unknown action");
263 $actions{$action}->();
266 ## ======================================================================
283 my %mapping = @mapping;
285 $params{"project"} ||= $project;
288 for (my $i = 0; $i < @mapping; $i += 2) {
289 my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
290 if (defined $params{$name}) {
291 push @result, $symbol . "=" . esc_param
($params{$name});
294 return "$my_uri?" . join(';', @result);
298 ## ======================================================================
299 ## validation, quoting/unquoting and escaping
304 if ($input =~ m/^[0-9a-fA-F]{40}$/) {
307 if ($input =~ m/(^|\/)(|\
.|\
.\
.)($|\
/)/) {
310 if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \t\.\/\
-\
+\#\
~\
%]/) {
316 # quote unsafe chars, but keep the slash, even when it's not
317 # correct, but quoted slashes look too horrible in bookmarks
320 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
326 # replace invalid utf8 character with SUBSTITUTION sequence
329 $str = decode
("utf8", $str, Encode
::FB_DEFAULT
);
330 $str = escapeHTML
($str);
331 $str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
335 # git may return quoted and escaped filenames
338 if ($str =~ m/^"(.*)"$/) {
340 $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
345 # escape tabs (convert tabs to spaces)
349 while ((my $pos = index($line, "\t")) != -1) {
350 if (my $count = (8 - ($pos % 8))) {
351 my $spaces = ' ' x
$count;
352 $line =~ s/\t/$spaces/;
359 ## ----------------------------------------------------------------------
360 ## HTML aware string manipulation
365 my $add_len = shift || 10;
367 # allow only $len chars, but don't cut a word if it would fit in $add_len
368 # if it doesn't fit, cut it if it's still longer than the dots we would add
369 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@
]{0,$add_len})(.*)/;
372 if (length($tail) > 4) {
374 $body =~ s/&[^;]*$//; # remove chopped character entities
379 ## ----------------------------------------------------------------------
380 ## functions returning short strings
382 # CSS class for given age value (in seconds)
386 if ($age < 60*60*2) {
388 } elsif ($age < 60*60*24*2) {
395 # convert age in seconds to "nn units ago" string
400 if ($age > 60*60*24*365*2) {
401 $age_str = (int $age/60/60/24/365);
402 $age_str .= " years ago";
403 } elsif ($age > 60*60*24*(365/12)*2) {
404 $age_str = int $age/60/60/24/(365/12);
405 $age_str .= " months ago";
406 } elsif ($age > 60*60*24*7*2) {
407 $age_str = int $age/60/60/24/7;
408 $age_str .= " weeks ago";
409 } elsif ($age > 60*60*24*2) {
410 $age_str = int $age/60/60/24;
411 $age_str .= " days ago";
412 } elsif ($age > 60*60*2) {
413 $age_str = int $age/60/60;
414 $age_str .= " hours ago";
415 } elsif ($age > 60*2) {
416 $age_str = int $age/60;
417 $age_str .= " min ago";
420 $age_str .= " sec ago";
422 $age_str .= " right now";
427 # convert file mode in octal to symbolic file mode string
429 my $mode = oct shift;
431 if (S_ISDIR
($mode & S_IFMT
)) {
433 } elsif (S_ISLNK
($mode)) {
435 } elsif (S_ISREG
($mode)) {
436 # git cares only about the executable bit
437 if ($mode & S_IXUSR
) {
447 # convert file mode in octal to file type string
449 my $mode = oct shift;
451 if (S_ISDIR
($mode & S_IFMT
)) {
453 } elsif (S_ISLNK
($mode)) {
455 } elsif (S_ISREG
($mode)) {
462 ## ----------------------------------------------------------------------
463 ## functions returning short HTML fragments, or transforming HTML fragments
464 ## which don't beling to other sections
466 # format line of commit message or tag comment
467 sub format_log_line_html
{
470 $line = esc_html
($line);
471 $line =~ s/ / /g;
472 if ($line =~ m/([0-9a-fA-F]{40})/) {
474 if (git_get_type
($hash_text) eq "commit") {
476 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$hash_text),
477 -class => "text"}, $hash_text);
478 $line =~ s/$hash_text/$link/;
484 # format marker of refs pointing to given object
485 sub format_ref_marker
{
486 my ($refs, $id) = @_;
489 if (defined $refs->{$id}) {
490 foreach my $ref (@
{$refs->{$id}}) {
491 my ($type, $name) = qw();
492 # e.g. tags/v2.6.11 or heads/next
493 if ($ref =~ m!^(.*?)s?/(.*)$!) {
501 $markers .= " <span class=\"$type\">" . esc_html
($name) . "</span>";
506 return ' <span class="refs">'. $markers . '</span>';
512 # format, perhaps shortened and with markers, title line
513 sub format_subject_html
{
514 my ($long, $short, $href, $extra) = @_;
515 $extra = '' unless defined($extra);
517 if (length($short) < length($long)) {
518 return $cgi->a({-href
=> $href, -class => "list subject",
520 esc_html
($short) . $extra);
522 return $cgi->a({-href
=> $href, -class => "list subject"},
523 esc_html
($long) . $extra);
527 sub format_diff_line
{
529 my $char = substr($line, 0, 1);
535 $diff_class = " add";
536 } elsif ($char eq "-") {
537 $diff_class = " rem";
538 } elsif ($char eq "@") {
539 $diff_class = " chunk_header";
540 } elsif ($char eq "\\") {
541 $diff_class = " incomplete";
543 $line = untabify
($line);
544 return "<div class=\"diff$diff_class\">" . esc_html
($line) . "</div>\n";
547 ## ----------------------------------------------------------------------
548 ## git utility subroutines, invoking git commands
550 # get HEAD ref of given project as hash
551 sub git_get_head_hash
{
553 my $oENV = $ENV{'GIT_DIR'};
555 $ENV{'GIT_DIR'} = "$projectroot/$project";
556 if (open my $fd, "-|", $GIT, "rev-parse", "--verify", "HEAD") {
559 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
564 $ENV{'GIT_DIR'} = $oENV;
569 # get type of given object
573 open my $fd, "-|", $GIT, "cat-file", '-t', $hash or return;
580 sub git_get_project_config
{
581 my ($key, $type) = @_;
583 return unless ($key);
584 $key =~ s/^gitweb\.//;
585 return if ($key =~ m/\W/);
587 my @x = ($GIT, 'repo-config');
588 if (defined $type) { push @x, $type; }
590 push @x, "gitweb.$key";
596 # get hash of given path at given ref
597 sub git_get_hash_by_path
{
599 my $path = shift || return undef;
603 open my $fd, "-|", $GIT, "ls-tree", $base, "--", $path
604 or die_error
(undef, "Open git-ls-tree failed");
606 close $fd or return undef;
608 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
609 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
613 ## ......................................................................
614 ## git utility functions, directly accessing git repository
616 # assumes that PATH is not symref
617 sub git_get_hash_by_ref
{
620 open my $fd, "$projectroot/$path" or return undef;
624 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
629 sub git_get_project_description
{
632 open my $fd, "$projectroot/$path/description" or return undef;
639 sub git_get_project_url_list
{
642 open my $fd, "$projectroot/$path/cloneurl" or return undef;
643 my @git_project_url_list = map { chomp; $_ } <$fd>;
646 return wantarray ?
@git_project_url_list : \
@git_project_url_list;
649 sub git_get_projects_list
{
652 if (-d
$projects_list) {
653 # search in directory
654 my $dir = $projects_list;
655 opendir my ($dh), $dir or return undef;
656 while (my $dir = readdir($dh)) {
657 if (-e
"$projectroot/$dir/HEAD") {
665 } elsif (-f
$projects_list) {
666 # read from file(url-encoded):
667 # 'git%2Fgit.git Linus+Torvalds'
668 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
669 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
670 open my ($fd), $projects_list or return undef;
671 while (my $line = <$fd>) {
673 my ($path, $owner) = split ' ', $line;
674 $path = unescape
($path);
675 $owner = unescape
($owner);
676 if (!defined $path) {
679 if (-e
"$projectroot/$path/HEAD") {
682 owner
=> decode
("utf8", $owner, Encode
::FB_DEFAULT
),
689 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
693 sub git_get_project_owner
{
697 return undef unless $project;
699 # read from file (url-encoded):
700 # 'git%2Fgit.git Linus+Torvalds'
701 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
702 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
703 if (-f
$projects_list) {
704 open (my $fd , $projects_list);
705 while (my $line = <$fd>) {
707 my ($pr, $ow) = split ' ', $line;
710 if ($pr eq $project) {
711 $owner = decode
("utf8", $ow, Encode
::FB_DEFAULT
);
717 if (!defined $owner) {
718 $owner = get_file_owner
("$projectroot/$project");
724 sub git_get_references
{
725 my $type = shift || "";
728 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
729 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
730 if (-f
"$projectroot/$project/info/refs") {
731 open $fd, "$projectroot/$project/info/refs"
734 open $fd, "-|", $GIT, "ls-remote", "."
738 while (my $line = <$fd>) {
740 if ($line =~ m/^([0-9a-fA-F]{40})\trefs\/($type\
/?[^\^]+)/) {
741 if (defined $refs{$1}) {
742 push @
{$refs{$1}}, $2;
752 ## ----------------------------------------------------------------------
753 ## parse to hash functions
757 my $tz = shift || "-0000";
760 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
761 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
762 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
763 $date{'hour'} = $hour;
764 $date{'minute'} = $min;
765 $date{'mday'} = $mday;
766 $date{'day'} = $days[$wday];
767 $date{'month'} = $months[$mon];
768 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000",
769 $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
770 $date{'mday-time'} = sprintf "%d %s %02d:%02d",
771 $mday, $months[$mon], $hour ,$min;
773 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
774 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
775 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
776 $date{'hour_local'} = $hour;
777 $date{'minute_local'} = $min;
778 $date{'tz_local'} = $tz;
787 open my $fd, "-|", $GIT, "cat-file", "tag", $tag_id or return;
788 $tag{'id'} = $tag_id;
789 while (my $line = <$fd>) {
791 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
793 } elsif ($line =~ m/^type (.+)$/) {
795 } elsif ($line =~ m/^tag (.+)$/) {
797 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
801 } elsif ($line =~ m/--BEGIN/) {
802 push @comment, $line;
804 } elsif ($line eq "") {
808 push @comment, <$fd>;
809 $tag{'comment'} = \
@comment;
811 if (!defined $tag{'name'}) {
818 my $commit_id = shift;
819 my $commit_text = shift;
824 if (defined $commit_text) {
825 @commit_lines = @
$commit_text;
828 open my $fd, "-|", $GIT, "rev-list", "--header", "--parents", "--max-count=1", $commit_id
830 @commit_lines = split '\n', <$fd>;
835 my $header = shift @commit_lines;
836 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
839 ($co{'id'}, my @parents) = split ' ', $header;
840 $co{'parents'} = \
@parents;
841 $co{'parent'} = $parents[0];
842 while (my $line = shift @commit_lines) {
843 last if $line eq "\n";
844 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
846 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
848 $co{'author_epoch'} = $2;
849 $co{'author_tz'} = $3;
850 if ($co{'author'} =~ m/^([^<]+) </) {
851 $co{'author_name'} = $1;
853 $co{'author_name'} = $co{'author'};
855 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
856 $co{'committer'} = $1;
857 $co{'committer_epoch'} = $2;
858 $co{'committer_tz'} = $3;
859 $co{'committer_name'} = $co{'committer'};
860 $co{'committer_name'} =~ s/ <.*//;
863 if (!defined $co{'tree'}) {
867 foreach my $title (@commit_lines) {
870 $co{'title'} = chop_str
($title, 80, 5);
871 # remove leading stuff of merges to make the interesting part visible
872 if (length($title) > 50) {
873 $title =~ s/^Automatic //;
874 $title =~ s/^merge (of|with) /Merge ... /i;
875 if (length($title) > 50) {
876 $title =~ s/(http|rsync):\/\///;
878 if (length($title) > 50) {
879 $title =~ s/(master|www|rsync)\.//;
881 if (length($title) > 50) {
882 $title =~ s/kernel.org:?//;
884 if (length($title) > 50) {
885 $title =~ s/\/pub\/scm//;
888 $co{'title_short'} = chop_str
($title, 50, 5);
892 # remove added spaces
893 foreach my $line (@commit_lines) {
896 $co{'comment'} = \
@commit_lines;
898 my $age = time - $co{'committer_epoch'};
900 $co{'age_string'} = age_string
($age);
901 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
902 if ($age > 60*60*24*7*2) {
903 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
904 $co{'age_string_age'} = $co{'age_string'};
906 $co{'age_string_date'} = $co{'age_string'};
907 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
912 # parse ref from ref_file, given by ref_id, with given type
914 my $ref_file = shift;
916 my $type = shift || git_get_type
($ref_id);
919 $ref_item{'type'} = $type;
920 $ref_item{'id'} = $ref_id;
921 $ref_item{'epoch'} = 0;
922 $ref_item{'age'} = "unknown";
923 if ($type eq "tag") {
924 my %tag = parse_tag
($ref_id);
925 $ref_item{'comment'} = $tag{'comment'};
926 if ($tag{'type'} eq "commit") {
927 my %co = parse_commit
($tag{'object'});
928 $ref_item{'epoch'} = $co{'committer_epoch'};
929 $ref_item{'age'} = $co{'age_string'};
930 } elsif (defined($tag{'epoch'})) {
931 my $age = time - $tag{'epoch'};
932 $ref_item{'epoch'} = $tag{'epoch'};
933 $ref_item{'age'} = age_string
($age);
935 $ref_item{'reftype'} = $tag{'type'};
936 $ref_item{'name'} = $tag{'name'};
937 $ref_item{'refid'} = $tag{'object'};
938 } elsif ($type eq "commit"){
939 my %co = parse_commit
($ref_id);
940 $ref_item{'reftype'} = "commit";
941 $ref_item{'name'} = $ref_file;
942 $ref_item{'title'} = $co{'title'};
943 $ref_item{'refid'} = $ref_id;
944 $ref_item{'epoch'} = $co{'committer_epoch'};
945 $ref_item{'age'} = $co{'age_string'};
947 $ref_item{'reftype'} = $type;
948 $ref_item{'name'} = $ref_file;
949 $ref_item{'refid'} = $ref_id;
955 # parse line of git-diff-tree "raw" output
956 sub parse_difftree_raw_line
{
960 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
961 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
962 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
963 $res{'from_mode'} = $1;
964 $res{'to_mode'} = $2;
965 $res{'from_id'} = $3;
968 $res{'similarity'} = $6;
969 if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
970 ($res{'from_file'}, $res{'to_file'}) = map { unquote
($_) } split("\t", $7);
972 $res{'file'} = unquote
($7);
975 # 'c512b523472485aef4fff9e57b229d9d243c967f'
976 #elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
977 # $res{'commit'} = $1;
980 return wantarray ?
%res : \
%res;
983 ## ......................................................................
984 ## parse to array of hashes functions
986 sub git_get_refs_list
{
991 my $pfxlen = length("$projectroot/$project/$ref_dir");
992 File
::Find
::find
(sub {
995 push @refs, substr($File::Find
::name
, $pfxlen + 1);
997 }, "$projectroot/$project/$ref_dir");
999 foreach my $ref_file (@refs) {
1000 my $ref_id = git_get_hash_by_ref
("$project/$ref_dir/$ref_file");
1001 my $type = git_get_type
($ref_id) || next;
1002 my %ref_item = parse_ref
($ref_file, $ref_id, $type);
1004 push @reflist, \
%ref_item;
1007 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
1011 ## ----------------------------------------------------------------------
1012 ## filesystem-related functions
1014 sub get_file_owner
{
1017 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
1018 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
1019 if (!defined $gcos) {
1023 $owner =~ s/[,;].*$//;
1024 return decode
("utf8", $owner, Encode
::FB_DEFAULT
);
1027 ## ......................................................................
1028 ## mimetype related functions
1030 sub mimetype_guess_file
{
1031 my $filename = shift;
1032 my $mimemap = shift;
1033 -r
$mimemap or return undef;
1036 open(MIME
, $mimemap) or return undef;
1038 next if m/^#/; # skip comments
1039 my ($mime, $exts) = split(/\t+/);
1040 if (defined $exts) {
1041 my @exts = split(/\s+/, $exts);
1042 foreach my $ext (@exts) {
1043 $mimemap{$ext} = $mime;
1049 $filename =~ /\.(.*?)$/;
1050 return $mimemap{$1};
1053 sub mimetype_guess
{
1054 my $filename = shift;
1056 $filename =~ /\./ or return undef;
1058 if ($mimetypes_file) {
1059 my $file = $mimetypes_file;
1060 if ($file !~ m!^/!) { # if it is relative path
1061 # it is relative to project
1062 $file = "$projectroot/$project/$file";
1064 $mime = mimetype_guess_file
($filename, $file);
1066 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
1072 my $filename = shift;
1075 my $mime = mimetype_guess
($filename);
1076 $mime and return $mime;
1080 return $default_blob_plain_mimetype unless $fd;
1083 return 'text/plain' .
1084 ($default_text_plain_charset ?
'; charset='.$default_text_plain_charset : '');
1085 } elsif (! $filename) {
1086 return 'application/octet-stream';
1087 } elsif ($filename =~ m/\.png$/i) {
1089 } elsif ($filename =~ m/\.gif$/i) {
1091 } elsif ($filename =~ m/\.jpe?g$/i) {
1092 return 'image/jpeg';
1094 return 'application/octet-stream';
1098 ## ======================================================================
1099 ## functions printing HTML: header, footer, error page
1101 sub git_header_html
{
1102 my $status = shift || "200 OK";
1103 my $expires = shift;
1105 my $title = "$site_name git";
1106 if (defined $project) {
1107 $title .= " - $project";
1108 if (defined $action) {
1109 $title .= "/$action";
1110 if (defined $file_name) {
1111 $title .= " - $file_name";
1112 if ($action eq "tree" && $file_name !~ m
|/$|) {
1119 # require explicit support from the UA if we are to send the page as
1120 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
1121 # we have to do this because MSIE sometimes globs '*/*', pretending to
1122 # support xhtml+xml but choking when it gets what it asked for.
1123 if (defined $cgi->http('HTTP_ACCEPT') &&
1124 $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ &&
1125 $cgi->Accept('application/xhtml+xml') != 0) {
1126 $content_type = 'application/xhtml+xml';
1128 $content_type = 'text/html';
1130 print $cgi->header(-type
=>$content_type, -charset
=> 'utf-8',
1131 -status
=> $status, -expires
=> $expires);
1133 <?xml version="1.0" encoding="utf-8"?>
1134 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1135 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
1136 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
1137 <!-- git core binaries version $git_version -->
1139 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
1140 <meta name="generator" content="gitweb/$version git/$git_version"/>
1141 <meta name="robots" content="index, nofollow"/>
1142 <title>$title</title>
1143 <link rel="stylesheet" type="text/css" href="$stylesheet"/>
1145 if (defined $project) {
1146 printf('<link rel="alternate" title="%s log" '.
1147 'href="%s" type="application/rss+xml"/>'."\n",
1148 esc_param
($project), href
(action
=>"rss"));
1153 "<div class=\"page_header\">\n" .
1154 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
1155 "<img src=\"$logo\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
1157 print $cgi->a({-href
=> esc_param
($home_link)}, $home_link_str) . " / ";
1158 if (defined $project) {
1159 print $cgi->a({-href
=> href
(action
=>"summary")}, esc_html
($project));
1160 if (defined $action) {
1164 if (!defined $searchtext) {
1168 if (defined $hash_base) {
1169 $search_hash = $hash_base;
1170 } elsif (defined $hash) {
1171 $search_hash = $hash;
1173 $search_hash = "HEAD";
1175 $cgi->param("a", "search");
1176 $cgi->param("h", $search_hash);
1177 print $cgi->startform(-method
=> "get", -action
=> $my_uri) .
1178 "<div class=\"search\">\n" .
1179 $cgi->hidden(-name
=> "p") . "\n" .
1180 $cgi->hidden(-name
=> "a") . "\n" .
1181 $cgi->hidden(-name
=> "h") . "\n" .
1182 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
1184 $cgi->end_form() . "\n";
1189 sub git_footer_html
{
1190 print "<div class=\"page_footer\">\n";
1191 if (defined $project) {
1192 my $descr = git_get_project_description
($project);
1193 if (defined $descr) {
1194 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
1196 print $cgi->a({-href
=> href
(action
=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
1198 print $cgi->a({-href
=> href
(action
=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
1206 my $status = shift || "403 Forbidden";
1207 my $error = shift || "Malformed query, file missing or permission denied";
1209 git_header_html
($status);
1211 <div class="page_body">
1221 ## ----------------------------------------------------------------------
1222 ## functions printing or outputting HTML: navigation
1224 sub git_print_page_nav
{
1225 my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
1226 $extra = '' if !defined $extra; # pager or formats
1228 my @navs = qw(summary shortlog log commit commitdiff tree);
1230 @navs = grep { $_ ne $suppress } @navs;
1233 my %arg = map { $_ => {action
=>$_} } @navs;
1234 if (defined $head) {
1235 for (qw(commit commitdiff)) {
1236 $arg{$_}{hash
} = $head;
1238 if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
1239 for (qw(shortlog log)) {
1240 $arg{$_}{hash
} = $head;
1244 $arg{tree
}{hash
} = $treehead if defined $treehead;
1245 $arg{tree
}{hash_base
} = $treebase if defined $treebase;
1247 print "<div class=\"page_nav\">\n" .
1249 map { $_ eq $current ?
1250 $_ : $cgi->a({-href
=> href
(%{$arg{$_}})}, "$_")
1252 print "<br/>\n$extra<br/>\n" .
1256 sub format_paging_nav
{
1257 my ($action, $hash, $head, $page, $nrevs) = @_;
1261 if ($hash ne $head || $page) {
1262 $paging_nav .= $cgi->a({-href
=> href
(action
=>$action)}, "HEAD");
1264 $paging_nav .= "HEAD";
1268 $paging_nav .= " ⋅ " .
1269 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page-1),
1270 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1272 $paging_nav .= " ⋅ prev";
1275 if ($nrevs >= (100 * ($page+1)-1)) {
1276 $paging_nav .= " ⋅ " .
1277 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page+1),
1278 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1280 $paging_nav .= " ⋅ next";
1286 ## ......................................................................
1287 ## functions printing or outputting HTML: div
1289 sub git_print_header_div
{
1290 my ($action, $title, $hash, $hash_base) = @_;
1293 $args{action
} = $action;
1294 $args{hash
} = $hash if $hash;
1295 $args{hash_base
} = $hash_base if $hash_base;
1297 print "<div class=\"header\">\n" .
1298 $cgi->a({-href
=> href
(%args), -class => "title"},
1299 $title ?
$title : $action) .
1303 sub git_print_page_path
{
1308 if (!defined $name) {
1309 print "<div class=\"page_path\">/</div>\n";
1310 } elsif (defined $type && $type eq 'blob') {
1311 print "<div class=\"page_path\">";
1313 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name,
1317 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name)},
1320 print "<br/></div>\n";
1322 print "<div class=\"page_path\">" . esc_html
($name) . "<br/></div>\n";
1329 # remove leading empty lines
1330 while (defined $log->[0] && $log->[0] eq "") {
1337 foreach my $line (@
$log) {
1338 # print only one empty line
1339 # do not print empty line after signoff
1341 next if ($empty || $signoff);
1346 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1348 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
1351 print format_log_line_html
($line) . "<br/>\n";
1356 sub git_print_simplified_log
{
1358 my $remove_title = shift;
1360 shift @
$log if $remove_title;
1361 # remove leading empty lines
1362 while (defined $log->[0] && $log->[0] eq "") {
1366 # simplify and print log
1368 foreach my $line (@
$log) {
1369 # remove signoff lines
1370 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1373 # print only one empty line
1380 print format_log_line_html
($line) . "<br/>\n";
1382 # end with single empty line
1383 print "<br/>\n" unless $empty;
1386 ## ......................................................................
1387 ## functions printing large fragments of HTML
1389 sub git_difftree_body
{
1390 my ($difftree, $hash, $parent) = @_;
1392 print "<div class=\"list_head\">\n";
1393 if ($#{$difftree} > 10) {
1394 print(($#{$difftree} + 1) . " files changed:\n");
1398 print "<table class=\"diff_tree\">\n";
1400 foreach my $line (@
{$difftree}) {
1401 my %diff = parse_difftree_raw_line
($line);
1404 print "<tr class=\"dark\">\n";
1406 print "<tr class=\"light\">\n";
1410 my ($to_mode_oct, $to_mode_str, $to_file_type);
1411 my ($from_mode_oct, $from_mode_str, $from_file_type);
1412 if ($diff{'to_mode'} ne ('0' x
6)) {
1413 $to_mode_oct = oct $diff{'to_mode'};
1414 if (S_ISREG
($to_mode_oct)) { # only for regular file
1415 $to_mode_str = sprintf("%04o", $to_mode_oct & 0777); # permission bits
1417 $to_file_type = file_type
($diff{'to_mode'});
1419 if ($diff{'from_mode'} ne ('0' x
6)) {
1420 $from_mode_oct = oct $diff{'from_mode'};
1421 if (S_ISREG
($to_mode_oct)) { # only for regular file
1422 $from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
1424 $from_file_type = file_type
($diff{'from_mode'});
1427 if ($diff{'status'} eq "A") { # created
1428 my $mode_chng = "<span class=\"file_status new\">[new $to_file_type";
1429 $mode_chng .= " with mode: $to_mode_str" if $to_mode_str;
1430 $mode_chng .= "]</span>";
1432 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1433 hash_base
=>$hash, file_name
=>$diff{'file'}),
1434 -class => "list"}, esc_html
($diff{'file'})) .
1436 "<td>$mode_chng</td>\n" .
1437 "<td class=\"link\">" .
1438 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1439 hash_base
=>$hash, file_name
=>$diff{'file'})},
1443 } elsif ($diff{'status'} eq "D") { # deleted
1444 my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
1446 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
1447 hash_base
=>$parent, file_name
=>$diff{'file'}),
1448 -class => "list"}, esc_html
($diff{'file'})) .
1450 "<td>$mode_chng</td>\n" .
1451 "<td class=\"link\">" .
1452 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
1453 hash_base
=>$parent, file_name
=>$diff{'file'})},
1456 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$parent,
1457 file_name
=>$diff{'file'})},\
1461 } elsif ($diff{'status'} eq "M" || $diff{'status'} eq "T") { # modified, or type changed
1462 my $mode_chnge = "";
1463 if ($diff{'from_mode'} != $diff{'to_mode'}) {
1464 $mode_chnge = "<span class=\"file_status mode_chnge\">[changed";
1465 if ($from_file_type != $to_file_type) {
1466 $mode_chnge .= " from $from_file_type to $to_file_type";
1468 if (($from_mode_oct & 0777) != ($to_mode_oct & 0777)) {
1469 if ($from_mode_str && $to_mode_str) {
1470 $mode_chnge .= " mode: $from_mode_str->$to_mode_str";
1471 } elsif ($to_mode_str) {
1472 $mode_chnge .= " mode: $to_mode_str";
1475 $mode_chnge .= "]</span>\n";
1478 if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
1479 print $cgi->a({-href
=> href
(action
=>"blobdiff", hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
1480 hash_base
=>$hash, file_name
=>$diff{'file'}),
1481 -class => "list"}, esc_html
($diff{'file'}));
1482 } else { # only mode changed
1483 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1484 hash_base
=>$hash, file_name
=>$diff{'file'}),
1485 -class => "list"}, esc_html
($diff{'file'}));
1488 "<td>$mode_chnge</td>\n" .
1489 "<td class=\"link\">" .
1490 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1491 hash_base
=>$hash, file_name
=>$diff{'file'})},
1493 if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
1495 $cgi->a({-href
=> href
(action
=>"blobdiff", hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
1496 hash_base
=>$hash, file_name
=>$diff{'file'})},
1500 $cgi->a({-href
=> href
(action
=>"history",
1501 hash_base
=>$hash, file_name
=>$diff{'file'})},
1505 } elsif ($diff{'status'} eq "R" || $diff{'status'} eq "C") { # renamed or copied
1506 my %status_name = ('R' => 'moved', 'C' => 'copied');
1507 my $nstatus = $status_name{$diff{'status'}};
1509 if ($diff{'from_mode'} != $diff{'to_mode'}) {
1510 # mode also for directories, so we cannot use $to_mode_str
1511 $mode_chng = sprintf(", mode: %04o", $to_mode_oct & 0777);
1514 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1515 hash
=>$diff{'to_id'}, file_name
=>$diff{'to_file'}),
1516 -class => "list"}, esc_html
($diff{'to_file'})) . "</td>\n" .
1517 "<td><span class=\"file_status $nstatus\">[$nstatus from " .
1518 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$parent,
1519 hash
=>$diff{'from_id'}, file_name
=>$diff{'from_file'}),
1520 -class => "list"}, esc_html
($diff{'from_file'})) .
1521 " with " . (int $diff{'similarity'}) . "% similarity$mode_chng]</span></td>\n" .
1522 "<td class=\"link\">" .
1523 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1524 hash
=>$diff{'to_id'}, file_name
=>$diff{'to_file'})},
1526 if ($diff{'to_id'} ne $diff{'from_id'}) {
1528 $cgi->a({-href
=> href
(action
=>"blobdiff", hash_base
=>$hash,
1529 hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
1530 file_name
=>$diff{'to_file'}, file_parent
=>$diff{'from_file'})},
1535 } # we should not encounter Unmerged (U) or Unknown (X) status
1541 sub git_patchset_body
{
1542 my ($patchset, $difftree, $hash, $hash_parent) = @_;
1546 my $patch_found = 0;
1549 print "<div class=\"patchset\">\n";
1551 LINE
: foreach my $patch_line (@
$patchset) {
1553 if ($patch_line =~ m/^diff /) { # "git diff" header
1554 # beginning of patch (in patchset)
1556 # close previous patch
1557 print "</div>\n"; # class="patch"
1559 # first patch in patchset
1562 print "<div class=\"patch\">\n";
1564 %diffinfo = parse_difftree_raw_line
($difftree->[$patch_idx++]);
1566 # for now, no extended header, hence we skip empty patches
1567 # companion to next LINE if $in_header;
1568 if ($diffinfo{'from_id'} eq $diffinfo{'to_id'}) { # no change
1573 if ($diffinfo{'status'} eq "A") { # added
1574 print "<div class=\"diff_info\">" . file_type
($diffinfo{'to_mode'}) . ":" .
1575 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1576 hash
=>$diffinfo{'to_id'}, file_name
=>$diffinfo{'file'})},
1577 $diffinfo{'to_id'}) . "(new)" .
1578 "</div>\n"; # class="diff_info"
1580 } elsif ($diffinfo{'status'} eq "D") { # deleted
1581 print "<div class=\"diff_info\">" . file_type
($diffinfo{'from_mode'}) . ":" .
1582 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash_parent,
1583 hash
=>$diffinfo{'from_id'}, file_name
=>$diffinfo{'file'})},
1584 $diffinfo{'from_id'}) . "(deleted)" .
1585 "</div>\n"; # class="diff_info"
1587 } elsif ($diffinfo{'status'} eq "R" || # renamed
1588 $diffinfo{'status'} eq "C") { # copied
1589 print "<div class=\"diff_info\">" .
1590 file_type
($diffinfo{'from_mode'}) . ":" .
1591 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash_parent,
1592 hash
=>$diffinfo{'from_id'}, file_name
=>$diffinfo{'from_file'})},
1593 $diffinfo{'from_id'}) .
1595 file_type
($diffinfo{'to_mode'}) . ":" .
1596 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1597 hash
=>$diffinfo{'to_id'}, file_name
=>$diffinfo{'to_file'})},
1598 $diffinfo{'to_id'});
1599 print "</div>\n"; # class="diff_info"
1601 } else { # modified, mode changed, ...
1602 print "<div class=\"diff_info\">" .
1603 file_type
($diffinfo{'from_mode'}) . ":" .
1604 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash_parent,
1605 hash
=>$diffinfo{'from_id'}, file_name
=>$diffinfo{'file'})},
1606 $diffinfo{'from_id'}) .
1608 file_type
($diffinfo{'to_mode'}) . ":" .
1609 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1610 hash
=>$diffinfo{'to_id'}, file_name
=>$diffinfo{'file'})},
1611 $diffinfo{'to_id'});
1612 print "</div>\n"; # class="diff_info"
1615 #print "<div class=\"diff extended_header\">\n";
1618 } # start of patch in patchset
1621 if ($in_header && $patch_line =~ m/^---/) {
1625 next LINE
if $in_header;
1627 print format_diff_line
($patch_line);
1629 print "</div>\n" if $patch_found; # class="patch"
1631 print "</div>\n"; # class="patchset"
1634 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1636 sub git_shortlog_body
{
1637 # uses global variable $project
1638 my ($revlist, $from, $to, $refs, $extra) = @_;
1640 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
1641 my $have_snapshot = (defined $ctype && defined $suffix);
1643 $from = 0 unless defined $from;
1644 $to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
1646 print "<table class=\"shortlog\" cellspacing=\"0\">\n";
1648 for (my $i = $from; $i <= $to; $i++) {
1649 my $commit = $revlist->[$i];
1650 #my $ref = defined $refs ? format_ref_marker($refs, $commit) : '';
1651 my $ref = format_ref_marker
($refs, $commit);
1652 my %co = parse_commit
($commit);
1654 print "<tr class=\"dark\">\n";
1656 print "<tr class=\"light\">\n";
1659 # git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
1660 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1661 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
1663 print format_subject_html
($co{'title'}, $co{'title_short'},
1664 href
(action
=>"commit", hash
=>$commit), $ref);
1666 "<td class=\"link\">" .
1667 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
1668 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff");
1669 if ($have_snapshot) {
1670 print " | " . $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$commit)}, "snapshot");
1675 if (defined $extra) {
1677 "<td colspan=\"4\">$extra</td>\n" .
1683 sub git_history_body
{
1684 # Warning: assumes constant type (blob or tree) during history
1685 my ($fd, $refs, $hash_base, $ftype, $extra) = @_;
1687 print "<table class=\"history\" cellspacing=\"0\">\n";
1689 while (my $line = <$fd>) {
1690 if ($line !~ m/^([0-9a-fA-F]{40})/) {
1695 my %co = parse_commit
($commit);
1700 my $ref = format_ref_marker
($refs, $commit);
1703 print "<tr class=\"dark\">\n";
1705 print "<tr class=\"light\">\n";
1708 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1709 # shortlog uses chop_str($co{'author_name'}, 10)
1710 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
1712 # originally git_history used chop_str($co{'title'}, 50)
1713 print format_subject_html
($co{'title'}, $co{'title_short'},
1714 href
(action
=>"commit", hash
=>$commit), $ref);
1716 "<td class=\"link\">" .
1717 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
1718 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") . " | " .
1719 $cgi->a({-href
=> href
(action
=>$ftype, hash_base
=>$commit, file_name
=>$file_name)}, $ftype);
1721 if ($ftype eq 'blob') {
1722 my $blob_current = git_get_hash_by_path
($hash_base, $file_name);
1723 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
1724 if (defined $blob_current && defined $blob_parent &&
1725 $blob_current ne $blob_parent) {
1727 $cgi->a({-href
=> href
(action
=>"blobdiff", hash
=>$blob_current, hash_parent
=>$blob_parent,
1728 hash_base
=>$commit, file_name
=>$file_name)},
1735 if (defined $extra) {
1737 "<td colspan=\"4\">$extra</td>\n" .
1744 # uses global variable $project
1745 my ($taglist, $from, $to, $extra) = @_;
1746 $from = 0 unless defined $from;
1747 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
1749 print "<table class=\"tags\" cellspacing=\"0\">\n";
1751 for (my $i = $from; $i <= $to; $i++) {
1752 my $entry = $taglist->[$i];
1754 my $comment_lines = $tag{'comment'};
1755 my $comment = shift @
$comment_lines;
1757 if (defined $comment) {
1758 $comment_short = chop_str
($comment, 30, 5);
1761 print "<tr class=\"dark\">\n";
1763 print "<tr class=\"light\">\n";
1766 print "<td><i>$tag{'age'}</i></td>\n" .
1768 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'}),
1769 -class => "list name"}, esc_html
($tag{'name'})) .
1772 if (defined $comment) {
1773 print format_subject_html
($comment, $comment_short,
1774 href
(action
=>"tag", hash
=>$tag{'id'}));
1777 "<td class=\"selflink\">";
1778 if ($tag{'type'} eq "tag") {
1779 print $cgi->a({-href
=> href
(action
=>"tag", hash
=>$tag{'id'})}, "tag");
1784 "<td class=\"link\">" . " | " .
1785 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'})}, $tag{'reftype'});
1786 if ($tag{'reftype'} eq "commit") {
1787 print " | " . $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") .
1788 " | " . $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'refid'})}, "log");
1789 } elsif ($tag{'reftype'} eq "blob") {
1790 print " | " . $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$tag{'refid'})}, "raw");
1795 if (defined $extra) {
1797 "<td colspan=\"5\">$extra</td>\n" .
1803 sub git_heads_body
{
1804 # uses global variable $project
1805 my ($taglist, $head, $from, $to, $extra) = @_;
1806 $from = 0 unless defined $from;
1807 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
1809 print "<table class=\"heads\" cellspacing=\"0\">\n";
1811 for (my $i = $from; $i <= $to; $i++) {
1812 my $entry = $taglist->[$i];
1814 my $curr = $tag{'id'} eq $head;
1816 print "<tr class=\"dark\">\n";
1818 print "<tr class=\"light\">\n";
1821 print "<td><i>$tag{'age'}</i></td>\n" .
1822 ($tag{'id'} eq $head ?
"<td class=\"current_head\">" : "<td>") .
1823 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'}),
1824 -class => "list name"},esc_html
($tag{'name'})) .
1826 "<td class=\"link\">" .
1827 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") . " | " .
1828 $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'name'})}, "log") .
1832 if (defined $extra) {
1834 "<td colspan=\"3\">$extra</td>\n" .
1840 ## ----------------------------------------------------------------------
1841 ## functions printing large fragments, format as one of arguments
1843 sub git_diff_print
{
1845 my $from_name = shift;
1847 my $to_name = shift;
1848 my $format = shift || "html";
1850 my $from_tmp = "/dev/null";
1851 my $to_tmp = "/dev/null";
1854 # create tmp from-file
1855 if (defined $from) {
1856 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
1857 open my $fd2, "> $from_tmp";
1858 open my $fd, "-|", $GIT, "cat-file", "blob", $from;
1865 # create tmp to-file
1867 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
1868 open my $fd2, "> $to_tmp";
1869 open my $fd, "-|", $GIT, "cat-file", "blob", $to;
1876 open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp";
1877 if ($format eq "plain") {
1882 while (my $line = <$fd>) {
1884 my $char = substr($line, 0, 1);
1885 my $diff_class = "";
1887 $diff_class = " add";
1888 } elsif ($char eq "-") {
1889 $diff_class = " rem";
1890 } elsif ($char eq "@") {
1891 $diff_class = " chunk_header";
1892 } elsif ($char eq "\\") {
1896 $line = untabify
($line);
1897 print "<div class=\"diff$diff_class\">" . esc_html
($line) . "</div>\n";
1902 if (defined $from) {
1911 ## ======================================================================
1912 ## ======================================================================
1915 sub git_project_list
{
1916 my $order = $cgi->param('o');
1917 if (defined $order && $order !~ m/project|descr|owner|age/) {
1918 die_error
(undef, "Unknown order parameter");
1921 my @list = git_get_projects_list
();
1924 die_error
(undef, "No projects found");
1926 foreach my $pr (@list) {
1927 my $head = git_get_head_hash
($pr->{'path'});
1928 if (!defined $head) {
1931 $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}";
1932 my %co = parse_commit
($head);
1936 $pr->{'commit'} = \
%co;
1937 if (!defined $pr->{'descr'}) {
1938 my $descr = git_get_project_description
($pr->{'path'}) || "";
1939 $pr->{'descr'} = chop_str
($descr, 25, 5);
1941 if (!defined $pr->{'owner'}) {
1942 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
1944 push @projects, $pr;
1948 if (-f
$home_text) {
1949 print "<div class=\"index_include\">\n";
1950 open (my $fd, $home_text);
1955 print "<table class=\"project_list\">\n" .
1957 $order ||= "project";
1958 if ($order eq "project") {
1959 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
1960 print "<th>Project</th>\n";
1963 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=project"),
1964 -class => "header"}, "Project") .
1967 if ($order eq "descr") {
1968 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
1969 print "<th>Description</th>\n";
1972 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=descr"),
1973 -class => "header"}, "Description") .
1976 if ($order eq "owner") {
1977 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
1978 print "<th>Owner</th>\n";
1981 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=owner"),
1982 -class => "header"}, "Owner") .
1985 if ($order eq "age") {
1986 @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
1987 print "<th>Last Change</th>\n";
1990 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=age"),
1991 -class => "header"}, "Last Change") .
1994 print "<th></th>\n" .
1997 foreach my $pr (@projects) {
1999 print "<tr class=\"dark\">\n";
2001 print "<tr class=\"light\">\n";
2004 print "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
2005 -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
2006 "<td>" . esc_html
($pr->{'descr'}) . "</td>\n" .
2007 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
2008 print "<td class=\"". age_class
($pr->{'commit'}{'age'}) . "\">" .
2009 $pr->{'commit'}{'age_string'} . "</td>\n" .
2010 "<td class=\"link\">" .
2011 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary")}, "summary") . " | " .
2012 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"shortlog")}, "shortlog") . " | " .
2013 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"log")}, "log") .
2022 my $descr = git_get_project_description
($project) || "none";
2023 my $head = git_get_head_hash
($project);
2024 my %co = parse_commit
($head);
2025 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
2027 my $owner = git_get_project_owner
($project);
2029 my $refs = git_get_references
();
2031 git_print_page_nav
('summary','', $head);
2033 print "<div class=\"title\"> </div>\n";
2034 print "<table cellspacing=\"0\">\n" .
2035 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
2036 "<tr><td>owner</td><td>$owner</td></tr>\n" .
2037 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
2038 # use per project git URL list in $projectroot/$project/cloneurl
2039 # or make project git URL from git base URL and project name
2040 my $url_tag = "URL";
2041 my @url_list = git_get_project_url_list
($project);
2042 @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
2043 foreach my $git_url (@url_list) {
2044 next unless $git_url;
2045 print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
2050 open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash
($project)
2051 or die_error
(undef, "Open git-rev-list failed");
2052 my @revlist = map { chomp; $_ } <$fd>;
2054 git_print_header_div
('shortlog');
2055 git_shortlog_body
(\
@revlist, 0, 15, $refs,
2056 $cgi->a({-href
=> href
(action
=>"shortlog")}, "..."));
2058 my $taglist = git_get_refs_list
("refs/tags");
2059 if (defined @
$taglist) {
2060 git_print_header_div
('tags');
2061 git_tags_body
($taglist, 0, 15,
2062 $cgi->a({-href
=> href
(action
=>"tags")}, "..."));
2065 my $headlist = git_get_refs_list
("refs/heads");
2066 if (defined @
$headlist) {
2067 git_print_header_div
('heads');
2068 git_heads_body
($headlist, $head, 0, 15,
2069 $cgi->a({-href
=> href
(action
=>"heads")}, "..."));
2076 my $head = git_get_head_hash
($project);
2078 git_print_page_nav
('','', $head,undef,$head);
2079 my %tag = parse_tag
($hash);
2080 git_print_header_div
('commit', esc_html
($tag{'name'}), $hash);
2081 print "<div class=\"title_text\">\n" .
2082 "<table cellspacing=\"0\">\n" .
2084 "<td>object</td>\n" .
2085 "<td>" . $cgi->a({-class => "list", -href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
2086 $tag{'object'}) . "</td>\n" .
2087 "<td class=\"link\">" . $cgi->a({-href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
2088 $tag{'type'}) . "</td>\n" .
2090 if (defined($tag{'author'})) {
2091 my %ad = parse_date
($tag{'epoch'}, $tag{'tz'});
2092 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
2093 print "<tr><td></td><td>" . $ad{'rfc2822'} .
2094 sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) .
2097 print "</table>\n\n" .
2099 print "<div class=\"page_body\">";
2100 my $comment = $tag{'comment'};
2101 foreach my $line (@
$comment) {
2102 print esc_html
($line) . "<br/>\n";
2112 if (!gitweb_check_feature
('blame')) {
2113 die_error
('403 Permission denied', "Permission denied");
2115 die_error
('404 Not Found', "File name not defined") if (!$file_name);
2116 $hash_base ||= git_get_head_hash
($project);
2117 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
2118 my %co = parse_commit
($hash_base)
2119 or die_error
(undef, "Reading commit failed");
2120 if (!defined $hash) {
2121 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
2122 or die_error
(undef, "Error looking up file");
2124 $ftype = git_get_type
($hash);
2125 if ($ftype !~ "blob") {
2126 die_error
("400 Bad Request", "Object is not a blob");
2128 open ($fd, "-|", $GIT, "blame", '-l', $file_name, $hash_base)
2129 or die_error
(undef, "Open git-blame failed");
2132 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
2135 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
2137 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2138 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2139 git_print_page_path
($file_name, $ftype, $hash_base);
2140 my @rev_color = (qw(light2 dark2));
2141 my $num_colors = scalar(@rev_color);
2142 my $current_color = 0;
2145 <div class="page_body">
2146 <table class="blame">
2147 <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
2150 /^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
2152 my $rev = substr($full_rev, 0, 8);
2156 if (!defined $last_rev) {
2157 $last_rev = $full_rev;
2158 } elsif ($last_rev ne $full_rev) {
2159 $last_rev = $full_rev;
2160 $current_color = ++$current_color % $num_colors;
2162 print "<tr class=\"$rev_color[$current_color]\">\n";
2163 print "<td class=\"sha1\">" .
2164 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$full_rev, file_name
=>$file_name)},
2165 esc_html
($rev)) . "</td>\n";
2166 print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" .
2167 esc_html
($lineno) . "</a></td>\n";
2168 print "<td class=\"pre\">" . esc_html
($data) . "</td>\n";
2174 or print "Reading blob failed\n";
2181 if (!gitweb_check_feature
('blame')) {
2182 die_error
('403 Permission denied', "Permission denied");
2184 die_error
('404 Not Found', "File name not defined") if (!$file_name);
2185 $hash_base ||= git_get_head_hash
($project);
2186 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
2187 my %co = parse_commit
($hash_base)
2188 or die_error
(undef, "Reading commit failed");
2189 if (!defined $hash) {
2190 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
2191 or die_error
(undef, "Error lookup file");
2193 open ($fd, "-|", $GIT, "annotate", '-l', '-t', '-r', $file_name, $hash_base)
2194 or die_error
(undef, "Open git-annotate failed");
2197 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
2200 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
2202 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2203 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2204 git_print_page_path
($file_name, 'blob', $hash_base);
2205 print "<div class=\"page_body\">\n";
2207 <table class="blame">
2216 my @line_class = (qw(light dark));
2217 my $line_class_len = scalar (@line_class);
2218 my $line_class_num = $#line_class;
2219 while (my $line = <$fd>) {
2231 $line_class_num = ($line_class_num + 1) % $line_class_len;
2233 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) \+\d\d\d\d\t(\d+)\)(.*)$/) {
2240 print qq( <tr
><td colspan
="5" class="error">Unable to parse
: $line</td></tr
>\n);
2243 $short_rev = substr ($long_rev, 0, 8);
2244 $age = time () - $time;
2245 $age_str = age_string
($age);
2246 $age_str =~ s/ / /g;
2247 $age_class = age_class
($age);
2248 $author = esc_html
($author);
2249 $author =~ s/ / /g;
2251 $data = untabify
($data);
2252 $data = esc_html
($data);
2255 <tr class="$line_class[$line_class_num]">
2256 <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
2257 <td class="$age_class">$age_str</td>
2259 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
2260 <td class="pre">$data</td>
2263 } # while (my $line = <$fd>)
2264 print "</table>\n\n";
2266 or print "Reading blob failed.\n";
2272 my $head = git_get_head_hash
($project);
2274 git_print_page_nav
('','', $head,undef,$head);
2275 git_print_header_div
('summary', $project);
2277 my $taglist = git_get_refs_list
("refs/tags");
2278 if (defined @
$taglist) {
2279 git_tags_body
($taglist);
2285 my $head = git_get_head_hash
($project);
2287 git_print_page_nav
('','', $head,undef,$head);
2288 git_print_header_div
('summary', $project);
2290 my $taglist = git_get_refs_list
("refs/heads");
2291 if (defined @
$taglist) {
2292 git_heads_body
($taglist, $head);
2297 sub git_blob_plain
{
2298 if (!defined $hash) {
2299 if (defined $file_name) {
2300 my $base = $hash_base || git_get_head_hash
($project);
2301 $hash = git_get_hash_by_path
($base, $file_name, "blob")
2302 or die_error
(undef, "Error lookup file");
2304 die_error
(undef, "No file name defined");
2308 open my $fd, "-|", $GIT, "cat-file", "blob", $hash
2309 or die_error
(undef, "Couldn't cat $file_name, $hash");
2311 $type ||= blob_mimetype
($fd, $file_name);
2313 # save as filename, even when no $file_name is given
2314 my $save_as = "$hash";
2315 if (defined $file_name) {
2316 $save_as = $file_name;
2317 } elsif ($type =~ m/^text\//) {
2321 print $cgi->header(-type
=> "$type",
2322 -content_disposition
=> "inline; filename=\"$save_as\"");
2324 binmode STDOUT
, ':raw';
2326 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
2332 if (!defined $hash) {
2333 if (defined $file_name) {
2334 my $base = $hash_base || git_get_head_hash
($project);
2335 $hash = git_get_hash_by_path
($base, $file_name, "blob")
2336 or die_error
(undef, "Error lookup file");
2338 die_error
(undef, "No file name defined");
2341 my $have_blame = gitweb_check_feature
('blame');
2342 open my $fd, "-|", $GIT, "cat-file", "blob", $hash
2343 or die_error
(undef, "Couldn't cat $file_name, $hash");
2344 my $mimetype = blob_mimetype
($fd, $file_name);
2345 if ($mimetype !~ m/^text\//) {
2347 return git_blob_plain
($mimetype);
2350 my $formats_nav = '';
2351 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
2352 if (defined $file_name) {
2355 $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash_base,
2356 hash
=>$hash, file_name
=>$file_name)},
2361 $cgi->a({-href
=> href
(action
=>"blob_plain",
2362 hash
=>$hash, file_name
=>$file_name)},
2365 $cgi->a({-href
=> href
(action
=>"blob",
2366 hash_base
=>"HEAD", file_name
=>$file_name)},
2370 $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$hash)}, "plain");
2372 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2373 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2375 print "<div class=\"page_nav\">\n" .
2376 "<br/><br/></div>\n" .
2377 "<div class=\"title\">$hash</div>\n";
2379 git_print_page_path
($file_name, "blob", $hash_base);
2380 print "<div class=\"page_body\">\n";
2382 while (my $line = <$fd>) {
2385 $line = untabify
($line);
2386 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
2387 $nr, $nr, $nr, esc_html
($line);
2390 or print "Reading blob failed.\n";
2396 if (!defined $hash) {
2397 $hash = git_get_head_hash
($project);
2398 if (defined $file_name) {
2399 my $base = $hash_base || $hash;
2400 $hash = git_get_hash_by_path
($base, $file_name, "tree");
2402 if (!defined $hash_base) {
2407 open my $fd, "-|", $GIT, "ls-tree", '-z', $hash
2408 or die_error
(undef, "Open git-ls-tree failed");
2409 my @entries = map { chomp; $_ } <$fd>;
2410 close $fd or die_error
(undef, "Reading tree failed");
2413 my $refs = git_get_references
();
2414 my $ref = format_ref_marker
($refs, $hash_base);
2418 my $have_blame = gitweb_check_feature
('blame');
2419 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
2420 $base_key{hash_base
} = $hash_base;
2421 git_print_page_nav
('tree','', $hash_base);
2422 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash_base);
2424 print "<div class=\"page_nav\">\n";
2425 print "<br/><br/></div>\n";
2426 print "<div class=\"title\">$hash</div>\n";
2428 if (defined $file_name) {
2429 $base = esc_html
("$file_name/");
2431 git_print_page_path
($file_name, 'tree', $hash_base);
2432 print "<div class=\"page_body\">\n";
2433 print "<table cellspacing=\"0\">\n";
2435 foreach my $line (@entries) {
2436 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
2437 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
2441 my $t_name = validate_input
($4);
2443 print "<tr class=\"dark\">\n";
2445 print "<tr class=\"light\">\n";
2448 print "<td class=\"mode\">" . mode_str
($t_mode) . "</td>\n";
2449 if ($t_type eq "blob") {
2450 print "<td class=\"list\">" .
2451 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key),
2452 -class => "list"}, esc_html
($t_name)) .
2454 "<td class=\"link\">" .
2455 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2459 $cgi->a({-href
=> href
(action
=>"blame", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2463 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2464 hash
=>$t_hash, file_name
=>"$base$t_name")},
2467 $cgi->a({-href
=> href
(action
=>"blob_plain",
2468 hash
=>$t_hash, file_name
=>"$base$t_name")},
2471 } elsif ($t_type eq "tree") {
2472 print "<td class=\"list\">" .
2473 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2474 esc_html
($t_name)) .
2476 "<td class=\"link\">" .
2477 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2480 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base, file_name
=>"$base$t_name")},
2486 print "</table>\n" .
2493 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
2494 my $have_snapshot = (defined $ctype && defined $suffix);
2495 if (!$have_snapshot) {
2496 die_error
('403 Permission denied', "Permission denied");
2499 if (!defined $hash) {
2500 $hash = git_get_head_hash
($project);
2503 my $filename = basename
($project) . "-$hash.tar.$suffix";
2505 print $cgi->header(-type
=> 'application/x-tar',
2506 -content_encoding
=> $ctype,
2507 -content_disposition
=> "inline; filename=\"$filename\"",
2508 -status
=> '200 OK');
2510 open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | $command" or
2511 die_error
(undef, "Execute git-tar-tree failed.");
2512 binmode STDOUT
, ':raw';
2514 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
2520 my $head = git_get_head_hash
($project);
2521 if (!defined $hash) {
2524 if (!defined $page) {
2527 my $refs = git_get_references
();
2529 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2530 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
2531 or die_error
(undef, "Open git-rev-list failed");
2532 my @revlist = map { chomp; $_ } <$fd>;
2535 my $paging_nav = format_paging_nav
('log', $hash, $head, $page, $#revlist);
2538 git_print_page_nav
('log','', $hash,undef,undef, $paging_nav);
2541 my %co = parse_commit
($hash);
2543 git_print_header_div
('summary', $project);
2544 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
2546 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2547 my $commit = $revlist[$i];
2548 my $ref = format_ref_marker
($refs, $commit);
2549 my %co = parse_commit
($commit);
2551 my %ad = parse_date
($co{'author_epoch'});
2552 git_print_header_div
('commit',
2553 "<span class=\"age\">$co{'age_string'}</span>" .
2554 esc_html
($co{'title'}) . $ref,
2556 print "<div class=\"title_text\">\n" .
2557 "<div class=\"log_link\">\n" .
2558 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") .
2560 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") .
2563 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
2566 print "<div class=\"log_body\">\n";
2567 git_print_simplified_log
($co{'comment'});
2574 my %co = parse_commit
($hash);
2576 die_error
(undef, "Unknown commit object");
2578 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
2579 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
2581 my $parent = $co{'parent'};
2582 if (!defined $parent) {
2585 open my $fd, "-|", $GIT, "diff-tree", '-r', '-M', $parent, $hash
2586 or die_error
(undef, "Open git-diff-tree failed");
2587 my @difftree = map { chomp; $_ } <$fd>;
2588 close $fd or die_error
(undef, "Reading git-diff-tree failed");
2590 # non-textual hash id's can be cached
2592 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2595 my $refs = git_get_references
();
2596 my $ref = format_ref_marker
($refs, $co{'id'});
2598 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
2599 my $have_snapshot = (defined $ctype && defined $suffix);
2601 my $formats_nav = '';
2602 if (defined $file_name && defined $co{'parent'}) {
2603 my $parent = $co{'parent'};
2605 $cgi->a({-href
=> href
(action
=>"blame", hash_parent
=>$parent, file_name
=>$file_name)},
2608 git_header_html
(undef, $expires);
2609 git_print_page_nav
('commit', defined $co{'parent'} ?
'' : 'commitdiff',
2610 $hash, $co{'tree'}, $hash,
2613 if (defined $co{'parent'}) {
2614 git_print_header_div
('commitdiff', esc_html
($co{'title'}) . $ref, $hash);
2616 git_print_header_div
('tree', esc_html
($co{'title'}) . $ref, $co{'tree'}, $hash);
2618 print "<div class=\"title_text\">\n" .
2619 "<table cellspacing=\"0\">\n";
2620 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
2622 "<td></td><td> $ad{'rfc2822'}";
2623 if ($ad{'hour_local'} < 6) {
2624 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
2625 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2627 printf(" (%02d:%02d %s)",
2628 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2632 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
2633 print "<tr><td></td><td> $cd{'rfc2822'}" .
2634 sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
2636 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
2639 "<td class=\"sha1\">" .
2640 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash),
2641 class => "list"}, $co{'tree'}) .
2643 "<td class=\"link\">" .
2644 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash)},
2646 if ($have_snapshot) {
2648 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)}, "snapshot");
2652 my $parents = $co{'parents'};
2653 foreach my $par (@
$parents) {
2656 "<td class=\"sha1\">" .
2657 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par),
2658 class => "list"}, $par) .
2660 "<td class=\"link\">" .
2661 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par)}, "commit") .
2663 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$hash, hash_parent
=>$par)}, "commitdiff") .
2670 print "<div class=\"page_body\">\n";
2671 git_print_log
($co{'comment'});
2674 git_difftree_body
(\
@difftree, $hash, $parent);
2680 mkdir($git_temp, 0700);
2682 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
2684 $cgi->a({-href
=> href
(action
=>"blobdiff_plain",
2685 hash
=>$hash, hash_parent
=>$hash_parent)},
2687 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2688 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2691 <div class="page_nav"><br/><br/></div>
2692 <div class="title">$hash vs $hash_parent</div>
2695 git_print_page_path
($file_name, "blob", $hash_base);
2696 print "<div class=\"page_body\">\n" .
2697 "<div class=\"diff_info\">blob:" .
2698 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash_parent,
2699 hash_base
=>$hash_base, file_name
=>($file_parent || $file_name))},
2702 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash,
2703 hash_base
=>$hash_base, file_name
=>$file_name)},
2706 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
2707 print "</div>"; # page_body
2711 sub git_blobdiff_plain
{
2712 mkdir($git_temp, 0700);
2713 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
2714 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
2717 sub git_commitdiff
{
2718 my $format = shift || 'html';
2719 my %co = parse_commit
($hash);
2721 die_error
(undef, "Unknown commit object");
2723 if (!defined $hash_parent) {
2724 $hash_parent = $co{'parent'} || '--root';
2731 if ($format eq 'html') {
2732 open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C',
2733 "--patch-with-raw", "--full-index", $hash_parent, $hash
2734 or die_error
(undef, "Open git-diff-tree failed");
2736 while (chomp(my $line = <$fd>)) {
2737 # empty line ends raw part of diff-tree output
2739 push @difftree, $line;
2741 @patchset = map { chomp; $_ } <$fd>;
2744 or die_error
(undef, "Reading git-diff-tree failed");
2745 } elsif ($format eq 'plain') {
2746 open $fd, "-|", $GIT, "diff-tree", '-r', '-p', '-B', $hash_parent, $hash
2747 or die_error
(undef, "Open git-diff-tree failed");
2749 die_error
(undef, "Unknown commitdiff format");
2752 # non-textual hash id's can be cached
2754 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2758 # write commit message
2759 if ($format eq 'html') {
2760 my $refs = git_get_references
();
2761 my $ref = format_ref_marker
($refs, $co{'id'});
2763 $cgi->a({-href
=> href
(action
=>"commitdiff_plain",
2764 hash
=>$hash, hash_parent
=>$hash_parent)},
2767 git_header_html
(undef, $expires);
2768 git_print_page_nav
('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
2769 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash);
2770 print "<div class=\"page_body\">\n";
2771 print "<div class=\"log\">\n";
2772 git_print_simplified_log
($co{'comment'}, 1); # skip title
2773 print "</div>\n"; # class="log"
2775 } elsif ($format eq 'plain') {
2776 my $refs = git_get_references
("tags");
2778 if (exists $refs->{$hash}) {
2779 @tagnames = map { s
|^tags
/|| } $refs->{$hash};
2781 my $filename = basename
($project) . "-$hash.patch";
2784 -type
=> 'text/plain',
2785 -charset
=> 'utf-8',
2786 -expires
=> $expires,
2787 -content_disposition
=> qq(inline
; filename
="$filename"));
2788 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
2791 Date: $ad{'rfc2822'} ($ad{'tz_local'})
2792 Subject: $co{'title'}
2794 foreach my $tag (@tagnames) {
2795 print "X-Git-Tag: $tag\n";
2797 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
2798 foreach my $line (@
{$co{'comment'}}) {
2805 if ($format eq 'html') {
2806 #git_difftree_body(\@difftree, $hash, $hash_parent);
2809 git_patchset_body
(\
@patchset, \
@difftree, $hash, $hash_parent);
2811 print "</div>\n"; # class="page_body"
2814 } elsif ($format eq 'plain') {
2818 or print "Reading git-diff-tree failed\n";
2822 sub git_commitdiff_plain
{
2823 git_commitdiff
('plain');
2827 if (!defined $hash_base) {
2828 $hash_base = git_get_head_hash
($project);
2831 my %co = parse_commit
($hash_base);
2833 die_error
(undef, "Unknown commit object");
2835 my $refs = git_get_references
();
2837 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base);
2838 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2839 if (!defined $hash && defined $file_name) {
2840 $hash = git_get_hash_by_path
($hash_base, $file_name);
2842 if (defined $hash) {
2843 $ftype = git_get_type
($hash);
2845 git_print_page_path
($file_name, $ftype, $hash_base);
2848 $GIT, "rev-list", "--full-history", $hash_base, "--", $file_name;
2849 git_history_body
($fd, $refs, $hash_base, $ftype);
2856 if (!defined $searchtext) {
2857 die_error
(undef, "Text field empty");
2859 if (!defined $hash) {
2860 $hash = git_get_head_hash
($project);
2862 my %co = parse_commit
($hash);
2864 die_error
(undef, "Unknown commit object");
2866 # pickaxe may take all resources of your box and run for several minutes
2867 # with every query - so decide by yourself how public you make this feature :)
2868 my $commit_search = 1;
2869 my $author_search = 0;
2870 my $committer_search = 0;
2871 my $pickaxe_search = 0;
2872 if ($searchtext =~ s/^author\\://i) {
2874 } elsif ($searchtext =~ s/^committer\\://i) {
2875 $committer_search = 1;
2876 } elsif ($searchtext =~ s/^pickaxe\\://i) {
2878 $pickaxe_search = 1;
2881 git_print_page_nav
('','', $hash,$co{'tree'},$hash);
2882 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
2884 print "<table cellspacing=\"0\">\n";
2886 if ($commit_search) {
2888 open my $fd, "-|", $GIT, "rev-list", "--header", "--parents", $hash or next;
2889 while (my $commit_text = <$fd>) {
2890 if (!grep m/$searchtext/i, $commit_text) {
2893 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2896 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2899 my @commit_lines = split "\n", $commit_text;
2900 my %co = parse_commit
(undef, \
@commit_lines);
2905 print "<tr class=\"dark\">\n";
2907 print "<tr class=\"light\">\n";
2910 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2911 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2913 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}), -class => "list subject"},
2914 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
2915 my $comment = $co{'comment'};
2916 foreach my $line (@
$comment) {
2917 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2918 my $lead = esc_html
($1) || "";
2919 $lead = chop_str
($lead, 30, 10);
2920 my $match = esc_html
($2) || "";
2921 my $trail = esc_html
($3) || "";
2922 $trail = chop_str
($trail, 30, 10);
2923 my $text = "$lead<span class=\"match\">$match</span>$trail";
2924 print chop_str
($text, 80, 5) . "<br/>\n";
2928 "<td class=\"link\">" .
2929 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
2931 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
2938 if ($pickaxe_search) {
2940 open my $fd, "-|", "$GIT rev-list $hash | $GIT diff-tree -r --stdin -S\'$searchtext\'";
2943 while (my $line = <$fd>) {
2944 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2947 $set{'from_id'} = $3;
2949 $set{'id'} = $set{'to_id'};
2950 if ($set{'id'} =~ m/0{40}/) {
2951 $set{'id'} = $set{'from_id'};
2953 if ($set{'id'} =~ m/0{40}/) {
2957 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
2960 print "<tr class=\"dark\">\n";
2962 print "<tr class=\"light\">\n";
2965 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2966 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2968 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}),
2969 -class => "list subject"},
2970 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
2971 while (my $setref = shift @files) {
2973 print $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$co{'id'},
2974 hash
=>$set{'id'}, file_name
=>$set{'file'}),
2976 "<span class=\"match\">" . esc_html
($set{'file'}) . "</span>") .
2980 "<td class=\"link\">" .
2981 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
2983 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
2987 %co = parse_commit
($1);
2997 my $head = git_get_head_hash
($project);
2998 if (!defined $hash) {
3001 if (!defined $page) {
3004 my $refs = git_get_references
();
3006 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
3007 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
3008 or die_error
(undef, "Open git-rev-list failed");
3009 my @revlist = map { chomp; $_ } <$fd>;
3012 my $paging_nav = format_paging_nav
('shortlog', $hash, $head, $page, $#revlist);
3014 if ($#revlist >= (100 * ($page+1)-1)) {
3016 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$hash, page
=>$page+1),
3017 -title
=> "Alt-n"}, "next");
3022 git_print_page_nav
('shortlog','', $hash,$hash,$hash, $paging_nav);
3023 git_print_header_div
('summary', $project);
3025 git_shortlog_body
(\
@revlist, ($page * 100), $#revlist, $refs, $next_link);
3030 ## ......................................................................
3031 ## feeds (RSS, OPML)
3034 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
3035 open my $fd, "-|", $GIT, "rev-list", "--max-count=150", git_get_head_hash
($project)
3036 or die_error
(undef, "Open git-rev-list failed");
3037 my @revlist = map { chomp; $_ } <$fd>;
3038 close $fd or die_error
(undef, "Reading git-rev-list failed");
3039 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
3041 <?xml version="1.0" encoding="utf-8"?>
3042 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
3044 <title>$project $my_uri $my_url</title>
3045 <link>${\esc_html("$my_url?p=$project;a=summary")}</link>
3046 <description>$project log</description>
3047 <language>en</language>
3050 for (my $i = 0; $i <= $#revlist; $i++) {
3051 my $commit = $revlist[$i];
3052 my %co = parse_commit
($commit);
3053 # we read 150, we always show 30 and the ones more recent than 48 hours
3054 if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) {
3057 my %cd = parse_date
($co{'committer_epoch'});
3058 open $fd, "-|", $GIT, "diff-tree", '-r', $co{'parent'}, $co{'id'} or next;
3059 my @difftree = map { chomp; $_ } <$fd>;
3063 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html
($co{'title'}) .
3065 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
3066 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
3067 "<guid isPermaLink=\"true\">" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" .
3068 "<link>" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
3069 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
3070 "<content:encoded>" .
3072 my $comment = $co{'comment'};
3073 foreach my $line (@
$comment) {
3074 $line = decode
("utf8", $line, Encode
::FB_DEFAULT
);
3075 print "$line<br/>\n";
3078 foreach my $line (@difftree) {
3079 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
3082 my $file = validate_input
(unquote
($7));
3083 $file = decode
("utf8", $file, Encode
::FB_DEFAULT
);
3084 print "$file<br/>\n";
3087 "</content:encoded>\n" .
3090 print "</channel></rss>";
3094 my @list = git_get_projects_list
();
3096 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
3098 <?xml version="1.0" encoding="utf-8"?>
3099 <opml version="1.0">
3101 <title>$site_name Git OPML Export</title>
3104 <outline text="git RSS feeds">
3107 foreach my $pr (@list) {
3109 my $head = git_get_head_hash
($proj{'path'});
3110 if (!defined $head) {
3113 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
3114 my %co = parse_commit
($head);
3119 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
3120 my $rss = "$my_url?p=$proj{'path'};a=rss";
3121 my $html = "$my_url?p=$proj{'path'};a=summary";
3122 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";