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 # skip errors (incomplete lines)
542 $diff_class = " incomplete";
544 $line = untabify
($line);
545 return "<div class=\"diff$diff_class\">" . esc_html
($line) . "</div>\n";
548 ## ----------------------------------------------------------------------
549 ## git utility subroutines, invoking git commands
551 # get HEAD ref of given project as hash
552 sub git_get_head_hash
{
554 my $oENV = $ENV{'GIT_DIR'};
556 $ENV{'GIT_DIR'} = "$projectroot/$project";
557 if (open my $fd, "-|", $GIT, "rev-parse", "--verify", "HEAD") {
560 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
565 $ENV{'GIT_DIR'} = $oENV;
570 # get type of given object
574 open my $fd, "-|", $GIT, "cat-file", '-t', $hash or return;
581 sub git_get_project_config
{
582 my ($key, $type) = @_;
584 return unless ($key);
585 $key =~ s/^gitweb\.//;
586 return if ($key =~ m/\W/);
588 my @x = ($GIT, 'repo-config');
589 if (defined $type) { push @x, $type; }
591 push @x, "gitweb.$key";
597 # get hash of given path at given ref
598 sub git_get_hash_by_path
{
600 my $path = shift || return undef;
604 open my $fd, "-|", $GIT, "ls-tree", $base, "--", $path
605 or die_error
(undef, "Open git-ls-tree failed");
607 close $fd or return undef;
609 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
610 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
614 ## ......................................................................
615 ## git utility functions, directly accessing git repository
617 # assumes that PATH is not symref
618 sub git_get_hash_by_ref
{
621 open my $fd, "$projectroot/$path" or return undef;
625 if ($head =~ m/^[0-9a-fA-F]{40}$/) {
630 sub git_get_project_description
{
633 open my $fd, "$projectroot/$path/description" or return undef;
640 sub git_get_project_url_list
{
643 open my $fd, "$projectroot/$path/cloneurl" or return undef;
644 my @git_project_url_list = map { chomp; $_ } <$fd>;
647 return wantarray ?
@git_project_url_list : \
@git_project_url_list;
650 sub git_get_projects_list
{
653 if (-d
$projects_list) {
654 # search in directory
655 my $dir = $projects_list;
656 opendir my ($dh), $dir or return undef;
657 while (my $dir = readdir($dh)) {
658 if (-e
"$projectroot/$dir/HEAD") {
666 } elsif (-f
$projects_list) {
667 # read from file(url-encoded):
668 # 'git%2Fgit.git Linus+Torvalds'
669 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
670 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
671 open my ($fd), $projects_list or return undef;
672 while (my $line = <$fd>) {
674 my ($path, $owner) = split ' ', $line;
675 $path = unescape
($path);
676 $owner = unescape
($owner);
677 if (!defined $path) {
680 if (-e
"$projectroot/$path/HEAD") {
683 owner
=> decode
("utf8", $owner, Encode
::FB_DEFAULT
),
690 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
694 sub git_get_project_owner
{
698 return undef unless $project;
700 # read from file (url-encoded):
701 # 'git%2Fgit.git Linus+Torvalds'
702 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
703 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
704 if (-f
$projects_list) {
705 open (my $fd , $projects_list);
706 while (my $line = <$fd>) {
708 my ($pr, $ow) = split ' ', $line;
711 if ($pr eq $project) {
712 $owner = decode
("utf8", $ow, Encode
::FB_DEFAULT
);
718 if (!defined $owner) {
719 $owner = get_file_owner
("$projectroot/$project");
725 sub git_get_references
{
726 my $type = shift || "";
729 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
730 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
731 if (-f
"$projectroot/$project/info/refs") {
732 open $fd, "$projectroot/$project/info/refs"
735 open $fd, "-|", $GIT, "ls-remote", "."
739 while (my $line = <$fd>) {
741 if ($line =~ m/^([0-9a-fA-F]{40})\trefs\/($type\
/?[^\^]+)/) {
742 if (defined $refs{$1}) {
743 push @
{$refs{$1}}, $2;
753 ## ----------------------------------------------------------------------
754 ## parse to hash functions
758 my $tz = shift || "-0000";
761 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
762 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
763 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
764 $date{'hour'} = $hour;
765 $date{'minute'} = $min;
766 $date{'mday'} = $mday;
767 $date{'day'} = $days[$wday];
768 $date{'month'} = $months[$mon];
769 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000",
770 $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
771 $date{'mday-time'} = sprintf "%d %s %02d:%02d",
772 $mday, $months[$mon], $hour ,$min;
774 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
775 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
776 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
777 $date{'hour_local'} = $hour;
778 $date{'minute_local'} = $min;
779 $date{'tz_local'} = $tz;
788 open my $fd, "-|", $GIT, "cat-file", "tag", $tag_id or return;
789 $tag{'id'} = $tag_id;
790 while (my $line = <$fd>) {
792 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
794 } elsif ($line =~ m/^type (.+)$/) {
796 } elsif ($line =~ m/^tag (.+)$/) {
798 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
802 } elsif ($line =~ m/--BEGIN/) {
803 push @comment, $line;
805 } elsif ($line eq "") {
809 push @comment, <$fd>;
810 $tag{'comment'} = \
@comment;
812 if (!defined $tag{'name'}) {
819 my $commit_id = shift;
820 my $commit_text = shift;
825 if (defined $commit_text) {
826 @commit_lines = @
$commit_text;
829 open my $fd, "-|", $GIT, "rev-list", "--header", "--parents", "--max-count=1", $commit_id
831 @commit_lines = split '\n', <$fd>;
836 my $header = shift @commit_lines;
837 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
840 ($co{'id'}, my @parents) = split ' ', $header;
841 $co{'parents'} = \
@parents;
842 $co{'parent'} = $parents[0];
843 while (my $line = shift @commit_lines) {
844 last if $line eq "\n";
845 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
847 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
849 $co{'author_epoch'} = $2;
850 $co{'author_tz'} = $3;
851 if ($co{'author'} =~ m/^([^<]+) </) {
852 $co{'author_name'} = $1;
854 $co{'author_name'} = $co{'author'};
856 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
857 $co{'committer'} = $1;
858 $co{'committer_epoch'} = $2;
859 $co{'committer_tz'} = $3;
860 $co{'committer_name'} = $co{'committer'};
861 $co{'committer_name'} =~ s/ <.*//;
864 if (!defined $co{'tree'}) {
868 foreach my $title (@commit_lines) {
871 $co{'title'} = chop_str
($title, 80, 5);
872 # remove leading stuff of merges to make the interesting part visible
873 if (length($title) > 50) {
874 $title =~ s/^Automatic //;
875 $title =~ s/^merge (of|with) /Merge ... /i;
876 if (length($title) > 50) {
877 $title =~ s/(http|rsync):\/\///;
879 if (length($title) > 50) {
880 $title =~ s/(master|www|rsync)\.//;
882 if (length($title) > 50) {
883 $title =~ s/kernel.org:?//;
885 if (length($title) > 50) {
886 $title =~ s/\/pub\/scm//;
889 $co{'title_short'} = chop_str
($title, 50, 5);
893 # remove added spaces
894 foreach my $line (@commit_lines) {
897 $co{'comment'} = \
@commit_lines;
899 my $age = time - $co{'committer_epoch'};
901 $co{'age_string'} = age_string
($age);
902 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
903 if ($age > 60*60*24*7*2) {
904 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
905 $co{'age_string_age'} = $co{'age_string'};
907 $co{'age_string_date'} = $co{'age_string'};
908 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
913 # parse ref from ref_file, given by ref_id, with given type
915 my $ref_file = shift;
917 my $type = shift || git_get_type
($ref_id);
920 $ref_item{'type'} = $type;
921 $ref_item{'id'} = $ref_id;
922 $ref_item{'epoch'} = 0;
923 $ref_item{'age'} = "unknown";
924 if ($type eq "tag") {
925 my %tag = parse_tag
($ref_id);
926 $ref_item{'comment'} = $tag{'comment'};
927 if ($tag{'type'} eq "commit") {
928 my %co = parse_commit
($tag{'object'});
929 $ref_item{'epoch'} = $co{'committer_epoch'};
930 $ref_item{'age'} = $co{'age_string'};
931 } elsif (defined($tag{'epoch'})) {
932 my $age = time - $tag{'epoch'};
933 $ref_item{'epoch'} = $tag{'epoch'};
934 $ref_item{'age'} = age_string
($age);
936 $ref_item{'reftype'} = $tag{'type'};
937 $ref_item{'name'} = $tag{'name'};
938 $ref_item{'refid'} = $tag{'object'};
939 } elsif ($type eq "commit"){
940 my %co = parse_commit
($ref_id);
941 $ref_item{'reftype'} = "commit";
942 $ref_item{'name'} = $ref_file;
943 $ref_item{'title'} = $co{'title'};
944 $ref_item{'refid'} = $ref_id;
945 $ref_item{'epoch'} = $co{'committer_epoch'};
946 $ref_item{'age'} = $co{'age_string'};
948 $ref_item{'reftype'} = $type;
949 $ref_item{'name'} = $ref_file;
950 $ref_item{'refid'} = $ref_id;
956 # parse line of git-diff-tree "raw" output
957 sub parse_difftree_raw_line
{
961 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
962 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
963 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
964 $res{'from_mode'} = $1;
965 $res{'to_mode'} = $2;
966 $res{'from_id'} = $3;
969 $res{'similarity'} = $6;
970 if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
971 ($res{'from_file'}, $res{'to_file'}) = map { unquote
($_) } split("\t", $7);
973 $res{'file'} = unquote
($7);
976 # 'c512b523472485aef4fff9e57b229d9d243c967f'
977 #elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
978 # $res{'commit'} = $1;
981 return wantarray ?
%res : \
%res;
984 ## ......................................................................
985 ## parse to array of hashes functions
987 sub git_get_refs_list
{
992 my $pfxlen = length("$projectroot/$project/$ref_dir");
993 File
::Find
::find
(sub {
996 push @refs, substr($File::Find
::name
, $pfxlen + 1);
998 }, "$projectroot/$project/$ref_dir");
1000 foreach my $ref_file (@refs) {
1001 my $ref_id = git_get_hash_by_ref
("$project/$ref_dir/$ref_file");
1002 my $type = git_get_type
($ref_id) || next;
1003 my %ref_item = parse_ref
($ref_file, $ref_id, $type);
1005 push @reflist, \
%ref_item;
1008 @reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
1012 ## ----------------------------------------------------------------------
1013 ## filesystem-related functions
1015 sub get_file_owner
{
1018 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
1019 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
1020 if (!defined $gcos) {
1024 $owner =~ s/[,;].*$//;
1025 return decode
("utf8", $owner, Encode
::FB_DEFAULT
);
1028 ## ......................................................................
1029 ## mimetype related functions
1031 sub mimetype_guess_file
{
1032 my $filename = shift;
1033 my $mimemap = shift;
1034 -r
$mimemap or return undef;
1037 open(MIME
, $mimemap) or return undef;
1039 next if m/^#/; # skip comments
1040 my ($mime, $exts) = split(/\t+/);
1041 if (defined $exts) {
1042 my @exts = split(/\s+/, $exts);
1043 foreach my $ext (@exts) {
1044 $mimemap{$ext} = $mime;
1050 $filename =~ /\.(.*?)$/;
1051 return $mimemap{$1};
1054 sub mimetype_guess
{
1055 my $filename = shift;
1057 $filename =~ /\./ or return undef;
1059 if ($mimetypes_file) {
1060 my $file = $mimetypes_file;
1061 if ($file !~ m!^/!) { # if it is relative path
1062 # it is relative to project
1063 $file = "$projectroot/$project/$file";
1065 $mime = mimetype_guess_file
($filename, $file);
1067 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
1073 my $filename = shift;
1076 my $mime = mimetype_guess
($filename);
1077 $mime and return $mime;
1081 return $default_blob_plain_mimetype unless $fd;
1084 return 'text/plain' .
1085 ($default_text_plain_charset ?
'; charset='.$default_text_plain_charset : '');
1086 } elsif (! $filename) {
1087 return 'application/octet-stream';
1088 } elsif ($filename =~ m/\.png$/i) {
1090 } elsif ($filename =~ m/\.gif$/i) {
1092 } elsif ($filename =~ m/\.jpe?g$/i) {
1093 return 'image/jpeg';
1095 return 'application/octet-stream';
1099 ## ======================================================================
1100 ## functions printing HTML: header, footer, error page
1102 sub git_header_html
{
1103 my $status = shift || "200 OK";
1104 my $expires = shift;
1106 my $title = "$site_name git";
1107 if (defined $project) {
1108 $title .= " - $project";
1109 if (defined $action) {
1110 $title .= "/$action";
1111 if (defined $file_name) {
1112 $title .= " - $file_name";
1113 if ($action eq "tree" && $file_name !~ m
|/$|) {
1120 # require explicit support from the UA if we are to send the page as
1121 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
1122 # we have to do this because MSIE sometimes globs '*/*', pretending to
1123 # support xhtml+xml but choking when it gets what it asked for.
1124 if (defined $cgi->http('HTTP_ACCEPT') &&
1125 $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ &&
1126 $cgi->Accept('application/xhtml+xml') != 0) {
1127 $content_type = 'application/xhtml+xml';
1129 $content_type = 'text/html';
1131 print $cgi->header(-type
=>$content_type, -charset
=> 'utf-8',
1132 -status
=> $status, -expires
=> $expires);
1134 <?xml version="1.0" encoding="utf-8"?>
1135 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1136 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
1137 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
1138 <!-- git core binaries version $git_version -->
1140 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
1141 <meta name="generator" content="gitweb/$version git/$git_version"/>
1142 <meta name="robots" content="index, nofollow"/>
1143 <title>$title</title>
1144 <link rel="stylesheet" type="text/css" href="$stylesheet"/>
1146 if (defined $project) {
1147 printf('<link rel="alternate" title="%s log" '.
1148 'href="%s" type="application/rss+xml"/>'."\n",
1149 esc_param
($project), href
(action
=>"rss"));
1154 "<div class=\"page_header\">\n" .
1155 "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
1156 "<img src=\"$logo\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
1158 print $cgi->a({-href
=> esc_param
($home_link)}, $home_link_str) . " / ";
1159 if (defined $project) {
1160 print $cgi->a({-href
=> href
(action
=>"summary")}, esc_html
($project));
1161 if (defined $action) {
1165 if (!defined $searchtext) {
1169 if (defined $hash_base) {
1170 $search_hash = $hash_base;
1171 } elsif (defined $hash) {
1172 $search_hash = $hash;
1174 $search_hash = "HEAD";
1176 $cgi->param("a", "search");
1177 $cgi->param("h", $search_hash);
1178 print $cgi->startform(-method
=> "get", -action
=> $my_uri) .
1179 "<div class=\"search\">\n" .
1180 $cgi->hidden(-name
=> "p") . "\n" .
1181 $cgi->hidden(-name
=> "a") . "\n" .
1182 $cgi->hidden(-name
=> "h") . "\n" .
1183 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
1185 $cgi->end_form() . "\n";
1190 sub git_footer_html
{
1191 print "<div class=\"page_footer\">\n";
1192 if (defined $project) {
1193 my $descr = git_get_project_description
($project);
1194 if (defined $descr) {
1195 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
1197 print $cgi->a({-href
=> href
(action
=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
1199 print $cgi->a({-href
=> href
(action
=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
1207 my $status = shift || "403 Forbidden";
1208 my $error = shift || "Malformed query, file missing or permission denied";
1210 git_header_html
($status);
1212 <div class="page_body">
1222 ## ----------------------------------------------------------------------
1223 ## functions printing or outputting HTML: navigation
1225 sub git_print_page_nav
{
1226 my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
1227 $extra = '' if !defined $extra; # pager or formats
1229 my @navs = qw(summary shortlog log commit commitdiff tree);
1231 @navs = grep { $_ ne $suppress } @navs;
1234 my %arg = map { $_ => {action
=>$_} } @navs;
1235 if (defined $head) {
1236 for (qw(commit commitdiff)) {
1237 $arg{$_}{hash
} = $head;
1239 if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
1240 for (qw(shortlog log)) {
1241 $arg{$_}{hash
} = $head;
1245 $arg{tree
}{hash
} = $treehead if defined $treehead;
1246 $arg{tree
}{hash_base
} = $treebase if defined $treebase;
1248 print "<div class=\"page_nav\">\n" .
1250 map { $_ eq $current ?
1251 $_ : $cgi->a({-href
=> href
(%{$arg{$_}})}, "$_")
1253 print "<br/>\n$extra<br/>\n" .
1257 sub format_paging_nav
{
1258 my ($action, $hash, $head, $page, $nrevs) = @_;
1262 if ($hash ne $head || $page) {
1263 $paging_nav .= $cgi->a({-href
=> href
(action
=>$action)}, "HEAD");
1265 $paging_nav .= "HEAD";
1269 $paging_nav .= " ⋅ " .
1270 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page-1),
1271 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1273 $paging_nav .= " ⋅ prev";
1276 if ($nrevs >= (100 * ($page+1)-1)) {
1277 $paging_nav .= " ⋅ " .
1278 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page+1),
1279 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1281 $paging_nav .= " ⋅ next";
1287 ## ......................................................................
1288 ## functions printing or outputting HTML: div
1290 sub git_print_header_div
{
1291 my ($action, $title, $hash, $hash_base) = @_;
1294 $args{action
} = $action;
1295 $args{hash
} = $hash if $hash;
1296 $args{hash_base
} = $hash_base if $hash_base;
1298 print "<div class=\"header\">\n" .
1299 $cgi->a({-href
=> href
(%args), -class => "title"},
1300 $title ?
$title : $action) .
1304 sub git_print_page_path
{
1309 if (!defined $name) {
1310 print "<div class=\"page_path\">/</div>\n";
1311 } elsif (defined $type && $type eq 'blob') {
1312 print "<div class=\"page_path\">";
1314 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name,
1318 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name)},
1321 print "<br/></div>\n";
1323 print "<div class=\"page_path\">" . esc_html
($name) . "<br/></div>\n";
1330 # remove leading empty lines
1331 while (defined $log->[0] && $log->[0] eq "") {
1338 foreach my $line (@
$log) {
1339 # print only one empty line
1340 # do not print empty line after signoff
1342 next if ($empty || $signoff);
1347 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1349 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
1352 print format_log_line_html
($line) . "<br/>\n";
1357 sub git_print_simplified_log
{
1359 my $remove_title = shift;
1361 shift @
$log if $remove_title;
1362 # remove leading empty lines
1363 while (defined $log->[0] && $log->[0] eq "") {
1367 # simplify and print log
1369 foreach my $line (@
$log) {
1370 # remove signoff lines
1371 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1374 # print only one empty line
1381 print format_log_line_html
($line) . "<br/>\n";
1383 # end with single empty line
1384 print "<br/>\n" unless $empty;
1387 ## ......................................................................
1388 ## functions printing large fragments of HTML
1390 sub git_difftree_body
{
1391 my ($difftree, $hash, $parent) = @_;
1393 print "<div class=\"list_head\">\n";
1394 if ($#{$difftree} > 10) {
1395 print(($#{$difftree} + 1) . " files changed:\n");
1399 print "<table class=\"diff_tree\">\n";
1401 foreach my $line (@
{$difftree}) {
1402 my %diff = parse_difftree_raw_line
($line);
1405 print "<tr class=\"dark\">\n";
1407 print "<tr class=\"light\">\n";
1411 my ($to_mode_oct, $to_mode_str, $to_file_type);
1412 my ($from_mode_oct, $from_mode_str, $from_file_type);
1413 if ($diff{'to_mode'} ne ('0' x
6)) {
1414 $to_mode_oct = oct $diff{'to_mode'};
1415 if (S_ISREG
($to_mode_oct)) { # only for regular file
1416 $to_mode_str = sprintf("%04o", $to_mode_oct & 0777); # permission bits
1418 $to_file_type = file_type
($diff{'to_mode'});
1420 if ($diff{'from_mode'} ne ('0' x
6)) {
1421 $from_mode_oct = oct $diff{'from_mode'};
1422 if (S_ISREG
($to_mode_oct)) { # only for regular file
1423 $from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
1425 $from_file_type = file_type
($diff{'from_mode'});
1428 if ($diff{'status'} eq "A") { # created
1429 my $mode_chng = "<span class=\"file_status new\">[new $to_file_type";
1430 $mode_chng .= " with mode: $to_mode_str" if $to_mode_str;
1431 $mode_chng .= "]</span>";
1433 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1434 hash_base
=>$hash, file_name
=>$diff{'file'}),
1435 -class => "list"}, esc_html
($diff{'file'})) .
1437 "<td>$mode_chng</td>\n" .
1438 "<td class=\"link\">" .
1439 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1440 hash_base
=>$hash, file_name
=>$diff{'file'})},
1444 } elsif ($diff{'status'} eq "D") { # deleted
1445 my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
1447 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
1448 hash_base
=>$parent, file_name
=>$diff{'file'}),
1449 -class => "list"}, esc_html
($diff{'file'})) .
1451 "<td>$mode_chng</td>\n" .
1452 "<td class=\"link\">" .
1453 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
1454 hash_base
=>$parent, file_name
=>$diff{'file'})},
1457 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$parent,
1458 file_name
=>$diff{'file'})},\
1462 } elsif ($diff{'status'} eq "M" || $diff{'status'} eq "T") { # modified, or type changed
1463 my $mode_chnge = "";
1464 if ($diff{'from_mode'} != $diff{'to_mode'}) {
1465 $mode_chnge = "<span class=\"file_status mode_chnge\">[changed";
1466 if ($from_file_type != $to_file_type) {
1467 $mode_chnge .= " from $from_file_type to $to_file_type";
1469 if (($from_mode_oct & 0777) != ($to_mode_oct & 0777)) {
1470 if ($from_mode_str && $to_mode_str) {
1471 $mode_chnge .= " mode: $from_mode_str->$to_mode_str";
1472 } elsif ($to_mode_str) {
1473 $mode_chnge .= " mode: $to_mode_str";
1476 $mode_chnge .= "]</span>\n";
1479 if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
1480 print $cgi->a({-href
=> href
(action
=>"blobdiff", hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
1481 hash_base
=>$hash, file_name
=>$diff{'file'}),
1482 -class => "list"}, esc_html
($diff{'file'}));
1483 } else { # only mode changed
1484 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1485 hash_base
=>$hash, file_name
=>$diff{'file'}),
1486 -class => "list"}, esc_html
($diff{'file'}));
1489 "<td>$mode_chnge</td>\n" .
1490 "<td class=\"link\">" .
1491 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
1492 hash_base
=>$hash, file_name
=>$diff{'file'})},
1494 if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
1496 $cgi->a({-href
=> href
(action
=>"blobdiff", hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
1497 hash_base
=>$hash, file_name
=>$diff{'file'})},
1501 $cgi->a({-href
=> href
(action
=>"history",
1502 hash_base
=>$hash, file_name
=>$diff{'file'})},
1506 } elsif ($diff{'status'} eq "R" || $diff{'status'} eq "C") { # renamed or copied
1507 my %status_name = ('R' => 'moved', 'C' => 'copied');
1508 my $nstatus = $status_name{$diff{'status'}};
1510 if ($diff{'from_mode'} != $diff{'to_mode'}) {
1511 # mode also for directories, so we cannot use $to_mode_str
1512 $mode_chng = sprintf(", mode: %04o", $to_mode_oct & 0777);
1515 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1516 hash
=>$diff{'to_id'}, file_name
=>$diff{'to_file'}),
1517 -class => "list"}, esc_html
($diff{'to_file'})) . "</td>\n" .
1518 "<td><span class=\"file_status $nstatus\">[$nstatus from " .
1519 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$parent,
1520 hash
=>$diff{'from_id'}, file_name
=>$diff{'from_file'}),
1521 -class => "list"}, esc_html
($diff{'from_file'})) .
1522 " with " . (int $diff{'similarity'}) . "% similarity$mode_chng]</span></td>\n" .
1523 "<td class=\"link\">" .
1524 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1525 hash
=>$diff{'to_id'}, file_name
=>$diff{'to_file'})},
1527 if ($diff{'to_id'} ne $diff{'from_id'}) {
1529 $cgi->a({-href
=> href
(action
=>"blobdiff", hash_base
=>$hash,
1530 hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
1531 file_name
=>$diff{'to_file'}, file_parent
=>$diff{'from_file'})},
1536 } # we should not encounter Unmerged (U) or Unknown (X) status
1542 sub git_patchset_body
{
1543 my ($patchset, $difftree, $hash, $hash_parent) = @_;
1547 my $patch_found = 0;
1550 print "<div class=\"patchset\">\n";
1552 LINE
: foreach my $patch_line (@
$patchset) {
1554 if ($patch_line =~ m/^diff /) { # "git diff" header
1555 # beginning of patch (in patchset)
1557 # close previous patch
1558 print "</div>\n"; # class="patch"
1560 # first patch in patchset
1563 print "<div class=\"patch\">\n";
1565 %diffinfo = parse_difftree_raw_line
($difftree->[$patch_idx++]);
1567 # for now, no extended header, hence we skip empty patches
1568 # companion to next LINE if $in_header;
1569 if ($diffinfo{'from_id'} eq $diffinfo{'to_id'}) { # no change
1574 if ($diffinfo{'status'} eq "A") { # added
1575 print "<div class=\"diff_info\">" . file_type
($diffinfo{'to_mode'}) . ":" .
1576 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1577 hash
=>$diffinfo{'to_id'}, file_name
=>$diffinfo{'file'})},
1578 $diffinfo{'to_id'}) . "(new)" .
1579 "</div>\n"; # class="diff_info"
1581 } elsif ($diffinfo{'status'} eq "D") { # deleted
1582 print "<div class=\"diff_info\">" . file_type
($diffinfo{'from_mode'}) . ":" .
1583 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash_parent,
1584 hash
=>$diffinfo{'from_id'}, file_name
=>$diffinfo{'file'})},
1585 $diffinfo{'from_id'}) . "(deleted)" .
1586 "</div>\n"; # class="diff_info"
1588 } elsif ($diffinfo{'status'} eq "R" || # renamed
1589 $diffinfo{'status'} eq "C") { # copied
1590 print "<div class=\"diff_info\">" .
1591 file_type
($diffinfo{'from_mode'}) . ":" .
1592 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash_parent,
1593 hash
=>$diffinfo{'from_id'}, file_name
=>$diffinfo{'from_file'})},
1594 $diffinfo{'from_id'}) .
1596 file_type
($diffinfo{'to_mode'}) . ":" .
1597 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1598 hash
=>$diffinfo{'to_id'}, file_name
=>$diffinfo{'to_file'})},
1599 $diffinfo{'to_id'});
1600 print "</div>\n"; # class="diff_info"
1602 } else { # modified, mode changed, ...
1603 print "<div class=\"diff_info\">" .
1604 file_type
($diffinfo{'from_mode'}) . ":" .
1605 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash_parent,
1606 hash
=>$diffinfo{'from_id'}, file_name
=>$diffinfo{'file'})},
1607 $diffinfo{'from_id'}) .
1609 file_type
($diffinfo{'to_mode'}) . ":" .
1610 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
1611 hash
=>$diffinfo{'to_id'}, file_name
=>$diffinfo{'file'})},
1612 $diffinfo{'to_id'});
1613 print "</div>\n"; # class="diff_info"
1616 #print "<div class=\"diff extended_header\">\n";
1619 } # start of patch in patchset
1622 if ($in_header && $patch_line =~ m/^---/) {
1626 next LINE
if $in_header;
1628 print format_diff_line
($patch_line);
1630 print "</div>\n" if $patch_found; # class="patch"
1632 print "</div>\n"; # class="patchset"
1635 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1637 sub git_shortlog_body
{
1638 # uses global variable $project
1639 my ($revlist, $from, $to, $refs, $extra) = @_;
1641 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
1642 my $have_snapshot = (defined $ctype && defined $suffix);
1644 $from = 0 unless defined $from;
1645 $to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
1647 print "<table class=\"shortlog\" cellspacing=\"0\">\n";
1649 for (my $i = $from; $i <= $to; $i++) {
1650 my $commit = $revlist->[$i];
1651 #my $ref = defined $refs ? format_ref_marker($refs, $commit) : '';
1652 my $ref = format_ref_marker
($refs, $commit);
1653 my %co = parse_commit
($commit);
1655 print "<tr class=\"dark\">\n";
1657 print "<tr class=\"light\">\n";
1660 # git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
1661 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1662 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
1664 print format_subject_html
($co{'title'}, $co{'title_short'},
1665 href
(action
=>"commit", hash
=>$commit), $ref);
1667 "<td class=\"link\">" .
1668 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
1669 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff");
1670 if ($have_snapshot) {
1671 print " | " . $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$commit)}, "snapshot");
1676 if (defined $extra) {
1678 "<td colspan=\"4\">$extra</td>\n" .
1684 sub git_history_body
{
1685 # Warning: assumes constant type (blob or tree) during history
1686 my ($fd, $refs, $hash_base, $ftype, $extra) = @_;
1688 print "<table class=\"history\" cellspacing=\"0\">\n";
1690 while (my $line = <$fd>) {
1691 if ($line !~ m/^([0-9a-fA-F]{40})/) {
1696 my %co = parse_commit
($commit);
1701 my $ref = format_ref_marker
($refs, $commit);
1704 print "<tr class=\"dark\">\n";
1706 print "<tr class=\"light\">\n";
1709 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
1710 # shortlog uses chop_str($co{'author_name'}, 10)
1711 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
1713 # originally git_history used chop_str($co{'title'}, 50)
1714 print format_subject_html
($co{'title'}, $co{'title_short'},
1715 href
(action
=>"commit", hash
=>$commit), $ref);
1717 "<td class=\"link\">" .
1718 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
1719 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") . " | " .
1720 $cgi->a({-href
=> href
(action
=>$ftype, hash_base
=>$commit, file_name
=>$file_name)}, $ftype);
1722 if ($ftype eq 'blob') {
1723 my $blob_current = git_get_hash_by_path
($hash_base, $file_name);
1724 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
1725 if (defined $blob_current && defined $blob_parent &&
1726 $blob_current ne $blob_parent) {
1728 $cgi->a({-href
=> href
(action
=>"blobdiff", hash
=>$blob_current, hash_parent
=>$blob_parent,
1729 hash_base
=>$commit, file_name
=>$file_name)},
1736 if (defined $extra) {
1738 "<td colspan=\"4\">$extra</td>\n" .
1745 # uses global variable $project
1746 my ($taglist, $from, $to, $extra) = @_;
1747 $from = 0 unless defined $from;
1748 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
1750 print "<table class=\"tags\" cellspacing=\"0\">\n";
1752 for (my $i = $from; $i <= $to; $i++) {
1753 my $entry = $taglist->[$i];
1755 my $comment_lines = $tag{'comment'};
1756 my $comment = shift @
$comment_lines;
1758 if (defined $comment) {
1759 $comment_short = chop_str
($comment, 30, 5);
1762 print "<tr class=\"dark\">\n";
1764 print "<tr class=\"light\">\n";
1767 print "<td><i>$tag{'age'}</i></td>\n" .
1769 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'}),
1770 -class => "list name"}, esc_html
($tag{'name'})) .
1773 if (defined $comment) {
1774 print format_subject_html
($comment, $comment_short,
1775 href
(action
=>"tag", hash
=>$tag{'id'}));
1778 "<td class=\"selflink\">";
1779 if ($tag{'type'} eq "tag") {
1780 print $cgi->a({-href
=> href
(action
=>"tag", hash
=>$tag{'id'})}, "tag");
1785 "<td class=\"link\">" . " | " .
1786 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'})}, $tag{'reftype'});
1787 if ($tag{'reftype'} eq "commit") {
1788 print " | " . $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") .
1789 " | " . $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'refid'})}, "log");
1790 } elsif ($tag{'reftype'} eq "blob") {
1791 print " | " . $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$tag{'refid'})}, "raw");
1796 if (defined $extra) {
1798 "<td colspan=\"5\">$extra</td>\n" .
1804 sub git_heads_body
{
1805 # uses global variable $project
1806 my ($taglist, $head, $from, $to, $extra) = @_;
1807 $from = 0 unless defined $from;
1808 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
1810 print "<table class=\"heads\" cellspacing=\"0\">\n";
1812 for (my $i = $from; $i <= $to; $i++) {
1813 my $entry = $taglist->[$i];
1815 my $curr = $tag{'id'} eq $head;
1817 print "<tr class=\"dark\">\n";
1819 print "<tr class=\"light\">\n";
1822 print "<td><i>$tag{'age'}</i></td>\n" .
1823 ($tag{'id'} eq $head ?
"<td class=\"current_head\">" : "<td>") .
1824 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'}),
1825 -class => "list name"},esc_html
($tag{'name'})) .
1827 "<td class=\"link\">" .
1828 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") . " | " .
1829 $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'name'})}, "log") .
1833 if (defined $extra) {
1835 "<td colspan=\"3\">$extra</td>\n" .
1841 ## ----------------------------------------------------------------------
1842 ## functions printing large fragments, format as one of arguments
1844 sub git_diff_print
{
1846 my $from_name = shift;
1848 my $to_name = shift;
1849 my $format = shift || "html";
1851 my $from_tmp = "/dev/null";
1852 my $to_tmp = "/dev/null";
1855 # create tmp from-file
1856 if (defined $from) {
1857 $from_tmp = "$git_temp/gitweb_" . $$ . "_from";
1858 open my $fd2, "> $from_tmp";
1859 open my $fd, "-|", $GIT, "cat-file", "blob", $from;
1866 # create tmp to-file
1868 $to_tmp = "$git_temp/gitweb_" . $$ . "_to";
1869 open my $fd2, "> $to_tmp";
1870 open my $fd, "-|", $GIT, "cat-file", "blob", $to;
1877 open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp";
1878 if ($format eq "plain") {
1883 while (my $line = <$fd>) {
1885 my $char = substr($line, 0, 1);
1886 my $diff_class = "";
1888 $diff_class = " add";
1889 } elsif ($char eq "-") {
1890 $diff_class = " rem";
1891 } elsif ($char eq "@") {
1892 $diff_class = " chunk_header";
1893 } elsif ($char eq "\\") {
1897 $line = untabify
($line);
1898 print "<div class=\"diff$diff_class\">" . esc_html
($line) . "</div>\n";
1903 if (defined $from) {
1912 ## ======================================================================
1913 ## ======================================================================
1916 sub git_project_list
{
1917 my $order = $cgi->param('o');
1918 if (defined $order && $order !~ m/project|descr|owner|age/) {
1919 die_error
(undef, "Unknown order parameter");
1922 my @list = git_get_projects_list
();
1925 die_error
(undef, "No projects found");
1927 foreach my $pr (@list) {
1928 my $head = git_get_head_hash
($pr->{'path'});
1929 if (!defined $head) {
1932 $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}";
1933 my %co = parse_commit
($head);
1937 $pr->{'commit'} = \
%co;
1938 if (!defined $pr->{'descr'}) {
1939 my $descr = git_get_project_description
($pr->{'path'}) || "";
1940 $pr->{'descr'} = chop_str
($descr, 25, 5);
1942 if (!defined $pr->{'owner'}) {
1943 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
1945 push @projects, $pr;
1949 if (-f
$home_text) {
1950 print "<div class=\"index_include\">\n";
1951 open (my $fd, $home_text);
1956 print "<table class=\"project_list\">\n" .
1958 $order ||= "project";
1959 if ($order eq "project") {
1960 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
1961 print "<th>Project</th>\n";
1964 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=project"),
1965 -class => "header"}, "Project") .
1968 if ($order eq "descr") {
1969 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
1970 print "<th>Description</th>\n";
1973 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=descr"),
1974 -class => "header"}, "Description") .
1977 if ($order eq "owner") {
1978 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
1979 print "<th>Owner</th>\n";
1982 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=owner"),
1983 -class => "header"}, "Owner") .
1986 if ($order eq "age") {
1987 @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
1988 print "<th>Last Change</th>\n";
1991 $cgi->a({-href
=> "$my_uri?" . esc_param
("o=age"),
1992 -class => "header"}, "Last Change") .
1995 print "<th></th>\n" .
1998 foreach my $pr (@projects) {
2000 print "<tr class=\"dark\">\n";
2002 print "<tr class=\"light\">\n";
2005 print "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
2006 -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
2007 "<td>" . esc_html
($pr->{'descr'}) . "</td>\n" .
2008 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
2009 print "<td class=\"". age_class
($pr->{'commit'}{'age'}) . "\">" .
2010 $pr->{'commit'}{'age_string'} . "</td>\n" .
2011 "<td class=\"link\">" .
2012 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary")}, "summary") . " | " .
2013 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"shortlog")}, "shortlog") . " | " .
2014 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"log")}, "log") .
2023 my $descr = git_get_project_description
($project) || "none";
2024 my $head = git_get_head_hash
($project);
2025 my %co = parse_commit
($head);
2026 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
2028 my $owner = git_get_project_owner
($project);
2030 my $refs = git_get_references
();
2032 git_print_page_nav
('summary','', $head);
2034 print "<div class=\"title\"> </div>\n";
2035 print "<table cellspacing=\"0\">\n" .
2036 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
2037 "<tr><td>owner</td><td>$owner</td></tr>\n" .
2038 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
2039 # use per project git URL list in $projectroot/$project/cloneurl
2040 # or make project git URL from git base URL and project name
2041 my $url_tag = "URL";
2042 my @url_list = git_get_project_url_list
($project);
2043 @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
2044 foreach my $git_url (@url_list) {
2045 next unless $git_url;
2046 print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
2051 open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash
($project)
2052 or die_error
(undef, "Open git-rev-list failed");
2053 my @revlist = map { chomp; $_ } <$fd>;
2055 git_print_header_div
('shortlog');
2056 git_shortlog_body
(\
@revlist, 0, 15, $refs,
2057 $cgi->a({-href
=> href
(action
=>"shortlog")}, "..."));
2059 my $taglist = git_get_refs_list
("refs/tags");
2060 if (defined @
$taglist) {
2061 git_print_header_div
('tags');
2062 git_tags_body
($taglist, 0, 15,
2063 $cgi->a({-href
=> href
(action
=>"tags")}, "..."));
2066 my $headlist = git_get_refs_list
("refs/heads");
2067 if (defined @
$headlist) {
2068 git_print_header_div
('heads');
2069 git_heads_body
($headlist, $head, 0, 15,
2070 $cgi->a({-href
=> href
(action
=>"heads")}, "..."));
2077 my $head = git_get_head_hash
($project);
2079 git_print_page_nav
('','', $head,undef,$head);
2080 my %tag = parse_tag
($hash);
2081 git_print_header_div
('commit', esc_html
($tag{'name'}), $hash);
2082 print "<div class=\"title_text\">\n" .
2083 "<table cellspacing=\"0\">\n" .
2085 "<td>object</td>\n" .
2086 "<td>" . $cgi->a({-class => "list", -href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
2087 $tag{'object'}) . "</td>\n" .
2088 "<td class=\"link\">" . $cgi->a({-href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
2089 $tag{'type'}) . "</td>\n" .
2091 if (defined($tag{'author'})) {
2092 my %ad = parse_date
($tag{'epoch'}, $tag{'tz'});
2093 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
2094 print "<tr><td></td><td>" . $ad{'rfc2822'} .
2095 sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) .
2098 print "</table>\n\n" .
2100 print "<div class=\"page_body\">";
2101 my $comment = $tag{'comment'};
2102 foreach my $line (@
$comment) {
2103 print esc_html
($line) . "<br/>\n";
2113 if (!gitweb_check_feature
('blame')) {
2114 die_error
('403 Permission denied', "Permission denied");
2116 die_error
('404 Not Found', "File name not defined") if (!$file_name);
2117 $hash_base ||= git_get_head_hash
($project);
2118 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
2119 my %co = parse_commit
($hash_base)
2120 or die_error
(undef, "Reading commit failed");
2121 if (!defined $hash) {
2122 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
2123 or die_error
(undef, "Error looking up file");
2125 $ftype = git_get_type
($hash);
2126 if ($ftype !~ "blob") {
2127 die_error
("400 Bad Request", "Object is not a blob");
2129 open ($fd, "-|", $GIT, "blame", '-l', $file_name, $hash_base)
2130 or die_error
(undef, "Open git-blame failed");
2133 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
2136 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
2138 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2139 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2140 git_print_page_path
($file_name, $ftype, $hash_base);
2141 my @rev_color = (qw(light2 dark2));
2142 my $num_colors = scalar(@rev_color);
2143 my $current_color = 0;
2146 <div class="page_body">
2147 <table class="blame">
2148 <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
2151 /^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
2153 my $rev = substr($full_rev, 0, 8);
2157 if (!defined $last_rev) {
2158 $last_rev = $full_rev;
2159 } elsif ($last_rev ne $full_rev) {
2160 $last_rev = $full_rev;
2161 $current_color = ++$current_color % $num_colors;
2163 print "<tr class=\"$rev_color[$current_color]\">\n";
2164 print "<td class=\"sha1\">" .
2165 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$full_rev, file_name
=>$file_name)},
2166 esc_html
($rev)) . "</td>\n";
2167 print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" .
2168 esc_html
($lineno) . "</a></td>\n";
2169 print "<td class=\"pre\">" . esc_html
($data) . "</td>\n";
2175 or print "Reading blob failed\n";
2182 if (!gitweb_check_feature
('blame')) {
2183 die_error
('403 Permission denied', "Permission denied");
2185 die_error
('404 Not Found', "File name not defined") if (!$file_name);
2186 $hash_base ||= git_get_head_hash
($project);
2187 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
2188 my %co = parse_commit
($hash_base)
2189 or die_error
(undef, "Reading commit failed");
2190 if (!defined $hash) {
2191 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
2192 or die_error
(undef, "Error lookup file");
2194 open ($fd, "-|", $GIT, "annotate", '-l', '-t', '-r', $file_name, $hash_base)
2195 or die_error
(undef, "Open git-annotate failed");
2198 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
2201 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
2203 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2204 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2205 git_print_page_path
($file_name, 'blob', $hash_base);
2206 print "<div class=\"page_body\">\n";
2208 <table class="blame">
2217 my @line_class = (qw(light dark));
2218 my $line_class_len = scalar (@line_class);
2219 my $line_class_num = $#line_class;
2220 while (my $line = <$fd>) {
2232 $line_class_num = ($line_class_num + 1) % $line_class_len;
2234 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) \+\d\d\d\d\t(\d+)\)(.*)$/) {
2241 print qq( <tr
><td colspan
="5" class="error">Unable to parse
: $line</td></tr
>\n);
2244 $short_rev = substr ($long_rev, 0, 8);
2245 $age = time () - $time;
2246 $age_str = age_string
($age);
2247 $age_str =~ s/ / /g;
2248 $age_class = age_class
($age);
2249 $author = esc_html
($author);
2250 $author =~ s/ / /g;
2252 $data = untabify
($data);
2253 $data = esc_html
($data);
2256 <tr class="$line_class[$line_class_num]">
2257 <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
2258 <td class="$age_class">$age_str</td>
2260 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
2261 <td class="pre">$data</td>
2264 } # while (my $line = <$fd>)
2265 print "</table>\n\n";
2267 or print "Reading blob failed.\n";
2273 my $head = git_get_head_hash
($project);
2275 git_print_page_nav
('','', $head,undef,$head);
2276 git_print_header_div
('summary', $project);
2278 my $taglist = git_get_refs_list
("refs/tags");
2279 if (defined @
$taglist) {
2280 git_tags_body
($taglist);
2286 my $head = git_get_head_hash
($project);
2288 git_print_page_nav
('','', $head,undef,$head);
2289 git_print_header_div
('summary', $project);
2291 my $taglist = git_get_refs_list
("refs/heads");
2292 if (defined @
$taglist) {
2293 git_heads_body
($taglist, $head);
2298 sub git_blob_plain
{
2299 if (!defined $hash) {
2300 if (defined $file_name) {
2301 my $base = $hash_base || git_get_head_hash
($project);
2302 $hash = git_get_hash_by_path
($base, $file_name, "blob")
2303 or die_error
(undef, "Error lookup file");
2305 die_error
(undef, "No file name defined");
2309 open my $fd, "-|", $GIT, "cat-file", "blob", $hash
2310 or die_error
(undef, "Couldn't cat $file_name, $hash");
2312 $type ||= blob_mimetype
($fd, $file_name);
2314 # save as filename, even when no $file_name is given
2315 my $save_as = "$hash";
2316 if (defined $file_name) {
2317 $save_as = $file_name;
2318 } elsif ($type =~ m/^text\//) {
2322 print $cgi->header(-type
=> "$type",
2323 -content_disposition
=> "inline; filename=\"$save_as\"");
2325 binmode STDOUT
, ':raw';
2327 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
2333 if (!defined $hash) {
2334 if (defined $file_name) {
2335 my $base = $hash_base || git_get_head_hash
($project);
2336 $hash = git_get_hash_by_path
($base, $file_name, "blob")
2337 or die_error
(undef, "Error lookup file");
2339 die_error
(undef, "No file name defined");
2342 my $have_blame = gitweb_check_feature
('blame');
2343 open my $fd, "-|", $GIT, "cat-file", "blob", $hash
2344 or die_error
(undef, "Couldn't cat $file_name, $hash");
2345 my $mimetype = blob_mimetype
($fd, $file_name);
2346 if ($mimetype !~ m/^text\//) {
2348 return git_blob_plain
($mimetype);
2351 my $formats_nav = '';
2352 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
2353 if (defined $file_name) {
2356 $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash_base,
2357 hash
=>$hash, file_name
=>$file_name)},
2362 $cgi->a({-href
=> href
(action
=>"blob_plain",
2363 hash
=>$hash, file_name
=>$file_name)},
2366 $cgi->a({-href
=> href
(action
=>"blob",
2367 hash_base
=>"HEAD", file_name
=>$file_name)},
2371 $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$hash)}, "plain");
2373 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2374 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2376 print "<div class=\"page_nav\">\n" .
2377 "<br/><br/></div>\n" .
2378 "<div class=\"title\">$hash</div>\n";
2380 git_print_page_path
($file_name, "blob", $hash_base);
2381 print "<div class=\"page_body\">\n";
2383 while (my $line = <$fd>) {
2386 $line = untabify
($line);
2387 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
2388 $nr, $nr, $nr, esc_html
($line);
2391 or print "Reading blob failed.\n";
2397 if (!defined $hash) {
2398 $hash = git_get_head_hash
($project);
2399 if (defined $file_name) {
2400 my $base = $hash_base || $hash;
2401 $hash = git_get_hash_by_path
($base, $file_name, "tree");
2403 if (!defined $hash_base) {
2408 open my $fd, "-|", $GIT, "ls-tree", '-z', $hash
2409 or die_error
(undef, "Open git-ls-tree failed");
2410 my @entries = map { chomp; $_ } <$fd>;
2411 close $fd or die_error
(undef, "Reading tree failed");
2414 my $refs = git_get_references
();
2415 my $ref = format_ref_marker
($refs, $hash_base);
2419 my $have_blame = gitweb_check_feature
('blame');
2420 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
2421 $base_key{hash_base
} = $hash_base;
2422 git_print_page_nav
('tree','', $hash_base);
2423 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash_base);
2425 print "<div class=\"page_nav\">\n";
2426 print "<br/><br/></div>\n";
2427 print "<div class=\"title\">$hash</div>\n";
2429 if (defined $file_name) {
2430 $base = esc_html
("$file_name/");
2432 git_print_page_path
($file_name, 'tree', $hash_base);
2433 print "<div class=\"page_body\">\n";
2434 print "<table cellspacing=\"0\">\n";
2436 foreach my $line (@entries) {
2437 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
2438 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
2442 my $t_name = validate_input
($4);
2444 print "<tr class=\"dark\">\n";
2446 print "<tr class=\"light\">\n";
2449 print "<td class=\"mode\">" . mode_str
($t_mode) . "</td>\n";
2450 if ($t_type eq "blob") {
2451 print "<td class=\"list\">" .
2452 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key),
2453 -class => "list"}, esc_html
($t_name)) .
2455 "<td class=\"link\">" .
2456 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2460 $cgi->a({-href
=> href
(action
=>"blame", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2464 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2465 hash
=>$t_hash, file_name
=>"$base$t_name")},
2468 $cgi->a({-href
=> href
(action
=>"blob_plain",
2469 hash
=>$t_hash, file_name
=>"$base$t_name")},
2472 } elsif ($t_type eq "tree") {
2473 print "<td class=\"list\">" .
2474 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2475 esc_html
($t_name)) .
2477 "<td class=\"link\">" .
2478 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t_hash, file_name
=>"$base$t_name", %base_key)},
2481 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base, file_name
=>"$base$t_name")},
2487 print "</table>\n" .
2494 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
2495 my $have_snapshot = (defined $ctype && defined $suffix);
2496 if (!$have_snapshot) {
2497 die_error
('403 Permission denied', "Permission denied");
2500 if (!defined $hash) {
2501 $hash = git_get_head_hash
($project);
2504 my $filename = basename
($project) . "-$hash.tar.$suffix";
2506 print $cgi->header(-type
=> 'application/x-tar',
2507 -content_encoding
=> $ctype,
2508 -content_disposition
=> "inline; filename=\"$filename\"",
2509 -status
=> '200 OK');
2511 open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | $command" or
2512 die_error
(undef, "Execute git-tar-tree failed.");
2513 binmode STDOUT
, ':raw';
2515 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
2521 my $head = git_get_head_hash
($project);
2522 if (!defined $hash) {
2525 if (!defined $page) {
2528 my $refs = git_get_references
();
2530 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2531 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
2532 or die_error
(undef, "Open git-rev-list failed");
2533 my @revlist = map { chomp; $_ } <$fd>;
2536 my $paging_nav = format_paging_nav
('log', $hash, $head, $page, $#revlist);
2539 git_print_page_nav
('log','', $hash,undef,undef, $paging_nav);
2542 my %co = parse_commit
($hash);
2544 git_print_header_div
('summary', $project);
2545 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
2547 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
2548 my $commit = $revlist[$i];
2549 my $ref = format_ref_marker
($refs, $commit);
2550 my %co = parse_commit
($commit);
2552 my %ad = parse_date
($co{'author_epoch'});
2553 git_print_header_div
('commit',
2554 "<span class=\"age\">$co{'age_string'}</span>" .
2555 esc_html
($co{'title'}) . $ref,
2557 print "<div class=\"title_text\">\n" .
2558 "<div class=\"log_link\">\n" .
2559 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") .
2561 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") .
2564 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
2567 print "<div class=\"log_body\">\n";
2568 git_print_simplified_log
($co{'comment'});
2575 my %co = parse_commit
($hash);
2577 die_error
(undef, "Unknown commit object");
2579 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
2580 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
2582 my $parent = $co{'parent'};
2583 if (!defined $parent) {
2586 open my $fd, "-|", $GIT, "diff-tree", '-r', '-M', $parent, $hash
2587 or die_error
(undef, "Open git-diff-tree failed");
2588 my @difftree = map { chomp; $_ } <$fd>;
2589 close $fd or die_error
(undef, "Reading git-diff-tree failed");
2591 # non-textual hash id's can be cached
2593 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2596 my $refs = git_get_references
();
2597 my $ref = format_ref_marker
($refs, $co{'id'});
2599 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
2600 my $have_snapshot = (defined $ctype && defined $suffix);
2602 my $formats_nav = '';
2603 if (defined $file_name && defined $co{'parent'}) {
2604 my $parent = $co{'parent'};
2606 $cgi->a({-href
=> href
(action
=>"blame", hash_parent
=>$parent, file_name
=>$file_name)},
2609 git_header_html
(undef, $expires);
2610 git_print_page_nav
('commit', defined $co{'parent'} ?
'' : 'commitdiff',
2611 $hash, $co{'tree'}, $hash,
2614 if (defined $co{'parent'}) {
2615 git_print_header_div
('commitdiff', esc_html
($co{'title'}) . $ref, $hash);
2617 git_print_header_div
('tree', esc_html
($co{'title'}) . $ref, $co{'tree'}, $hash);
2619 print "<div class=\"title_text\">\n" .
2620 "<table cellspacing=\"0\">\n";
2621 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
2623 "<td></td><td> $ad{'rfc2822'}";
2624 if ($ad{'hour_local'} < 6) {
2625 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
2626 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2628 printf(" (%02d:%02d %s)",
2629 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2633 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
2634 print "<tr><td></td><td> $cd{'rfc2822'}" .
2635 sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
2637 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
2640 "<td class=\"sha1\">" .
2641 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash),
2642 class => "list"}, $co{'tree'}) .
2644 "<td class=\"link\">" .
2645 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash)},
2647 if ($have_snapshot) {
2649 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)}, "snapshot");
2653 my $parents = $co{'parents'};
2654 foreach my $par (@
$parents) {
2657 "<td class=\"sha1\">" .
2658 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par),
2659 class => "list"}, $par) .
2661 "<td class=\"link\">" .
2662 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par)}, "commit") .
2664 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$hash, hash_parent
=>$par)}, "commitdiff") .
2671 print "<div class=\"page_body\">\n";
2672 git_print_log
($co{'comment'});
2675 git_difftree_body
(\
@difftree, $hash, $parent);
2681 mkdir($git_temp, 0700);
2683 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
2685 $cgi->a({-href
=> href
(action
=>"blobdiff_plain",
2686 hash
=>$hash, hash_parent
=>$hash_parent)},
2688 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2689 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2692 <div class="page_nav"><br/><br/></div>
2693 <div class="title">$hash vs $hash_parent</div>
2696 git_print_page_path
($file_name, "blob", $hash_base);
2697 print "<div class=\"page_body\">\n" .
2698 "<div class=\"diff_info\">blob:" .
2699 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash_parent,
2700 hash_base
=>$hash_base, file_name
=>($file_parent || $file_name))},
2703 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash,
2704 hash_base
=>$hash_base, file_name
=>$file_name)},
2707 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
2708 print "</div>"; # page_body
2712 sub git_blobdiff_plain
{
2713 mkdir($git_temp, 0700);
2714 print $cgi->header(-type
=> "text/plain", -charset
=> 'utf-8');
2715 git_diff_print
($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
2718 sub git_commitdiff
{
2719 my $format = shift || 'html';
2720 my %co = parse_commit
($hash);
2722 die_error
(undef, "Unknown commit object");
2724 if (!defined $hash_parent) {
2725 $hash_parent = $co{'parent'} || '--root';
2732 if ($format eq 'html') {
2733 open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C',
2734 "--patch-with-raw", "--full-index", $hash_parent, $hash
2735 or die_error
(undef, "Open git-diff-tree failed");
2737 while (chomp(my $line = <$fd>)) {
2738 # empty line ends raw part of diff-tree output
2740 push @difftree, $line;
2742 @patchset = map { chomp; $_ } <$fd>;
2745 or die_error
(undef, "Reading git-diff-tree failed");
2746 } elsif ($format eq 'plain') {
2747 open $fd, "-|", $GIT, "diff-tree", '-r', '-p', '-B', $hash_parent, $hash
2748 or die_error
(undef, "Open git-diff-tree failed");
2750 die_error
(undef, "Unknown commitdiff format");
2753 # non-textual hash id's can be cached
2755 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2759 # write commit message
2760 if ($format eq 'html') {
2761 my $refs = git_get_references
();
2762 my $ref = format_ref_marker
($refs, $co{'id'});
2764 $cgi->a({-href
=> href
(action
=>"commitdiff_plain",
2765 hash
=>$hash, hash_parent
=>$hash_parent)},
2768 git_header_html
(undef, $expires);
2769 git_print_page_nav
('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
2770 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash);
2771 print "<div class=\"page_body\">\n";
2772 print "<div class=\"log\">\n";
2773 git_print_simplified_log
($co{'comment'}, 1); # skip title
2774 print "</div>\n"; # class="log"
2776 } elsif ($format eq 'plain') {
2777 my $refs = git_get_references
("tags");
2779 if (exists $refs->{$hash}) {
2780 @tagnames = map { s
|^tags
/|| } $refs->{$hash};
2782 my $filename = basename
($project) . "-$hash.patch";
2785 -type
=> 'text/plain',
2786 -charset
=> 'utf-8',
2787 -expires
=> $expires,
2788 -content_disposition
=> qq(inline
; filename
="$filename"));
2789 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
2792 Date: $ad{'rfc2822'} ($ad{'tz_local'})
2793 Subject: $co{'title'}
2795 foreach my $tag (@tagnames) {
2796 print "X-Git-Tag: $tag\n";
2798 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
2799 foreach my $line (@
{$co{'comment'}}) {
2806 if ($format eq 'html') {
2807 #git_difftree_body(\@difftree, $hash, $hash_parent);
2810 git_patchset_body
(\
@patchset, \
@difftree, $hash, $hash_parent);
2812 print "</div>\n"; # class="page_body"
2815 } elsif ($format eq 'plain') {
2819 or print "Reading git-diff-tree failed\n";
2823 sub git_commitdiff_plain
{
2824 git_commitdiff
('plain');
2828 if (!defined $hash_base) {
2829 $hash_base = git_get_head_hash
($project);
2832 my %co = parse_commit
($hash_base);
2834 die_error
(undef, "Unknown commit object");
2836 my $refs = git_get_references
();
2838 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base);
2839 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
2840 if (!defined $hash && defined $file_name) {
2841 $hash = git_get_hash_by_path
($hash_base, $file_name);
2843 if (defined $hash) {
2844 $ftype = git_get_type
($hash);
2846 git_print_page_path
($file_name, $ftype, $hash_base);
2849 $GIT, "rev-list", "--full-history", $hash_base, "--", $file_name;
2850 git_history_body
($fd, $refs, $hash_base, $ftype);
2857 if (!defined $searchtext) {
2858 die_error
(undef, "Text field empty");
2860 if (!defined $hash) {
2861 $hash = git_get_head_hash
($project);
2863 my %co = parse_commit
($hash);
2865 die_error
(undef, "Unknown commit object");
2867 # pickaxe may take all resources of your box and run for several minutes
2868 # with every query - so decide by yourself how public you make this feature :)
2869 my $commit_search = 1;
2870 my $author_search = 0;
2871 my $committer_search = 0;
2872 my $pickaxe_search = 0;
2873 if ($searchtext =~ s/^author\\://i) {
2875 } elsif ($searchtext =~ s/^committer\\://i) {
2876 $committer_search = 1;
2877 } elsif ($searchtext =~ s/^pickaxe\\://i) {
2879 $pickaxe_search = 1;
2882 git_print_page_nav
('','', $hash,$co{'tree'},$hash);
2883 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
2885 print "<table cellspacing=\"0\">\n";
2887 if ($commit_search) {
2889 open my $fd, "-|", $GIT, "rev-list", "--header", "--parents", $hash or next;
2890 while (my $commit_text = <$fd>) {
2891 if (!grep m/$searchtext/i, $commit_text) {
2894 if ($author_search && !grep m/\nauthor .*$searchtext/i, $commit_text) {
2897 if ($committer_search && !grep m/\ncommitter .*$searchtext/i, $commit_text) {
2900 my @commit_lines = split "\n", $commit_text;
2901 my %co = parse_commit
(undef, \
@commit_lines);
2906 print "<tr class=\"dark\">\n";
2908 print "<tr class=\"light\">\n";
2911 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2912 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2914 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}), -class => "list subject"},
2915 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
2916 my $comment = $co{'comment'};
2917 foreach my $line (@
$comment) {
2918 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2919 my $lead = esc_html
($1) || "";
2920 $lead = chop_str
($lead, 30, 10);
2921 my $match = esc_html
($2) || "";
2922 my $trail = esc_html
($3) || "";
2923 $trail = chop_str
($trail, 30, 10);
2924 my $text = "$lead<span class=\"match\">$match</span>$trail";
2925 print chop_str
($text, 80, 5) . "<br/>\n";
2929 "<td class=\"link\">" .
2930 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
2932 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
2939 if ($pickaxe_search) {
2941 open my $fd, "-|", "$GIT rev-list $hash | $GIT diff-tree -r --stdin -S\'$searchtext\'";
2944 while (my $line = <$fd>) {
2945 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
2948 $set{'from_id'} = $3;
2950 $set{'id'} = $set{'to_id'};
2951 if ($set{'id'} =~ m/0{40}/) {
2952 $set{'id'} = $set{'from_id'};
2954 if ($set{'id'} =~ m/0{40}/) {
2958 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
2961 print "<tr class=\"dark\">\n";
2963 print "<tr class=\"light\">\n";
2966 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2967 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2969 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}),
2970 -class => "list subject"},
2971 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
2972 while (my $setref = shift @files) {
2974 print $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$co{'id'},
2975 hash
=>$set{'id'}, file_name
=>$set{'file'}),
2977 "<span class=\"match\">" . esc_html
($set{'file'}) . "</span>") .
2981 "<td class=\"link\">" .
2982 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
2984 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
2988 %co = parse_commit
($1);
2998 my $head = git_get_head_hash
($project);
2999 if (!defined $hash) {
3002 if (!defined $page) {
3005 my $refs = git_get_references
();
3007 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
3008 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
3009 or die_error
(undef, "Open git-rev-list failed");
3010 my @revlist = map { chomp; $_ } <$fd>;
3013 my $paging_nav = format_paging_nav
('shortlog', $hash, $head, $page, $#revlist);
3015 if ($#revlist >= (100 * ($page+1)-1)) {
3017 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$hash, page
=>$page+1),
3018 -title
=> "Alt-n"}, "next");
3023 git_print_page_nav
('shortlog','', $hash,$hash,$hash, $paging_nav);
3024 git_print_header_div
('summary', $project);
3026 git_shortlog_body
(\
@revlist, ($page * 100), $#revlist, $refs, $next_link);
3031 ## ......................................................................
3032 ## feeds (RSS, OPML)
3035 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
3036 open my $fd, "-|", $GIT, "rev-list", "--max-count=150", git_get_head_hash
($project)
3037 or die_error
(undef, "Open git-rev-list failed");
3038 my @revlist = map { chomp; $_ } <$fd>;
3039 close $fd or die_error
(undef, "Reading git-rev-list failed");
3040 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
3042 <?xml version="1.0" encoding="utf-8"?>
3043 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
3045 <title>$project $my_uri $my_url</title>
3046 <link>${\esc_html("$my_url?p=$project;a=summary")}</link>
3047 <description>$project log</description>
3048 <language>en</language>
3051 for (my $i = 0; $i <= $#revlist; $i++) {
3052 my $commit = $revlist[$i];
3053 my %co = parse_commit
($commit);
3054 # we read 150, we always show 30 and the ones more recent than 48 hours
3055 if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) {
3058 my %cd = parse_date
($co{'committer_epoch'});
3059 open $fd, "-|", $GIT, "diff-tree", '-r', $co{'parent'}, $co{'id'} or next;
3060 my @difftree = map { chomp; $_ } <$fd>;
3064 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html
($co{'title'}) .
3066 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
3067 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
3068 "<guid isPermaLink=\"true\">" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</guid>\n" .
3069 "<link>" . esc_html
("$my_url?p=$project;a=commit;h=$commit") . "</link>\n" .
3070 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
3071 "<content:encoded>" .
3073 my $comment = $co{'comment'};
3074 foreach my $line (@
$comment) {
3075 $line = decode
("utf8", $line, Encode
::FB_DEFAULT
);
3076 print "$line<br/>\n";
3079 foreach my $line (@difftree) {
3080 if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
3083 my $file = validate_input
(unquote
($7));
3084 $file = decode
("utf8", $file, Encode
::FB_DEFAULT
);
3085 print "$file<br/>\n";
3088 "</content:encoded>\n" .
3091 print "</channel></rss>";
3095 my @list = git_get_projects_list
();
3097 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
3099 <?xml version="1.0" encoding="utf-8"?>
3100 <opml version="1.0">
3102 <title>$site_name Git OPML Export</title>
3105 <outline text="git RSS feeds">
3108 foreach my $pr (@list) {
3110 my $head = git_get_head_hash
($proj{'path'});
3111 if (!defined $head) {
3114 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
3115 my %co = parse_commit
($head);
3120 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
3121 my $rss = "$my_url?p=$proj{'path'};a=rss";
3122 my $html = "$my_url?p=$proj{'path'};a=summary";
3123 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";