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 CGI-
>compile() if $ENV{'MOD_PERL'};
26 our $version = "++GIT_VERSION++";
27 our $my_url = $cgi->url();
28 our $my_uri = $cgi->url(-absolute
=> 1);
30 # core git executable to use
31 # this can just be "git" if your webserver has a sensible PATH
32 our $GIT = "++GIT_BINDIR++/git";
34 # absolute fs-path which will be prepended to the project path
35 #our $projectroot = "/pub/scm";
36 our $projectroot = "++GITWEB_PROJECTROOT++";
38 # target of the home link on top of all pages
39 our $home_link = $my_uri || "/";
41 # string of the home link on top of all pages
42 our $home_link_str = "++GITWEB_HOME_LINK_STR++";
44 # name of your site or organization to appear in page titles
45 # replace this with something more descriptive for clearer bookmarks
46 our $site_name = "++GITWEB_SITENAME++"
47 || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
49 # filename of html text to include at top of each page
50 our $site_header = "++GITWEB_SITE_HEADER++";
51 # html text to include at home page
52 our $home_text = "++GITWEB_HOMETEXT++";
53 # filename of html text to include at bottom of each page
54 our $site_footer = "++GITWEB_SITE_FOOTER++";
57 our @stylesheets = ("++GITWEB_CSS++");
58 # URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
59 our $stylesheet = undef;
61 # URI of GIT logo (72x27 size)
62 our $logo = "++GITWEB_LOGO++";
63 # URI of GIT favicon, assumed to be image/png type
64 our $favicon = "++GITWEB_FAVICON++";
66 # URI and label (title) of GIT logo link
67 #our $logo_url = "http://www.kernel.org/pub/software/scm/git/docs/";
68 #our $logo_label = "git documentation";
69 our $logo_url = "http://git.or.cz/";
70 our $logo_label = "git homepage";
72 # source of projects list
73 our $projects_list = "++GITWEB_LIST++";
75 # the width (in characters) of the projects list "Description" column
76 our $projects_list_description_width = 25;
78 # default order of projects list
79 # valid values are none, project, descr, owner, and age
80 our $default_projects_order = "project";
82 # show repository only if this file exists
83 # (only effective if this variable evaluates to true)
84 our $export_ok = "++GITWEB_EXPORT_OK++";
86 # only allow viewing of repositories also shown on the overview page
87 our $strict_export = "++GITWEB_STRICT_EXPORT++";
89 # list of git base URLs used for URL to where fetch project from,
90 # i.e. full URL is "$git_base_url/$project"
91 our @git_base_url_list = grep { $_ ne '' } ("++GITWEB_BASE_URL++");
93 # default blob_plain mimetype and default charset for text/plain blob
94 our $default_blob_plain_mimetype = 'text/plain';
95 our $default_text_plain_charset = undef;
97 # file to use for guessing MIME types before trying /etc/mime.types
98 # (relative to the current git repository)
99 our $mimetypes_file = undef;
101 # assume this charset if line contains non-UTF-8 characters;
102 # it should be valid encoding (see Encoding::Supported(3pm) for list),
103 # for which encoding all byte sequences are valid, for example
104 # 'iso-8859-1' aka 'latin1' (it is decoded without checking, so it
105 # could be even 'utf-8' for the old behavior)
106 our $fallback_encoding = 'latin1';
108 # You define site-wide feature defaults here; override them with
109 # $GITWEB_CONFIG as necessary.
112 # 'sub' => feature-sub (subroutine),
113 # 'override' => allow-override (boolean),
114 # 'default' => [ default options...] (array reference)}
116 # if feature is overridable (it means that allow-override has true value),
117 # then feature-sub will be called with default options as parameters;
118 # return value of feature-sub indicates if to enable specified feature
120 # if there is no 'sub' key (no feature-sub), then feature cannot be
123 # use gitweb_check_feature(<feature>) to check if <feature> is enabled
125 # Enable the 'blame' blob view, showing the last commit that modified
126 # each line in the file. This can be very CPU-intensive.
128 # To enable system wide have in $GITWEB_CONFIG
129 # $feature{'blame'}{'default'} = [1];
130 # To have project specific config enable override in $GITWEB_CONFIG
131 # $feature{'blame'}{'override'} = 1;
132 # and in project config gitweb.blame = 0|1;
134 'sub' => \
&feature_blame
,
138 # Enable the 'snapshot' link, providing a compressed tarball of any
139 # tree. This can potentially generate high traffic if you have large
142 # To disable system wide have in $GITWEB_CONFIG
143 # $feature{'snapshot'}{'default'} = [undef];
144 # To have project specific config enable override in $GITWEB_CONFIG
145 # $feature{'snapshot'}{'override'} = 1;
146 # and in project config gitweb.snapshot = none|gzip|bzip2|zip;
148 'sub' => \
&feature_snapshot
,
150 # => [content-encoding, suffix, program]
151 'default' => ['x-gzip', 'gz', 'gzip']},
153 # Enable text search, which will list the commits which match author,
154 # committer or commit text to a given string. Enabled by default.
155 # Project specific override is not supported.
160 # Enable grep search, which will list the files in currently selected
161 # tree containing the given string. Enabled by default. This can be
162 # potentially CPU-intensive, of course.
164 # To enable system wide have in $GITWEB_CONFIG
165 # $feature{'grep'}{'default'} = [1];
166 # To have project specific config enable override in $GITWEB_CONFIG
167 # $feature{'grep'}{'override'} = 1;
168 # and in project config gitweb.grep = 0|1;
173 # Enable the pickaxe search, which will list the commits that modified
174 # a given string in a file. This can be practical and quite faster
175 # alternative to 'blame', but still potentially CPU-intensive.
177 # To enable system wide have in $GITWEB_CONFIG
178 # $feature{'pickaxe'}{'default'} = [1];
179 # To have project specific config enable override in $GITWEB_CONFIG
180 # $feature{'pickaxe'}{'override'} = 1;
181 # and in project config gitweb.pickaxe = 0|1;
183 'sub' => \
&feature_pickaxe
,
187 # Make gitweb use an alternative format of the URLs which can be
188 # more readable and natural-looking: project name is embedded
189 # directly in the path and the query string contains other
190 # auxiliary information. All gitweb installations recognize
191 # URL in either format; this configures in which formats gitweb
194 # To enable system wide have in $GITWEB_CONFIG
195 # $feature{'pathinfo'}{'default'} = [1];
196 # Project specific override is not supported.
198 # Note that you will need to change the default location of CSS,
199 # favicon, logo and possibly other files to an absolute URL. Also,
200 # if gitweb.cgi serves as your indexfile, you will need to force
201 # $my_uri to contain the script name in your $GITWEB_CONFIG.
206 # Make gitweb consider projects in project root subdirectories
207 # to be forks of existing projects. Given project $projname.git,
208 # projects matching $projname/*.git will not be shown in the main
209 # projects list, instead a '+' mark will be added to $projname
210 # there and a 'forks' view will be enabled for the project, listing
211 # all the forks. If project list is taken from a file, forks have
212 # to be listed after the main project.
214 # To enable system wide have in $GITWEB_CONFIG
215 # $feature{'forks'}{'default'} = [1];
216 # Project specific override is not supported.
222 sub gitweb_check_feature
{
224 return unless exists $feature{$name};
225 my ($sub, $override, @defaults) = (
226 $feature{$name}{'sub'},
227 $feature{$name}{'override'},
228 @{$feature{$name}{'default'}});
229 if (!$override) { return @defaults; }
231 warn "feature $name is not overrideable";
234 return $sub->(@defaults);
238 my ($val) = git_get_project_config
('blame', '--bool');
240 if ($val eq 'true') {
242 } elsif ($val eq 'false') {
249 sub feature_snapshot
{
250 my ($ctype, $suffix, $command) = @_;
252 my ($val) = git_get_project_config
('snapshot');
254 if ($val eq 'gzip') {
255 return ('x-gzip', 'gz', 'gzip');
256 } elsif ($val eq 'bzip2') {
257 return ('x-bzip2', 'bz2', 'bzip2');
258 } elsif ($val eq 'zip') {
259 return ('x-zip', 'zip', '');
260 } elsif ($val eq 'none') {
264 return ($ctype, $suffix, $command);
267 sub gitweb_have_snapshot
{
268 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
269 my $have_snapshot = (defined $ctype && defined $suffix);
271 return $have_snapshot;
275 my ($val) = git_get_project_config
('grep', '--bool');
277 if ($val eq 'true') {
279 } elsif ($val eq 'false') {
286 sub feature_pickaxe
{
287 my ($val) = git_get_project_config
('pickaxe', '--bool');
289 if ($val eq 'true') {
291 } elsif ($val eq 'false') {
298 # checking HEAD file with -e is fragile if the repository was
299 # initialized long time ago (i.e. symlink HEAD) and was pack-ref'ed
301 sub check_head_link
{
303 my $headfile = "$dir/HEAD";
304 return ((-e
$headfile) ||
305 (-l
$headfile && readlink($headfile) =~ /^refs\/heads\
//));
308 sub check_export_ok
{
310 return (check_head_link
($dir) &&
311 (!$export_ok || -e
"$dir/$export_ok"));
314 # rename detection options for git-diff and git-diff-tree
315 # - default is '-M', with the cost proportional to
316 # (number of removed files) * (number of new files).
317 # - more costly is '-C' (or '-C', '-M'), with the cost proportional to
318 # (number of changed files + number of removed files) * (number of new files)
319 # - even more costly is '-C', '--find-copies-harder' with cost
320 # (number of files in the original tree) * (number of new files)
321 # - one might want to include '-B' option, e.g. '-B', '-M'
322 our @diff_opts = ('-M'); # taken from git_commit
324 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
325 do $GITWEB_CONFIG if -e
$GITWEB_CONFIG;
327 # version of the core git binary
328 our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
330 $projects_list ||= $projectroot;
332 # ======================================================================
333 # input validation and dispatch
334 our $action = $cgi->param('a');
335 if (defined $action) {
336 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
337 die_error
(undef, "Invalid action parameter");
341 # parameters which are pathnames
342 our $project = $cgi->param('p');
343 if (defined $project) {
344 if (!validate_pathname
($project) ||
345 !(-d
"$projectroot/$project") ||
346 !check_head_link
("$projectroot/$project") ||
347 ($export_ok && !(-e
"$projectroot/$project/$export_ok")) ||
348 ($strict_export && !project_in_list
($project))) {
350 die_error
(undef, "No such project");
354 our $file_name = $cgi->param('f');
355 if (defined $file_name) {
356 if (!validate_pathname
($file_name)) {
357 die_error
(undef, "Invalid file parameter");
361 our $file_parent = $cgi->param('fp');
362 if (defined $file_parent) {
363 if (!validate_pathname
($file_parent)) {
364 die_error
(undef, "Invalid file parent parameter");
368 # parameters which are refnames
369 our $hash = $cgi->param('h');
371 if (!validate_refname
($hash)) {
372 die_error
(undef, "Invalid hash parameter");
376 our $hash_parent = $cgi->param('hp');
377 if (defined $hash_parent) {
378 if (!validate_refname
($hash_parent)) {
379 die_error
(undef, "Invalid hash parent parameter");
383 our $hash_base = $cgi->param('hb');
384 if (defined $hash_base) {
385 if (!validate_refname
($hash_base)) {
386 die_error
(undef, "Invalid hash base parameter");
390 our $hash_parent_base = $cgi->param('hpb');
391 if (defined $hash_parent_base) {
392 if (!validate_refname
($hash_parent_base)) {
393 die_error
(undef, "Invalid hash parent base parameter");
398 our $page = $cgi->param('pg');
400 if ($page =~ m/[^0-9]/) {
401 die_error
(undef, "Invalid page parameter");
405 our $searchtype = $cgi->param('st');
406 if (defined $searchtype) {
407 if ($searchtype =~ m/[^a-z]/) {
408 die_error
(undef, "Invalid searchtype parameter");
412 our $searchtext = $cgi->param('s');
414 if (defined $searchtext) {
415 if ($searchtype ne 'grep' and $searchtype ne 'pickaxe' and $searchtext =~ m/[^a-zA-Z0-9_\.\/\
-\
+\
:\
@ ]/) {
416 die_error
(undef, "Invalid search parameter");
418 if (length($searchtext) < 2) {
419 die_error
(undef, "At least two characters are required for search parameter");
421 $search_regexp = quotemeta $searchtext;
424 # now read PATH_INFO and use it as alternative to parameters
425 sub evaluate_path_info
{
426 return if defined $project;
427 my $path_info = $ENV{"PATH_INFO"};
428 return if !$path_info;
429 $path_info =~ s
,^/+,,;
430 return if !$path_info;
431 # find which part of PATH_INFO is project
432 $project = $path_info;
434 while ($project && !check_head_link
("$projectroot/$project")) {
435 $project =~ s
,/*[^/]*$,,;
438 $project = validate_pathname
($project);
440 ($export_ok && !-e
"$projectroot/$project/$export_ok") ||
441 ($strict_export && !project_in_list
($project))) {
445 # do not change any parameters if an action is given using the query string
447 $path_info =~ s
,^$project/*,,;
448 my ($refname, $pathname) = split(/:/, $path_info, 2);
449 if (defined $pathname) {
450 # we got "project.git/branch:filename" or "project.git/branch:dir/"
451 # we could use git_get_type(branch:pathname), but it needs $git_dir
452 $pathname =~ s
,^/+,,;
453 if (!$pathname || substr($pathname, -1) eq "/") {
457 $action ||= "blob_plain";
459 $hash_base ||= validate_refname
($refname);
460 $file_name ||= validate_pathname
($pathname);
461 } elsif (defined $refname) {
462 # we got "project.git/branch"
463 $action ||= "shortlog";
464 $hash ||= validate_refname
($refname);
467 evaluate_path_info
();
469 # path to the current git repository
471 $git_dir = "$projectroot/$project" if $project;
475 "blame" => \
&git_blame2
,
476 "blobdiff" => \
&git_blobdiff
,
477 "blobdiff_plain" => \
&git_blobdiff_plain
,
478 "blob" => \
&git_blob
,
479 "blob_plain" => \
&git_blob_plain
,
480 "commitdiff" => \
&git_commitdiff
,
481 "commitdiff_plain" => \
&git_commitdiff_plain
,
482 "commit" => \
&git_commit
,
483 "forks" => \
&git_forks
,
484 "heads" => \
&git_heads
,
485 "history" => \
&git_history
,
488 "atom" => \
&git_atom
,
489 "search" => \
&git_search
,
490 "search_help" => \
&git_search_help
,
491 "shortlog" => \
&git_shortlog
,
492 "summary" => \
&git_summary
,
494 "tags" => \
&git_tags
,
495 "tree" => \
&git_tree
,
496 "snapshot" => \
&git_snapshot
,
497 "object" => \
&git_object
,
498 # those below don't need $project
499 "opml" => \
&git_opml
,
500 "project_list" => \
&git_project_list
,
501 "project_index" => \
&git_project_index
,
504 if (!defined $action) {
506 $action = git_get_type
($hash);
507 } elsif (defined $hash_base && defined $file_name) {
508 $action = git_get_type
("$hash_base:$file_name");
509 } elsif (defined $project) {
512 $action = 'project_list';
515 if (!defined($actions{$action})) {
516 die_error
(undef, "Unknown action");
518 if ($action !~ m/^(opml|project_list|project_index)$/ &&
520 die_error
(undef, "Project needed");
522 $actions{$action}->();
525 ## ======================================================================
530 # default is to use -absolute url() i.e. $my_uri
531 my $href = $params{-full
} ? $my_url : $my_uri;
533 # XXX: Warning: If you touch this, check the search form for updating,
544 hash_parent_base
=> "hpb",
550 my %mapping = @mapping;
552 $params{'project'} = $project unless exists $params{'project'};
554 my ($use_pathinfo) = gitweb_check_feature
('pathinfo');
556 # use PATH_INFO for project name
557 $href .= "/$params{'project'}" if defined $params{'project'};
558 delete $params{'project'};
560 # Summary just uses the project path URL
561 if (defined $params{'action'} && $params{'action'} eq 'summary') {
562 delete $params{'action'};
566 # now encode the parameters explicitly
568 for (my $i = 0; $i < @mapping; $i += 2) {
569 my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
570 if (defined $params{$name}) {
571 push @result, $symbol . "=" . esc_param
($params{$name});
574 $href .= "?" . join(';', @result) if scalar @result;
580 ## ======================================================================
581 ## validation, quoting/unquoting and escaping
583 sub validate_pathname
{
584 my $input = shift || return undef;
586 # no '.' or '..' as elements of path, i.e. no '.' nor '..'
587 # at the beginning, at the end, and between slashes.
588 # also this catches doubled slashes
589 if ($input =~ m!(^|/)(|\.|\.\.)(/|$)!) {
593 if ($input =~ m!\0!) {
599 sub validate_refname
{
600 my $input = shift || return undef;
602 # textual hashes are O.K.
603 if ($input =~ m/^[0-9a-fA-F]{40}$/) {
606 # it must be correct pathname
607 $input = validate_pathname
($input)
609 # restrictions on ref name according to git-check-ref-format
610 if ($input =~ m!(/\.|\.\.|[\000-\040\177 ~^:?*\[]|/$)!) {
616 # decode sequences of octets in utf8 into Perl's internal form,
617 # which is utf-8 with utf8 flag set if needed. gitweb writes out
618 # in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
622 eval { $res = decode_utf8
($str, Encode
::FB_CROAK
); };
626 return decode
($fallback_encoding, $str, Encode
::FB_DEFAULT
);
630 # quote unsafe chars, but keep the slash, even when it's not
631 # correct, but quoted slashes look too horrible in bookmarks
634 $str =~ s/([^A-Za-z0-9\-_.~()\/:@])/sprintf
("%%%02X", ord($1))/eg
;
640 # quote unsafe chars in whole URL, so some charactrs cannot be quoted
643 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
649 # replace invalid utf8 character with SUBSTITUTION sequence
654 $str = to_utf8
($str);
655 $str = $cgi->escapeHTML($str);
656 if ($opts{'-nbsp'}) {
657 $str =~ s/ / /g;
659 $str =~ s
|([[:cntrl
:]])|(($1 ne "\t") ? quot_cec
($1) : $1)|eg
;
663 # quote control characters and escape filename to HTML
668 $str = to_utf8
($str);
669 $str = $cgi->escapeHTML($str);
670 if ($opts{'-nbsp'}) {
671 $str =~ s/ / /g;
673 $str =~ s
|([[:cntrl
:]])|quot_cec
($1)|eg
;
677 # Make control characters "printable", using character escape codes (CEC)
680 my %es = ( # character escape codes, aka escape sequences
681 "\t" => '\t', # tab (HT)
682 "\n" => '\n', # line feed (LF)
683 "\r" => '\r', # carrige return (CR)
684 "\f" => '\f', # form feed (FF)
685 "\b" => '\b', # backspace (BS)
686 "\a" => '\a', # alarm (bell) (BEL)
687 "\e" => '\e', # escape (ESC)
688 "\013" => '\v', # vertical tab (VT)
689 "\000" => '\0', # nul character (NUL)
691 my $chr = ( (exists $es{$cntrl})
693 : sprintf('\%03o', ord($cntrl)) );
694 return "<span class=\"cntrl\">$chr</span>";
697 # Alternatively use unicode control pictures codepoints,
698 # Unicode "printable representation" (PR)
701 my $chr = sprintf('&#%04d;', 0x2400+ord($cntrl));
702 return "<span class=\"cntrl\">$chr</span>";
705 # git may return quoted and escaped filenames
711 my %es = ( # character escape codes, aka escape sequences
712 't' => "\t", # tab (HT, TAB)
713 'n' => "\n", # newline (NL)
714 'r' => "\r", # return (CR)
715 'f' => "\f", # form feed (FF)
716 'b' => "\b", # backspace (BS)
717 'a' => "\a", # alarm (bell) (BEL)
718 'e' => "\e", # escape (ESC)
719 'v' => "\013", # vertical tab (VT)
722 if ($seq =~ m/^[0-7]{1,3}$/) {
723 # octal char sequence
724 return chr(oct($seq));
725 } elsif (exists $es{$seq}) {
726 # C escape sequence, aka character escape code
729 # quoted ordinary character
733 if ($str =~ m/^"(.*)"$/) {
736 $str =~ s/\\([^0-7]|[0-7]{1,3})/unq($1)/eg;
741 # escape tabs (convert tabs to spaces)
745 while ((my $pos = index($line, "\t")) != -1) {
746 if (my $count = (8 - ($pos % 8))) {
747 my $spaces = ' ' x
$count;
748 $line =~ s/\t/$spaces/;
755 sub project_in_list
{
757 my @list = git_get_projects_list
();
758 return @list && scalar(grep { $_->{'path'} eq $project } @list);
761 ## ----------------------------------------------------------------------
762 ## HTML aware string manipulation
767 my $add_len = shift || 10;
769 # allow only $len chars, but don't cut a word if it would fit in $add_len
770 # if it doesn't fit, cut it if it's still longer than the dots we would add
771 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@]{0,$add_len})(.*)/;
774 if (length($tail) > 4) {
776 $body =~ s/&[^;]*$//; # remove chopped character entities
781 ## ----------------------------------------------------------------------
782 ## functions returning short strings
784 # CSS class for given age value (in seconds)
790 } elsif ($age < 60*60*2) {
792 } elsif ($age < 60*60*24*2) {
799 # convert age in seconds to "nn units ago" string
804 if ($age > 60*60*24*365*2) {
805 $age_str = (int $age/60/60/24/365);
806 $age_str .= " years ago";
807 } elsif ($age > 60*60*24*(365/12)*2) {
808 $age_str = int $age/60/60/24/(365/12);
809 $age_str .= " months ago";
810 } elsif ($age > 60*60*24*7*2) {
811 $age_str = int $age/60/60/24/7;
812 $age_str .= " weeks ago";
813 } elsif ($age > 60*60*24*2) {
814 $age_str = int $age/60/60/24;
815 $age_str .= " days ago";
816 } elsif ($age > 60*60*2) {
817 $age_str = int $age/60/60;
818 $age_str .= " hours ago";
819 } elsif ($age > 60*2) {
820 $age_str = int $age/60;
821 $age_str .= " min ago";
824 $age_str .= " sec ago";
826 $age_str .= " right now";
831 # convert file mode in octal to symbolic file mode string
833 my $mode = oct shift;
835 if (S_ISDIR
($mode & S_IFMT
)) {
837 } elsif (S_ISLNK
($mode)) {
839 } elsif (S_ISREG
($mode)) {
840 # git cares only about the executable bit
841 if ($mode & S_IXUSR
) {
851 # convert file mode in octal to file type string
855 if ($mode !~ m/^[0-7]+$/) {
861 if (S_ISDIR
($mode & S_IFMT
)) {
863 } elsif (S_ISLNK
($mode)) {
865 } elsif (S_ISREG
($mode)) {
872 # convert file mode in octal to file type description string
876 if ($mode !~ m/^[0-7]+$/) {
882 if (S_ISDIR
($mode & S_IFMT
)) {
884 } elsif (S_ISLNK
($mode)) {
886 } elsif (S_ISREG
($mode)) {
887 if ($mode & S_IXUSR
) {
898 ## ----------------------------------------------------------------------
899 ## functions returning short HTML fragments, or transforming HTML fragments
900 ## which don't belong to other sections
902 # format line of commit message.
903 sub format_log_line_html
{
906 $line = esc_html
($line, -nbsp
=>1);
907 if ($line =~ m/([0-9a-fA-F]{8,40})/) {
910 $cgi->a({-href
=> href
(action
=>"object", hash
=>$hash_text),
911 -class => "text"}, $hash_text);
912 $line =~ s/$hash_text/$link/;
917 # format marker of refs pointing to given object
918 sub format_ref_marker
{
919 my ($refs, $id) = @_;
922 if (defined $refs->{$id}) {
923 foreach my $ref (@{$refs->{$id}}) {
924 my ($type, $name) = qw();
925 # e.g. tags/v2.6.11 or heads/next
926 if ($ref =~ m!^(.*?)s?/(.*)$!) {
934 $markers .= " <span class=\"$type\" title=\"$ref\">" .
935 esc_html
($name) . "</span>";
940 return ' <span class="refs">'. $markers . '</span>';
946 # format, perhaps shortened and with markers, title line
947 sub format_subject_html
{
948 my ($long, $short, $href, $extra) = @_;
949 $extra = '' unless defined($extra);
951 if (length($short) < length($long)) {
952 return $cgi->a({-href
=> $href, -class => "list subject",
953 -title
=> to_utf8
($long)},
954 esc_html
($short) . $extra);
956 return $cgi->a({-href
=> $href, -class => "list subject"},
957 esc_html
($long) . $extra);
961 # format git diff header line, i.e. "diff --(git|combined|cc) ..."
962 sub format_git_diff_header_line
{
964 my $diffinfo = shift;
965 my ($from, $to) = @_;
967 if ($diffinfo->{'nparents'}) {
969 $line =~ s!^(diff (.*?) )"?.*$!$1!;
971 $line .= $cgi->a({-href
=> $to->{'href'}, -class => "path"},
972 esc_path
($to->{'file'}));
973 } else { # file was deleted (no href)
974 $line .= esc_path
($to->{'file'});
978 $line =~ s!^(diff (.*?) )"?a/.*$!$1!;
979 if ($from->{'href'}) {
980 $line .= $cgi->a({-href
=> $from->{'href'}, -class => "path"},
981 'a/' . esc_path
($from->{'file'}));
982 } else { # file was added (no href)
983 $line .= 'a/' . esc_path
($from->{'file'});
987 $line .= $cgi->a({-href
=> $to->{'href'}, -class => "path"},
988 'b/' . esc_path
($to->{'file'}));
989 } else { # file was deleted
990 $line .= 'b/' . esc_path
($to->{'file'});
994 return "<div class=\"diff header\">$line</div>\n";
997 # format extended diff header line, before patch itself
998 sub format_extended_diff_header_line
{
1000 my $diffinfo = shift;
1001 my ($from, $to) = @_;
1004 if ($line =~ s!^((copy|rename) from ).*$!$1! && $from->{'href'}) {
1005 $line .= $cgi->a({-href
=>$from->{'href'}, -class=>"path"},
1006 esc_path
($from->{'file'}));
1008 if ($line =~ s!^((copy|rename) to ).*$!$1! && $to->{'href'}) {
1009 $line .= $cgi->a({-href
=>$to->{'href'}, -class=>"path"},
1010 esc_path
($to->{'file'}));
1012 # match single <mode>
1013 if ($line =~ m/\s(\d{6})$/) {
1014 $line .= '<span class="info"> (' .
1015 file_type_long
($1) .
1019 if ($line =~ m/^index [0-9a-fA-F]{40},[0-9a-fA-F]{40}/) {
1020 # can match only for combined diff
1022 for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
1023 if ($from->{'href'}[$i]) {
1024 $line .= $cgi->a({-href
=>$from->{'href'}[$i],
1026 substr($diffinfo->{'from_id'}[$i],0,7));
1031 $line .= ',' if ($i < $diffinfo->{'nparents'} - 1);
1034 if ($to->{'href'}) {
1035 $line .= $cgi->a({-href
=>$to->{'href'}, -class=>"hash"},
1036 substr($diffinfo->{'to_id'},0,7));
1041 } elsif ($line =~ m/^index [0-9a-fA-F]{40}..[0-9a-fA-F]{40}/) {
1042 # can match only for ordinary diff
1043 my ($from_link, $to_link);
1044 if ($from->{'href'}) {
1045 $from_link = $cgi->a({-href
=>$from->{'href'}, -class=>"hash"},
1046 substr($diffinfo->{'from_id'},0,7));
1048 $from_link = '0' x
7;
1050 if ($to->{'href'}) {
1051 $to_link = $cgi->a({-href
=>$to->{'href'}, -class=>"hash"},
1052 substr($diffinfo->{'to_id'},0,7));
1056 my ($from_id, $to_id) = ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});
1057 $line =~ s!$from_id\.\.$to_id!$from_link..$to_link!;
1060 return $line . "<br/>\n";
1063 # format from-file/to-file diff header
1064 sub format_diff_from_to_header
{
1065 my ($from_line, $to_line, $diffinfo, $from, $to, @parents) = @_;
1070 #assert($line =~ m/^---/) if DEBUG;
1071 # no extra formatting for "^--- /dev/null"
1072 if (! $diffinfo->{'nparents'}) {
1073 # ordinary (single parent) diff
1074 if ($line =~ m!^--- "?a/!) {
1075 if ($from->{'href'}) {
1077 $cgi->a({-href
=>$from->{'href'}, -class=>"path"},
1078 esc_path
($from->{'file'}));
1081 esc_path
($from->{'file'});
1084 $result .= qq
!<div
class="diff from_file">$line</div
>\n!;
1087 # combined diff (merge commit)
1088 for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
1089 if ($from->{'href'}[$i]) {
1091 $cgi->a({-href
=>href
(action
=>"blobdiff",
1092 hash_parent
=>$diffinfo->{'from_id'}[$i],
1093 hash_parent_base
=>$parents[$i],
1094 file_parent
=>$from->{'file'}[$i],
1095 hash
=>$diffinfo->{'to_id'},
1097 file_name
=>$to->{'file'}),
1099 -title
=>"diff" . ($i+1)},
1102 $cgi->a({-href
=>$from->{'href'}[$i], -class=>"path"},
1103 esc_path
($from->{'file'}[$i]));
1105 $line = '--- /dev/null';
1107 $result .= qq
!<div
class="diff from_file">$line</div
>\n!;
1112 #assert($line =~ m/^\+\+\+/) if DEBUG;
1113 # no extra formatting for "^+++ /dev/null"
1114 if ($line =~ m!^\+\+\+ "?b/!) {
1115 if ($to->{'href'}) {
1117 $cgi->a({-href
=>$to->{'href'}, -class=>"path"},
1118 esc_path
($to->{'file'}));
1121 esc_path
($to->{'file'});
1124 $result .= qq
!<div
class="diff to_file">$line</div
>\n!;
1129 # create note for patch simplified by combined diff
1130 sub format_diff_cc_simplified
{
1131 my ($diffinfo, @parents) = @_;
1134 $result .= "<div class=\"diff header\">" .
1136 if (!is_deleted
($diffinfo)) {
1137 $result .= $cgi->a({-href
=> href
(action
=>"blob",
1139 hash
=>$diffinfo->{'to_id'},
1140 file_name
=>$diffinfo->{'to_file'}),
1142 esc_path
($diffinfo->{'to_file'}));
1144 $result .= esc_path
($diffinfo->{'to_file'});
1146 $result .= "</div>\n" . # class="diff header"
1147 "<div class=\"diff nodifferences\">" .
1149 "</div>\n"; # class="diff nodifferences"
1154 # format patch (diff) line (not to be used for diff headers)
1155 sub format_diff_line
{
1157 my ($from, $to) = @_;
1158 my $diff_class = "";
1162 if ($from && $to && ref($from->{'href'}) eq "ARRAY") {
1164 my $prefix = substr($line, 0, scalar @{$from->{'href'}});
1165 if ($line =~ m/^\@{3}/) {
1166 $diff_class = " chunk_header";
1167 } elsif ($line =~ m/^\\/) {
1168 $diff_class = " incomplete";
1169 } elsif ($prefix =~ tr/+/+/) {
1170 $diff_class = " add";
1171 } elsif ($prefix =~ tr/-/-/) {
1172 $diff_class = " rem";
1175 # assume ordinary diff
1176 my $char = substr($line, 0, 1);
1178 $diff_class = " add";
1179 } elsif ($char eq '-') {
1180 $diff_class = " rem";
1181 } elsif ($char eq '@') {
1182 $diff_class = " chunk_header";
1183 } elsif ($char eq "\\") {
1184 $diff_class = " incomplete";
1187 $line = untabify
($line);
1188 if ($from && $to && $line =~ m/^\@{2} /) {
1189 my ($from_text, $from_start, $from_lines, $to_text, $to_start, $to_lines, $section) =
1190 $line =~ m/^\@{2} (-(\d+)(?:,(\d+))?) (\+(\d+)(?:,(\d+))?) \@{2}(.*)$/;
1192 $from_lines = 0 unless defined $from_lines;
1193 $to_lines = 0 unless defined $to_lines;
1195 if ($from->{'href'}) {
1196 $from_text = $cgi->a({-href
=>"$from->{'href'}#l$from_start",
1197 -class=>"list"}, $from_text);
1199 if ($to->{'href'}) {
1200 $to_text = $cgi->a({-href
=>"$to->{'href'}#l$to_start",
1201 -class=>"list"}, $to_text);
1203 $line = "<span class=\"chunk_info\">@@ $from_text $to_text @@</span>" .
1204 "<span class=\"section\">" . esc_html
($section, -nbsp
=>1) . "</span>";
1205 return "<div class=\"diff$diff_class\">$line</div>\n";
1206 } elsif ($from && $to && $line =~ m/^\@{3}/) {
1207 my ($prefix, $ranges, $section) = $line =~ m/^(\@+) (.*?) \@+(.*)$/;
1208 my (@from_text, @from_start, @from_nlines, $to_text, $to_start, $to_nlines);
1210 @from_text = split(' ', $ranges);
1211 for (my $i = 0; $i < @from_text; ++$i) {
1212 ($from_start[$i], $from_nlines[$i]) =
1213 (split(',', substr($from_text[$i], 1)), 0);
1216 $to_text = pop @from_text;
1217 $to_start = pop @from_start;
1218 $to_nlines = pop @from_nlines;
1220 $line = "<span class=\"chunk_info\">$prefix ";
1221 for (my $i = 0; $i < @from_text; ++$i) {
1222 if ($from->{'href'}[$i]) {
1223 $line .= $cgi->a({-href
=>"$from->{'href'}[$i]#l$from_start[$i]",
1224 -class=>"list"}, $from_text[$i]);
1226 $line .= $from_text[$i];
1230 if ($to->{'href'}) {
1231 $line .= $cgi->a({-href
=>"$to->{'href'}#l$to_start",
1232 -class=>"list"}, $to_text);
1236 $line .= " $prefix</span>" .
1237 "<span class=\"section\">" . esc_html
($section, -nbsp
=>1) . "</span>";
1238 return "<div class=\"diff$diff_class\">$line</div>\n";
1240 return "<div class=\"diff$diff_class\">" . esc_html
($line, -nbsp
=>1) . "</div>\n";
1243 ## ----------------------------------------------------------------------
1244 ## git utility subroutines, invoking git commands
1246 # returns path to the core git executable and the --git-dir parameter as list
1248 return $GIT, '--git-dir='.$git_dir;
1251 # returns path to the core git executable and the --git-dir parameter as string
1253 return join(' ', git_cmd
());
1256 # get HEAD ref of given project as hash
1257 sub git_get_head_hash
{
1258 my $project = shift;
1259 my $o_git_dir = $git_dir;
1261 $git_dir = "$projectroot/$project";
1262 if (open my $fd, "-|", git_cmd
(), "rev-parse", "--verify", "HEAD") {
1265 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
1269 if (defined $o_git_dir) {
1270 $git_dir = $o_git_dir;
1275 # get type of given object
1279 open my $fd, "-|", git_cmd
(), "cat-file", '-t', $hash or return;
1281 close $fd or return;
1286 sub git_get_project_config
{
1287 my ($key, $type) = @_;
1289 return unless ($key);
1290 $key =~ s/^gitweb\.//;
1291 return if ($key =~ m/\W/);
1293 my @x = (git_cmd
(), 'config');
1294 if (defined $type) { push @x, $type; }
1296 push @x, "gitweb.$key";
1302 # get hash of given path at given ref
1303 sub git_get_hash_by_path
{
1305 my $path = shift || return undef;
1310 open my $fd, "-|", git_cmd
(), "ls-tree", $base, "--", $path
1311 or die_error
(undef, "Open git-ls-tree failed");
1313 close $fd or return undef;
1315 if (!defined $line) {
1316 # there is no tree or hash given by $path at $base
1320 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1321 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/;
1322 if (defined $type && $type ne $2) {
1323 # type doesn't match
1329 # get path of entry with given hash at given tree-ish (ref)
1330 # used to get 'from' filename for combined diff (merge commit) for renames
1331 sub git_get_path_by_hash
{
1332 my $base = shift || return;
1333 my $hash = shift || return;
1337 open my $fd, "-|", git_cmd
(), "ls-tree", '-r', '-t', '-z', $base
1339 while (my $line = <$fd>) {
1342 #'040000 tree 595596a6a9117ddba9fe379b6b012b558bac8423 gitweb'
1343 #'100644 blob e02e90f0429be0d2a69b76571101f20b8f75530f gitweb/README'
1344 if ($line =~ m/(?:[0-9]+) (?:.+) $hash\t(.+)$/) {
1353 ## ......................................................................
1354 ## git utility functions, directly accessing git repository
1356 sub git_get_project_description
{
1359 open my $fd, "$projectroot/$path/description" or return undef;
1362 if (defined $descr) {
1368 sub git_get_project_url_list
{
1371 open my $fd, "$projectroot/$path/cloneurl" or return;
1372 my @git_project_url_list = map { chomp; $_ } <$fd>;
1375 return wantarray ? @git_project_url_list : \
@git_project_url_list;
1378 sub git_get_projects_list
{
1383 $filter =~ s/\.git$//;
1385 my ($check_forks) = gitweb_check_feature
('forks');
1387 if (-d
$projects_list) {
1388 # search in directory
1389 my $dir = $projects_list . ($filter ? "/$filter" : '');
1390 # remove the trailing "/"
1392 my $pfxlen = length("$dir");
1395 follow_fast
=> 1, # follow symbolic links
1396 dangling_symlinks
=> 0, # ignore dangling symlinks, silently
1398 # skip project-list toplevel, if we get it.
1399 return if (m!^[/.]$!);
1400 # only directories can be git repositories
1401 return unless (-d
$_);
1403 my $subdir = substr($File::Find
::name
, $pfxlen + 1);
1404 # we check related file in $projectroot
1405 if ($check_forks and $subdir =~ m
#/.#) {
1406 $File::Find
::prune
= 1;
1407 } elsif (check_export_ok
("$projectroot/$filter/$subdir")) {
1408 push @list, { path
=> ($filter ? "$filter/" : '') . $subdir };
1409 $File::Find
::prune
= 1;
1414 } elsif (-f
$projects_list) {
1415 # read from file(url-encoded):
1416 # 'git%2Fgit.git Linus+Torvalds'
1417 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
1418 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
1420 open my ($fd), $projects_list or return;
1422 while (my $line = <$fd>) {
1424 my ($path, $owner) = split ' ', $line;
1425 $path = unescape
($path);
1426 $owner = unescape
($owner);
1427 if (!defined $path) {
1430 if ($filter ne '') {
1431 # looking for forks;
1432 my $pfx = substr($path, 0, length($filter));
1433 if ($pfx ne $filter) {
1436 my $sfx = substr($path, length($filter));
1437 if ($sfx !~ /^\/.*\
.git
$/) {
1440 } elsif ($check_forks) {
1442 foreach my $filter (keys %paths) {
1443 # looking for forks;
1444 my $pfx = substr($path, 0, length($filter));
1445 if ($pfx ne $filter) {
1448 my $sfx = substr($path, length($filter));
1449 if ($sfx !~ /^\/.*\
.git
$/) {
1452 # is a fork, don't include it in
1457 if (check_export_ok
("$projectroot/$path")) {
1460 owner
=> to_utf8
($owner),
1463 (my $forks_path = $path) =~ s/\.git$//;
1464 $paths{$forks_path}++;
1472 our $gitweb_project_owner = undef;
1473 sub git_get_project_list_from_file
{
1475 return if (defined $gitweb_project_owner);
1477 $gitweb_project_owner = {};
1478 # read from file (url-encoded):
1479 # 'git%2Fgit.git Linus+Torvalds'
1480 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
1481 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
1482 if (-f
$projects_list) {
1483 open (my $fd , $projects_list);
1484 while (my $line = <$fd>) {
1486 my ($pr, $ow) = split ' ', $line;
1487 $pr = unescape
($pr);
1488 $ow = unescape
($ow);
1489 $gitweb_project_owner->{$pr} = to_utf8
($ow);
1495 sub git_get_project_owner
{
1496 my $project = shift;
1499 return undef unless $project;
1501 if (!defined $gitweb_project_owner) {
1502 git_get_project_list_from_file
();
1505 if (exists $gitweb_project_owner->{$project}) {
1506 $owner = $gitweb_project_owner->{$project};
1508 if (!defined $owner) {
1509 $owner = get_file_owner
("$projectroot/$project");
1515 sub git_get_last_activity
{
1519 $git_dir = "$projectroot/$path";
1520 open($fd, "-|", git_cmd
(), 'for-each-ref',
1521 '--format=%(committer)',
1522 '--sort=-committerdate',
1524 'refs/heads') or return;
1525 my $most_recent = <$fd>;
1526 close $fd or return;
1527 if (defined $most_recent &&
1528 $most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
1530 my $age = time - $timestamp;
1531 return ($age, age_string
($age));
1533 return (undef, undef);
1536 sub git_get_references
{
1537 my $type = shift || "";
1539 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
1540 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
1541 open my $fd, "-|", git_cmd
(), "show-ref", "--dereference",
1542 ($type ? ("--", "refs/$type") : ()) # use -- <pattern> if $type
1545 while (my $line = <$fd>) {
1547 if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)!) {
1548 if (defined $refs{$1}) {
1549 push @{$refs{$1}}, $2;
1555 close $fd or return;
1559 sub git_get_rev_name_tags
{
1560 my $hash = shift || return undef;
1562 open my $fd, "-|", git_cmd
(), "name-rev", "--tags", $hash
1564 my $name_rev = <$fd>;
1567 if ($name_rev =~ m
|^$hash tags
/(.*)$|) {
1570 # catches also '$hash undefined' output
1575 ## ----------------------------------------------------------------------
1576 ## parse to hash functions
1580 my $tz = shift || "-0000";
1583 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
1584 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
1585 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
1586 $date{'hour'} = $hour;
1587 $date{'minute'} = $min;
1588 $date{'mday'} = $mday;
1589 $date{'day'} = $days[$wday];
1590 $date{'month'} = $months[$mon];
1591 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000",
1592 $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
1593 $date{'mday-time'} = sprintf "%d %s %02d:%02d",
1594 $mday, $months[$mon], $hour ,$min;
1595 $date{'iso-8601'} = sprintf "%04d-%02d-%02dT%02d:%02d:%02dZ",
1596 1900+$year, $mon, $mday, $hour ,$min, $sec;
1598 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
1599 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
1600 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
1601 $date{'hour_local'} = $hour;
1602 $date{'minute_local'} = $min;
1603 $date{'tz_local'} = $tz;
1604 $date{'iso-tz'} = sprintf("%04d-%02d-%02d %02d:%02d:%02d %s",
1605 1900+$year, $mon+1, $mday,
1606 $hour, $min, $sec, $tz);
1615 open my $fd, "-|", git_cmd
(), "cat-file", "tag", $tag_id or return;
1616 $tag{'id'} = $tag_id;
1617 while (my $line = <$fd>) {
1619 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
1620 $tag{'object'} = $1;
1621 } elsif ($line =~ m/^type (.+)$/) {
1623 } elsif ($line =~ m/^tag (.+)$/) {
1625 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
1626 $tag{'author'} = $1;
1629 } elsif ($line =~ m/--BEGIN/) {
1630 push @comment, $line;
1632 } elsif ($line eq "") {
1636 push @comment, <$fd>;
1637 $tag{'comment'} = \
@comment;
1638 close $fd or return;
1639 if (!defined $tag{'name'}) {
1645 sub parse_commit_text
{
1646 my ($commit_text, $withparents) = @_;
1647 my @commit_lines = split '\n', $commit_text;
1650 pop @commit_lines; # Remove '\0'
1652 if (! @commit_lines) {
1656 my $header = shift @commit_lines;
1657 if ($header !~ m/^[0-9a-fA-F]{40}/) {
1660 ($co{'id'}, my @parents) = split ' ', $header;
1661 while (my $line = shift @commit_lines) {
1662 last if $line eq "\n";
1663 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
1665 } elsif ((!defined $withparents) && ($line =~ m/^parent ([0-9a-fA-F]{40})$/)) {
1667 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
1669 $co{'author_epoch'} = $2;
1670 $co{'author_tz'} = $3;
1671 if ($co{'author'} =~ m/^([^<]+) <([^>]*)>/) {
1672 $co{'author_name'} = $1;
1673 $co{'author_email'} = $2;
1675 $co{'author_name'} = $co{'author'};
1677 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
1678 $co{'committer'} = $1;
1679 $co{'committer_epoch'} = $2;
1680 $co{'committer_tz'} = $3;
1681 $co{'committer_name'} = $co{'committer'};
1682 if ($co{'committer'} =~ m/^([^<]+) <([^>]*)>/) {
1683 $co{'committer_name'} = $1;
1684 $co{'committer_email'} = $2;
1686 $co{'committer_name'} = $co{'committer'};
1690 if (!defined $co{'tree'}) {
1693 $co{'parents'} = \
@parents;
1694 $co{'parent'} = $parents[0];
1696 foreach my $title (@commit_lines) {
1699 $co{'title'} = chop_str
($title, 80, 5);
1700 # remove leading stuff of merges to make the interesting part visible
1701 if (length($title) > 50) {
1702 $title =~ s/^Automatic //;
1703 $title =~ s/^merge (of|with) /Merge ... /i;
1704 if (length($title) > 50) {
1705 $title =~ s/(http|rsync):\/\///;
1707 if (length($title) > 50) {
1708 $title =~ s/(master|www|rsync)\.//;
1710 if (length($title) > 50) {
1711 $title =~ s/kernel.org:?//;
1713 if (length($title) > 50) {
1714 $title =~ s/\/pub\/scm//;
1717 $co{'title_short'} = chop_str
($title, 50, 5);
1721 if ($co{'title'} eq "") {
1722 $co{'title'} = $co{'title_short'} = '(no commit message)';
1724 # remove added spaces
1725 foreach my $line (@commit_lines) {
1728 $co{'comment'} = \
@commit_lines;
1730 my $age = time - $co{'committer_epoch'};
1732 $co{'age_string'} = age_string
($age);
1733 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
1734 if ($age > 60*60*24*7*2) {
1735 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
1736 $co{'age_string_age'} = $co{'age_string'};
1738 $co{'age_string_date'} = $co{'age_string'};
1739 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
1745 my ($commit_id) = @_;
1750 open my $fd, "-|", git_cmd
(), "rev-list",
1756 or die_error
(undef, "Open git-rev-list failed");
1757 %co = parse_commit_text
(<$fd>, 1);
1764 my ($commit_id, $maxcount, $skip, $arg, $filename) = @_;
1772 open my $fd, "-|", git_cmd
(), "rev-list",
1774 ($arg ? ($arg) : ()),
1775 ("--max-count=" . $maxcount),
1776 ("--skip=" . $skip),
1779 ($filename ? ($filename) : ())
1780 or die_error
(undef, "Open git-rev-list failed");
1781 while (my $line = <$fd>) {
1782 my %co = parse_commit_text
($line);
1787 return wantarray ? @cos : \
@cos;
1790 # parse ref from ref_file, given by ref_id, with given type
1792 my $ref_file = shift;
1794 my $type = shift || git_get_type
($ref_id);
1797 $ref_item{'type'} = $type;
1798 $ref_item{'id'} = $ref_id;
1799 $ref_item{'epoch'} = 0;
1800 $ref_item{'age'} = "unknown";
1801 if ($type eq "tag") {
1802 my %tag = parse_tag
($ref_id);
1803 $ref_item{'comment'} = $tag{'comment'};
1804 if ($tag{'type'} eq "commit") {
1805 my %co = parse_commit
($tag{'object'});
1806 $ref_item{'epoch'} = $co{'committer_epoch'};
1807 $ref_item{'age'} = $co{'age_string'};
1808 } elsif (defined($tag{'epoch'})) {
1809 my $age = time - $tag{'epoch'};
1810 $ref_item{'epoch'} = $tag{'epoch'};
1811 $ref_item{'age'} = age_string
($age);
1813 $ref_item{'reftype'} = $tag{'type'};
1814 $ref_item{'name'} = $tag{'name'};
1815 $ref_item{'refid'} = $tag{'object'};
1816 } elsif ($type eq "commit"){
1817 my %co = parse_commit
($ref_id);
1818 $ref_item{'reftype'} = "commit";
1819 $ref_item{'name'} = $ref_file;
1820 $ref_item{'title'} = $co{'title'};
1821 $ref_item{'refid'} = $ref_id;
1822 $ref_item{'epoch'} = $co{'committer_epoch'};
1823 $ref_item{'age'} = $co{'age_string'};
1825 $ref_item{'reftype'} = $type;
1826 $ref_item{'name'} = $ref_file;
1827 $ref_item{'refid'} = $ref_id;
1833 # parse line of git-diff-tree "raw" output
1834 sub parse_difftree_raw_line
{
1838 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1839 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1840 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
1841 $res{'from_mode'} = $1;
1842 $res{'to_mode'} = $2;
1843 $res{'from_id'} = $3;
1845 $res{'status'} = $5;
1846 $res{'similarity'} = $6;
1847 if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
1848 ($res{'from_file'}, $res{'to_file'}) = map { unquote
($_) } split("\t", $7);
1850 $res{'file'} = unquote
($7);
1853 # '::100755 100755 100755 60e79ca1b01bc8b057abe17ddab484699a7f5fdb 94067cc5f73388f33722d52ae02f44692bc07490 94067cc5f73388f33722d52ae02f44692bc07490 MR git-gui/git-gui.sh'
1854 # combined diff (for merge commit)
1855 elsif ($line =~ s/^(::+)((?:[0-7]{6} )+)((?:[0-9a-fA-F]{40} )+)([a-zA-Z]+)\t(.*)$//) {
1856 $res{'nparents'} = length($1);
1857 $res{'from_mode'} = [ split(' ', $2) ];
1858 $res{'to_mode'} = pop @{$res{'from_mode'}};
1859 $res{'from_id'} = [ split(' ', $3) ];
1860 $res{'to_id'} = pop @{$res{'from_id'}};
1861 $res{'status'} = [ split('', $4) ];
1862 $res{'to_file'} = unquote
($5);
1864 # 'c512b523472485aef4fff9e57b229d9d243c967f'
1865 elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
1866 $res{'commit'} = $1;
1869 return wantarray ? %res : \
%res;
1872 # parse line of git-ls-tree output
1873 sub parse_ls_tree_line
($;%) {
1878 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1879 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/s;
1887 $res{'name'} = unquote
($4);
1890 return wantarray ? %res : \
%res;
1893 # generates _two_ hashes, references to which are passed as 2 and 3 argument
1894 sub parse_from_to_diffinfo
{
1895 my ($diffinfo, $from, $to, @parents) = @_;
1897 if ($diffinfo->{'nparents'}) {
1899 $from->{'file'} = [];
1900 $from->{'href'} = [];
1901 fill_from_file_info
($diffinfo, @parents)
1902 unless exists $diffinfo->{'from_file'};
1903 for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
1904 $from->{'file'}[$i] = $diffinfo->{'from_file'}[$i] || $diffinfo->{'to_file'};
1905 if ($diffinfo->{'status'}[$i] ne "A") { # not new (added) file
1906 $from->{'href'}[$i] = href
(action
=>"blob",
1907 hash_base
=>$parents[$i],
1908 hash
=>$diffinfo->{'from_id'}[$i],
1909 file_name
=>$from->{'file'}[$i]);
1911 $from->{'href'}[$i] = undef;
1915 $from->{'file'} = $diffinfo->{'from_file'} || $diffinfo->{'file'};
1916 if ($diffinfo->{'status'} ne "A") { # not new (added) file
1917 $from->{'href'} = href
(action
=>"blob", hash_base
=>$hash_parent,
1918 hash
=>$diffinfo->{'from_id'},
1919 file_name
=>$from->{'file'});
1921 delete $from->{'href'};
1925 $to->{'file'} = $diffinfo->{'to_file'} || $diffinfo->{'file'};
1926 if (!is_deleted
($diffinfo)) { # file exists in result
1927 $to->{'href'} = href
(action
=>"blob", hash_base
=>$hash,
1928 hash
=>$diffinfo->{'to_id'},
1929 file_name
=>$to->{'file'});
1931 delete $to->{'href'};
1935 ## ......................................................................
1936 ## parse to array of hashes functions
1938 sub git_get_heads_list
{
1942 open my $fd, '-|', git_cmd
(), 'for-each-ref',
1943 ($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
1944 '--format=%(objectname) %(refname) %(subject)%00%(committer)',
1947 while (my $line = <$fd>) {
1951 my ($refinfo, $committerinfo) = split(/\0/, $line);
1952 my ($hash, $name, $title) = split(' ', $refinfo, 3);
1953 my ($committer, $epoch, $tz) =
1954 ($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
1955 $name =~ s!^refs/heads/!!;
1957 $ref_item{'name'} = $name;
1958 $ref_item{'id'} = $hash;
1959 $ref_item{'title'} = $title || '(no commit message)';
1960 $ref_item{'epoch'} = $epoch;
1962 $ref_item{'age'} = age_string
(time - $ref_item{'epoch'});
1964 $ref_item{'age'} = "unknown";
1967 push @headslist, \
%ref_item;
1971 return wantarray ? @headslist : \
@headslist;
1974 sub git_get_tags_list
{
1978 open my $fd, '-|', git_cmd
(), 'for-each-ref',
1979 ($limit ? '--count='.($limit+1) : ()), '--sort=-creatordate',
1980 '--format=%(objectname) %(objecttype) %(refname) '.
1981 '%(*objectname) %(*objecttype) %(subject)%00%(creator)',
1984 while (my $line = <$fd>) {
1988 my ($refinfo, $creatorinfo) = split(/\0/, $line);
1989 my ($id, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);
1990 my ($creator, $epoch, $tz) =
1991 ($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);
1992 $name =~ s!^refs/tags/!!;
1994 $ref_item{'type'} = $type;
1995 $ref_item{'id'} = $id;
1996 $ref_item{'name'} = $name;
1997 if ($type eq "tag") {
1998 $ref_item{'subject'} = $title;
1999 $ref_item{'reftype'} = $reftype;
2000 $ref_item{'refid'} = $refid;
2002 $ref_item{'reftype'} = $type;
2003 $ref_item{'refid'} = $id;
2006 if ($type eq "tag" || $type eq "commit") {
2007 $ref_item{'epoch'} = $epoch;
2009 $ref_item{'age'} = age_string
(time - $ref_item{'epoch'});
2011 $ref_item{'age'} = "unknown";
2015 push @tagslist, \
%ref_item;
2019 return wantarray ? @tagslist : \
@tagslist;
2022 ## ----------------------------------------------------------------------
2023 ## filesystem-related functions
2025 sub get_file_owner
{
2028 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
2029 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
2030 if (!defined $gcos) {
2034 $owner =~ s/[,;].*$//;
2035 return to_utf8
($owner);
2038 ## ......................................................................
2039 ## mimetype related functions
2041 sub mimetype_guess_file
{
2042 my $filename = shift;
2043 my $mimemap = shift;
2044 -r
$mimemap or return undef;
2047 open(MIME
, $mimemap) or return undef;
2049 next if m/^#/; # skip comments
2050 my ($mime, $exts) = split(/\t+/);
2051 if (defined $exts) {
2052 my @exts = split(/\s+/, $exts);
2053 foreach my $ext (@exts) {
2054 $mimemap{$ext} = $mime;
2060 $filename =~ /\.([^.]*)$/;
2061 return $mimemap{$1};
2064 sub mimetype_guess
{
2065 my $filename = shift;
2067 $filename =~ /\./ or return undef;
2069 if ($mimetypes_file) {
2070 my $file = $mimetypes_file;
2071 if ($file !~ m!^/!) { # if it is relative path
2072 # it is relative to project
2073 $file = "$projectroot/$project/$file";
2075 $mime = mimetype_guess_file
($filename, $file);
2077 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
2083 my $filename = shift;
2086 my $mime = mimetype_guess
($filename);
2087 $mime and return $mime;
2091 return $default_blob_plain_mimetype unless $fd;
2094 return 'text/plain' .
2095 ($default_text_plain_charset ? '; charset='.$default_text_plain_charset : '');
2096 } elsif (! $filename) {
2097 return 'application/octet-stream';
2098 } elsif ($filename =~ m/\.png$/i) {
2100 } elsif ($filename =~ m/\.gif$/i) {
2102 } elsif ($filename =~ m/\.jpe?g$/i) {
2103 return 'image/jpeg';
2105 return 'application/octet-stream';
2109 ## ======================================================================
2110 ## functions printing HTML: header, footer, error page
2112 sub git_header_html
{
2113 my $status = shift || "200 OK";
2114 my $expires = shift;
2116 my $title = "$site_name";
2117 if (defined $project) {
2118 $title .= " - " . to_utf8
($project);
2119 if (defined $action) {
2120 $title .= "/$action";
2121 if (defined $file_name) {
2122 $title .= " - " . esc_path
($file_name);
2123 if ($action eq "tree" && $file_name !~ m
|/$|) {
2130 # require explicit support from the UA if we are to send the page as
2131 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
2132 # we have to do this because MSIE sometimes globs '*/*', pretending to
2133 # support xhtml+xml but choking when it gets what it asked for.
2134 if (defined $cgi->http('HTTP_ACCEPT') &&
2135 $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ &&
2136 $cgi->Accept('application/xhtml+xml') != 0) {
2137 $content_type = 'application/xhtml+xml';
2139 $content_type = 'text/html';
2141 print $cgi->header(-type
=>$content_type, -charset
=> 'utf-8',
2142 -status
=> $status, -expires
=> $expires);
2143 my $mod_perl_version = $ENV{'MOD_PERL'} ? " $ENV{'MOD_PERL'}" : '';
2145 <?xml version="1.0" encoding="utf-8"?>
2146 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2147 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
2148 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
2149 <!-- git core binaries version $git_version -->
2151 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
2152 <meta name="generator" content="gitweb/$version git/$git_version$mod_perl_version"/>
2153 <meta name="robots" content="index, nofollow"/>
2154 <title>$title</title>
2156 # print out each stylesheet that exist
2157 if (defined $stylesheet) {
2158 #provides backwards capability for those people who define style sheet in a config file
2159 print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
2161 foreach my $stylesheet (@stylesheets) {
2162 next unless $stylesheet;
2163 print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
2166 if (defined $project) {
2167 printf('<link rel="alternate" title="%s log RSS feed" '.
2168 'href="%s" type="application/rss+xml" />'."\n",
2169 esc_param
($project), href
(action
=>"rss"));
2170 printf('<link rel="alternate" title="%s log Atom feed" '.
2171 'href="%s" type="application/atom+xml" />'."\n",
2172 esc_param
($project), href
(action
=>"atom"));
2174 printf('<link rel="alternate" title="%s projects list" '.
2175 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
2176 $site_name, href
(project
=>undef, action
=>"project_index"));
2177 printf('<link rel="alternate" title="%s projects feeds" '.
2178 'href="%s" type="text/x-opml"/>'."\n",
2179 $site_name, href
(project
=>undef, action
=>"opml"));
2181 if (defined $favicon) {
2182 print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
2188 if (-f
$site_header) {
2189 open (my $fd, $site_header);
2194 print "<div class=\"page_header\">\n" .
2195 $cgi->a({-href
=> esc_url
($logo_url),
2196 -title
=> $logo_label},
2197 qq(<img src="$logo" width="72" height="27" alt="git" class="logo"/>));
2198 print $cgi->a({-href
=> esc_url
($home_link)}, $home_link_str) . " / ";
2199 if (defined $project) {
2200 print $cgi->a({-href
=> href
(action
=>"summary")}, esc_html
($project));
2201 if (defined $action) {
2208 my ($have_search) = gitweb_check_feature
('search');
2209 if ((defined $project) && ($have_search)) {
2210 if (!defined $searchtext) {
2214 if (defined $hash_base) {
2215 $search_hash = $hash_base;
2216 } elsif (defined $hash) {
2217 $search_hash = $hash;
2219 $search_hash = "HEAD";
2221 my $action = $my_uri;
2222 my ($use_pathinfo) = gitweb_check_feature
('pathinfo');
2223 if ($use_pathinfo) {
2224 $action .= "/$project";
2226 $cgi->param("p", $project);
2228 $cgi->param("a", "search");
2229 $cgi->param("h", $search_hash);
2230 print $cgi->startform(-method => "get", -action
=> $action) .
2231 "<div class=\"search\">\n" .
2232 (!$use_pathinfo && $cgi->hidden(-name
=> "p") . "\n") .
2233 $cgi->hidden(-name
=> "a") . "\n" .
2234 $cgi->hidden(-name
=> "h") . "\n" .
2235 $cgi->popup_menu(-name
=> 'st', -default => 'commit',
2236 -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .
2237 $cgi->sup($cgi->a({-href
=> href
(action
=>"search_help")}, "?")) .
2239 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
2241 $cgi->end_form() . "\n";
2245 sub git_footer_html
{
2246 print "<div class=\"page_footer\">\n";
2247 if (defined $project) {
2248 my $descr = git_get_project_description
($project);
2249 if (defined $descr) {
2250 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
2252 print $cgi->a({-href
=> href
(action
=>"rss"),
2253 -class => "rss_logo"}, "RSS") . " ";
2254 print $cgi->a({-href
=> href
(action
=>"atom"),
2255 -class => "rss_logo"}, "Atom") . "\n";
2257 print $cgi->a({-href
=> href
(project
=>undef, action
=>"opml"),
2258 -class => "rss_logo"}, "OPML") . " ";
2259 print $cgi->a({-href
=> href
(project
=>undef, action
=>"project_index"),
2260 -class => "rss_logo"}, "TXT") . "\n";
2264 if (-f
$site_footer) {
2265 open (my $fd, $site_footer);
2275 my $status = shift || "403 Forbidden";
2276 my $error = shift || "Malformed query, file missing or permission denied";
2278 git_header_html
($status);
2280 <div class="page_body">
2290 ## ----------------------------------------------------------------------
2291 ## functions printing or outputting HTML: navigation
2293 sub git_print_page_nav
{
2294 my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
2295 $extra = '' if !defined $extra; # pager or formats
2297 my @navs = qw(summary shortlog log commit commitdiff tree);
2299 @navs = grep { $_ ne $suppress } @navs;
2302 my %arg = map { $_ => {action
=>$_} } @navs;
2303 if (defined $head) {
2304 for (qw(commit commitdiff)) {
2305 $arg{$_}{'hash'} = $head;
2307 if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
2308 for (qw(shortlog log)) {
2309 $arg{$_}{'hash'} = $head;
2313 $arg{'tree'}{'hash'} = $treehead if defined $treehead;
2314 $arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
2316 print "<div class=\"page_nav\">\n" .
2318 map { $_ eq $current ?
2319 $_ : $cgi->a({-href
=> href
(%{$arg{$_}})}, "$_")
2321 print "<br/>\n$extra<br/>\n" .
2325 sub format_paging_nav
{
2326 my ($action, $hash, $head, $page, $nrevs) = @_;
2330 if ($hash ne $head || $page) {
2331 $paging_nav .= $cgi->a({-href
=> href
(action
=>$action)}, "HEAD");
2333 $paging_nav .= "HEAD";
2337 $paging_nav .= " ⋅ " .
2338 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page-1),
2339 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
2341 $paging_nav .= " ⋅ prev";
2344 if ($nrevs >= (100 * ($page+1)-1)) {
2345 $paging_nav .= " ⋅ " .
2346 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page+1),
2347 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
2349 $paging_nav .= " ⋅ next";
2355 ## ......................................................................
2356 ## functions printing or outputting HTML: div
2358 sub git_print_header_div
{
2359 my ($action, $title, $hash, $hash_base) = @_;
2362 $args{'action'} = $action;
2363 $args{'hash'} = $hash if $hash;
2364 $args{'hash_base'} = $hash_base if $hash_base;
2366 print "<div class=\"header\">\n" .
2367 $cgi->a({-href
=> href
(%args), -class => "title"},
2368 $title ? $title : $action) .
2372 #sub git_print_authorship (\%) {
2373 sub git_print_authorship
{
2376 my %ad = parse_date
($co->{'author_epoch'}, $co->{'author_tz'});
2377 print "<div class=\"author_date\">" .
2378 esc_html
($co->{'author_name'}) .
2380 if ($ad{'hour_local'} < 6) {
2381 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
2382 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2384 printf(" (%02d:%02d %s)",
2385 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
2390 sub git_print_page_path
{
2396 print "<div class=\"page_path\">";
2397 print $cgi->a({-href
=> href
(action
=>"tree", hash_base
=>$hb),
2398 -title
=> 'tree root'}, to_utf8
("[$project]"));
2400 if (defined $name) {
2401 my @dirname = split '/', $name;
2402 my $basename = pop @dirname;
2405 foreach my $dir (@dirname) {
2406 $fullname .= ($fullname ? '/' : '') . $dir;
2407 print $cgi->a({-href
=> href
(action
=>"tree", file_name
=>$fullname,
2409 -title
=> $fullname}, esc_path
($dir));
2412 if (defined $type && $type eq 'blob') {
2413 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name,
2415 -title
=> $name}, esc_path
($basename));
2416 } elsif (defined $type && $type eq 'tree') {
2417 print $cgi->a({-href
=> href
(action
=>"tree", file_name
=>$file_name,
2419 -title
=> $name}, esc_path
($basename));
2422 print esc_path
($basename);
2425 print "<br/></div>\n";
2428 # sub git_print_log (\@;%) {
2429 sub git_print_log
($;%) {
2433 if ($opts{'-remove_title'}) {
2434 # remove title, i.e. first line of log
2437 # remove leading empty lines
2438 while (defined $log->[0] && $log->[0] eq "") {
2445 foreach my $line (@$log) {
2446 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2449 if (! $opts{'-remove_signoff'}) {
2450 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
2453 # remove signoff lines
2460 # print only one empty line
2461 # do not print empty line after signoff
2463 next if ($empty || $signoff);
2469 print format_log_line_html
($line) . "<br/>\n";
2472 if ($opts{'-final_empty_line'}) {
2473 # end with single empty line
2474 print "<br/>\n" unless $empty;
2478 # return link target (what link points to)
2479 sub git_get_link_target
{
2484 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
2488 $link_target = <$fd>;
2493 return $link_target;
2496 # given link target, and the directory (basedir) the link is in,
2497 # return target of link relative to top directory (top tree);
2498 # return undef if it is not possible (including absolute links).
2499 sub normalize_link_target
{
2500 my ($link_target, $basedir, $hash_base) = @_;
2502 # we can normalize symlink target only if $hash_base is provided
2503 return unless $hash_base;
2505 # absolute symlinks (beginning with '/') cannot be normalized
2506 return if (substr($link_target, 0, 1) eq '/');
2508 # normalize link target to path from top (root) tree (dir)
2511 $path = $basedir . '/' . $link_target;
2513 # we are in top (root) tree (dir)
2514 $path = $link_target;
2517 # remove //, /./, and /../
2519 foreach my $part (split('/', $path)) {
2520 # discard '.' and ''
2521 next if (!$part || $part eq '.');
2523 if ($part eq '..') {
2527 # link leads outside repository (outside top dir)
2531 push @path_parts, $part;
2534 $path = join('/', @path_parts);
2539 # print tree entry (row of git_tree), but without encompassing <tr> element
2540 sub git_print_tree_entry
{
2541 my ($t, $basedir, $hash_base, $have_blame) = @_;
2544 $base_key{'hash_base'} = $hash_base if defined $hash_base;
2546 # The format of a table row is: mode list link. Where mode is
2547 # the mode of the entry, list is the name of the entry, an href,
2548 # and link is the action links of the entry.
2550 print "<td class=\"mode\">" . mode_str
($t->{'mode'}) . "</td>\n";
2551 if ($t->{'type'} eq "blob") {
2552 print "<td class=\"list\">" .
2553 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t->{'hash'},
2554 file_name
=>"$basedir$t->{'name'}", %base_key),
2555 -class => "list"}, esc_path
($t->{'name'}));
2556 if (S_ISLNK
(oct $t->{'mode'})) {
2557 my $link_target = git_get_link_target
($t->{'hash'});
2559 my $norm_target = normalize_link_target
($link_target, $basedir, $hash_base);
2560 if (defined $norm_target) {
2562 $cgi->a({-href
=> href
(action
=>"object", hash_base
=>$hash_base,
2563 file_name
=>$norm_target),
2564 -title
=> $norm_target}, esc_path
($link_target));
2566 print " -> " . esc_path
($link_target);
2571 print "<td class=\"link\">";
2572 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t->{'hash'},
2573 file_name
=>"$basedir$t->{'name'}", %base_key)},
2577 $cgi->a({-href
=> href
(action
=>"blame", hash
=>$t->{'hash'},
2578 file_name
=>"$basedir$t->{'name'}", %base_key)},
2581 if (defined $hash_base) {
2583 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2584 hash
=>$t->{'hash'}, file_name
=>"$basedir$t->{'name'}")},
2588 $cgi->a({-href
=> href
(action
=>"blob_plain", hash_base
=>$hash_base,
2589 file_name
=>"$basedir$t->{'name'}")},
2593 } elsif ($t->{'type'} eq "tree") {
2594 print "<td class=\"list\">";
2595 print $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t->{'hash'},
2596 file_name
=>"$basedir$t->{'name'}", %base_key)},
2597 esc_path
($t->{'name'}));
2599 print "<td class=\"link\">";
2600 print $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t->{'hash'},
2601 file_name
=>"$basedir$t->{'name'}", %base_key)},
2603 if (defined $hash_base) {
2605 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2606 file_name
=>"$basedir$t->{'name'}")},
2613 ## ......................................................................
2614 ## functions printing large fragments of HTML
2616 sub fill_from_file_info
{
2617 my ($diff, @parents) = @_;
2619 $diff->{'from_file'} = [ ];
2620 $diff->{'from_file'}[$diff->{'nparents'} - 1] = undef;
2621 for (my $i = 0; $i < $diff->{'nparents'}; $i++) {
2622 if ($diff->{'status'}[$i] eq 'R' ||
2623 $diff->{'status'}[$i] eq 'C') {
2624 $diff->{'from_file'}[$i] =
2625 git_get_path_by_hash
($parents[$i], $diff->{'from_id'}[$i]);
2632 # parameters can be strings, or references to arrays of strings
2636 if (ref($a) eq "ARRAY" && ref($b) eq "ARRAY" && @$a == @$b) {
2637 for (my $i = 0; $i < @$a; ++$i) {
2638 return 0 unless ($a->[$i] eq $b->[$i]);
2641 } elsif (!ref($a) && !ref($b)) {
2649 my $diffinfo = shift;
2651 return $diffinfo->{'to_id'} eq ('0' x
40);
2654 sub git_difftree_body
{
2655 my ($difftree, $hash, @parents) = @_;
2656 my ($parent) = $parents[0];
2657 my ($have_blame) = gitweb_check_feature
('blame');
2658 print "<div class=\"list_head\">\n";
2659 if ($#{$difftree} > 10) {
2660 print(($#{$difftree} + 1) . " files changed:\n");
2664 print "<table class=\"" .
2665 (@parents > 1 ? "combined " : "") .
2668 # header only for combined diff in 'commitdiff' view
2669 my $has_header = @parents > 1 && $action eq 'commitdiff';
2672 print "<thead><tr>\n" .
2673 "<th></th><th></th>\n"; # filename, patchN link
2674 for (my $i = 0; $i < @parents; $i++) {
2675 my $par = $parents[$i];
2677 $cgi->a({-href
=> href
(action
=>"commitdiff",
2678 hash
=>$hash, hash_parent
=>$par),
2679 -title
=> 'commitdiff to parent number ' .
2680 ($i+1) . ': ' . substr($par,0,7)},
2684 print "</tr></thead>\n<tbody>\n";
2689 foreach my $line (@{$difftree}) {
2691 if (ref($line) eq "HASH") {
2692 # pre-parsed (or generated by hand)
2695 $diff = parse_difftree_raw_line
($line);
2699 print "<tr class=\"dark\">\n";
2701 print "<tr class=\"light\">\n";
2705 if (exists $diff->{'nparents'}) { # combined diff
2707 fill_from_file_info
($diff, @parents)
2708 unless exists $diff->{'from_file'};
2710 if (!is_deleted
($diff)) {
2711 # file exists in the result (child) commit
2713 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'to_id'},
2714 file_name
=>$diff->{'to_file'},
2716 -class => "list"}, esc_path
($diff->{'to_file'})) .
2720 esc_path
($diff->{'to_file'}) .
2724 if ($action eq 'commitdiff') {
2727 print "<td class=\"link\">" .
2728 $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2733 my $has_history = 0;
2734 my $not_deleted = 0;
2735 for (my $i = 0; $i < $diff->{'nparents'}; $i++) {
2736 my $hash_parent = $parents[$i];
2737 my $from_hash = $diff->{'from_id'}[$i];
2738 my $from_path = $diff->{'from_file'}[$i];
2739 my $status = $diff->{'status'}[$i];
2741 $has_history ||= ($status ne 'A');
2742 $not_deleted ||= ($status ne 'D');
2744 if ($status eq 'A') {
2745 print "<td class=\"link\" align=\"right\"> | </td>\n";
2746 } elsif ($status eq 'D') {
2747 print "<td class=\"link\">" .
2748 $cgi->a({-href
=> href
(action
=>"blob",
2751 file_name
=>$from_path)},
2755 if ($diff->{'to_id'} eq $from_hash) {
2756 print "<td class=\"link nochange\">";
2758 print "<td class=\"link\">";
2760 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2761 hash
=>$diff->{'to_id'},
2762 hash_parent
=>$from_hash,
2764 hash_parent_base
=>$hash_parent,
2765 file_name
=>$diff->{'to_file'},
2766 file_parent
=>$from_path)},
2772 print "<td class=\"link\">";
2774 print $cgi->a({-href
=> href
(action
=>"blob",
2775 hash
=>$diff->{'to_id'},
2776 file_name
=>$diff->{'to_file'},
2779 print " | " if ($has_history);
2782 print $cgi->a({-href
=> href
(action
=>"history",
2783 file_name
=>$diff->{'to_file'},
2790 next; # instead of 'else' clause, to avoid extra indent
2792 # else ordinary diff
2794 my ($to_mode_oct, $to_mode_str, $to_file_type);
2795 my ($from_mode_oct, $from_mode_str, $from_file_type);
2796 if ($diff->{'to_mode'} ne ('0' x
6)) {
2797 $to_mode_oct = oct $diff->{'to_mode'};
2798 if (S_ISREG
($to_mode_oct)) { # only for regular file
2799 $to_mode_str = sprintf("%04o", $to_mode_oct & 0777); # permission bits
2801 $to_file_type = file_type
($diff->{'to_mode'});
2803 if ($diff->{'from_mode'} ne ('0' x
6)) {
2804 $from_mode_oct = oct $diff->{'from_mode'};
2805 if (S_ISREG
($to_mode_oct)) { # only for regular file
2806 $from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
2808 $from_file_type = file_type
($diff->{'from_mode'});
2811 if ($diff->{'status'} eq "A") { # created
2812 my $mode_chng = "<span class=\"file_status new\">[new $to_file_type";
2813 $mode_chng .= " with mode: $to_mode_str" if $to_mode_str;
2814 $mode_chng .= "]</span>";
2816 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'to_id'},
2817 hash_base
=>$hash, file_name
=>$diff->{'file'}),
2818 -class => "list"}, esc_path
($diff->{'file'}));
2820 print "<td>$mode_chng</td>\n";
2821 print "<td class=\"link\">";
2822 if ($action eq 'commitdiff') {
2825 print $cgi->a({-href
=> "#patch$patchno"}, "patch");
2828 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'to_id'},
2829 hash_base
=>$hash, file_name
=>$diff->{'file'})},
2833 } elsif ($diff->{'status'} eq "D") { # deleted
2834 my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
2836 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'from_id'},
2837 hash_base
=>$parent, file_name
=>$diff->{'file'}),
2838 -class => "list"}, esc_path
($diff->{'file'}));
2840 print "<td>$mode_chng</td>\n";
2841 print "<td class=\"link\">";
2842 if ($action eq 'commitdiff') {
2845 print $cgi->a({-href
=> "#patch$patchno"}, "patch");
2848 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'from_id'},
2849 hash_base
=>$parent, file_name
=>$diff->{'file'})},
2852 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$parent,
2853 file_name
=>$diff->{'file'})},
2856 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$parent,
2857 file_name
=>$diff->{'file'})},
2861 } elsif ($diff->{'status'} eq "M" || $diff->{'status'} eq "T") { # modified, or type changed
2862 my $mode_chnge = "";
2863 if ($diff->{'from_mode'} != $diff->{'to_mode'}) {
2864 $mode_chnge = "<span class=\"file_status mode_chnge\">[changed";
2865 if ($from_file_type ne $to_file_type) {
2866 $mode_chnge .= " from $from_file_type to $to_file_type";
2868 if (($from_mode_oct & 0777) != ($to_mode_oct & 0777)) {
2869 if ($from_mode_str && $to_mode_str) {
2870 $mode_chnge .= " mode: $from_mode_str->$to_mode_str";
2871 } elsif ($to_mode_str) {
2872 $mode_chnge .= " mode: $to_mode_str";
2875 $mode_chnge .= "]</span>\n";
2878 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'to_id'},
2879 hash_base
=>$hash, file_name
=>$diff->{'file'}),
2880 -class => "list"}, esc_path
($diff->{'file'}));
2882 print "<td>$mode_chnge</td>\n";
2883 print "<td class=\"link\">";
2884 if ($action eq 'commitdiff') {
2887 print $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2889 } elsif ($diff->{'to_id'} ne $diff->{'from_id'}) {
2890 # "commit" view and modified file (not onlu mode changed)
2891 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2892 hash
=>$diff->{'to_id'}, hash_parent
=>$diff->{'from_id'},
2893 hash_base
=>$hash, hash_parent_base
=>$parent,
2894 file_name
=>$diff->{'file'})},
2898 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'to_id'},
2899 hash_base
=>$hash, file_name
=>$diff->{'file'})},
2902 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash,
2903 file_name
=>$diff->{'file'})},
2906 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash,
2907 file_name
=>$diff->{'file'})},
2911 } elsif ($diff->{'status'} eq "R" || $diff->{'status'} eq "C") { # renamed or copied
2912 my %status_name = ('R' => 'moved', 'C' => 'copied');
2913 my $nstatus = $status_name{$diff->{'status'}};
2915 if ($diff->{'from_mode'} != $diff->{'to_mode'}) {
2916 # mode also for directories, so we cannot use $to_mode_str
2917 $mode_chng = sprintf(", mode: %04o", $to_mode_oct & 0777);
2920 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
2921 hash
=>$diff->{'to_id'}, file_name
=>$diff->{'to_file'}),
2922 -class => "list"}, esc_path
($diff->{'to_file'})) . "</td>\n" .
2923 "<td><span class=\"file_status $nstatus\">[$nstatus from " .
2924 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$parent,
2925 hash
=>$diff->{'from_id'}, file_name
=>$diff->{'from_file'}),
2926 -class => "list"}, esc_path
($diff->{'from_file'})) .
2927 " with " . (int $diff->{'similarity'}) . "% similarity$mode_chng]</span></td>\n" .
2928 "<td class=\"link\">";
2929 if ($action eq 'commitdiff') {
2932 print $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2934 } elsif ($diff->{'to_id'} ne $diff->{'from_id'}) {
2935 # "commit" view and modified file (not only pure rename or copy)
2936 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2937 hash
=>$diff->{'to_id'}, hash_parent
=>$diff->{'from_id'},
2938 hash_base
=>$hash, hash_parent_base
=>$parent,
2939 file_name
=>$diff->{'to_file'}, file_parent
=>$diff->{'from_file'})},
2943 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff->{'to_id'},
2944 hash_base
=>$parent, file_name
=>$diff->{'to_file'})},
2947 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash,
2948 file_name
=>$diff->{'to_file'})},
2951 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash,
2952 file_name
=>$diff->{'to_file'})},
2956 } # we should not encounter Unmerged (U) or Unknown (X) status
2959 print "</tbody>" if $has_header;
2963 sub git_patchset_body
{
2964 my ($fd, $difftree, $hash, @hash_parents) = @_;
2965 my ($hash_parent) = $hash_parents[0];
2968 my $patch_number = 0;
2973 print "<div class=\"patchset\">\n";
2975 # skip to first patch
2976 while ($patch_line = <$fd>) {
2979 last if ($patch_line =~ m/^diff /);
2983 while ($patch_line) {
2985 my ($from_id, $to_id);
2988 #assert($patch_line =~ m/^diff /) if DEBUG;
2989 #assert($patch_line !~ m!$/$!) if DEBUG; # is chomp-ed
2991 push @diff_header, $patch_line;
2993 # extended diff header
2995 while ($patch_line = <$fd>) {
2998 last EXTENDED_HEADER
if ($patch_line =~ m/^--- |^diff /);
3000 if ($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/) {
3003 } elsif ($patch_line =~ m/^index ((?:[0-9a-fA-F]{40},)+[0-9a-fA-F]{40})..([0-9a-fA-F]{40})/) {
3004 $from_id = [ split(',', $1) ];
3008 push @diff_header, $patch_line;
3010 my $last_patch_line = $patch_line;
3012 # check if current patch belong to current raw line
3013 # and parse raw git-diff line if needed
3014 if (defined $diffinfo &&
3015 defined $from_id && defined $to_id &&
3016 from_ids_eq
($diffinfo->{'from_id'}, $from_id) &&
3017 $diffinfo->{'to_id'} eq $to_id) {
3018 # this is continuation of a split patch
3019 print "<div class=\"patch cont\">\n";
3021 # advance raw git-diff output if needed
3022 $patch_idx++ if defined $diffinfo;
3024 # compact combined diff output can have some patches skipped
3025 # find which patch (using pathname of result) we are at now
3027 if ($diff_header[0] =~ m!^diff --cc "?(.*)"?$!) {
3032 # read and prepare patch information
3033 if (ref($difftree->[$patch_idx]) eq "HASH") {
3034 # pre-parsed (or generated by hand)
3035 $diffinfo = $difftree->[$patch_idx];
3037 $diffinfo = parse_difftree_raw_line
($difftree->[$patch_idx]);
3040 # check if current raw line has no patch (it got simplified)
3041 if (defined $to_name && $to_name ne $diffinfo->{'to_file'}) {
3042 print "<div class=\"patch\" id=\"patch". ($patch_idx+1) ."\">\n" .
3043 format_diff_cc_simplified
($diffinfo, @hash_parents) .
3044 "</div>\n"; # class="patch"
3049 } until (!defined $to_name || $to_name eq $diffinfo->{'to_file'} ||
3050 $patch_idx > $#$difftree);
3051 # modifies %from, %to hashes
3052 parse_from_to_diffinfo
($diffinfo, \
%from, \
%to, @hash_parents);
3053 if ($diffinfo->{'nparents'}) {
3057 fill_from_file_info
($diffinfo, @hash_parents)
3058 unless exists $diffinfo->{'from_file'};
3059 for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
3060 $from{'file'}[$i] = $diffinfo->{'from_file'}[$i] || $diffinfo->{'to_file'};
3061 if ($diffinfo->{'status'}[$i] ne "A") { # not new (added) file
3062 $from{'href'}[$i] = href
(action
=>"blob",
3063 hash_base
=>$hash_parents[$i],
3064 hash
=>$diffinfo->{'from_id'}[$i],
3065 file_name
=>$from{'file'}[$i]);
3067 $from{'href'}[$i] = undef;
3071 $from{'file'} = $diffinfo->{'from_file'} || $diffinfo->{'file'};
3072 if ($diffinfo->{'status'} ne "A") { # not new (added) file
3073 $from{'href'} = href
(action
=>"blob", hash_base
=>$hash_parent,
3074 hash
=>$diffinfo->{'from_id'},
3075 file_name
=>$from{'file'});
3077 delete $from{'href'};
3081 $to{'file'} = $diffinfo->{'to_file'} || $diffinfo->{'file'};
3082 if (!is_deleted
($diffinfo)) { # file exists in result
3083 $to{'href'} = href
(action
=>"blob", hash_base
=>$hash,
3084 hash
=>$diffinfo->{'to_id'},
3085 file_name
=>$to{'file'});
3089 # this is first patch for raw difftree line with $patch_idx index
3090 # we index @$difftree array from 0, but number patches from 1
3091 print "<div class=\"patch\" id=\"patch". ($patch_idx+1) ."\">\n";
3094 # print "git diff" header
3095 $patch_line = shift @diff_header;
3096 print format_git_diff_header_line
($patch_line, $diffinfo,
3099 # print extended diff header
3100 print "<div class=\"diff extended_header\">\n" if (@diff_header > 0);
3102 foreach $patch_line (@diff_header) {
3103 print format_extended_diff_header_line
($patch_line, $diffinfo,
3106 print "</div>\n" if (@diff_header > 0); # class="diff extended_header"
3108 # from-file/to-file diff header
3109 $patch_line = $last_patch_line;
3110 if (! $patch_line) {
3111 print "</div>\n"; # class="patch"
3114 next PATCH
if ($patch_line =~ m/^diff /);
3115 #assert($patch_line =~ m/^---/) if DEBUG;
3116 #assert($patch_line eq $last_patch_line) if DEBUG;
3118 $patch_line = <$fd>;
3120 #assert($patch_line =~ m/^\+\+\+/) if DEBUG;
3122 print format_diff_from_to_header
($last_patch_line, $patch_line,
3123 $diffinfo, \
%from, \
%to,
3128 while ($patch_line = <$fd>) {
3131 next PATCH
if ($patch_line =~ m/^diff /);
3133 print format_diff_line
($patch_line, \
%from, \
%to);
3137 print "</div>\n"; # class="patch"
3140 # for compact combined (--cc) format, with chunk and patch simpliciaction
3141 # patchset might be empty, but there might be unprocessed raw lines
3142 for ($patch_idx++ if $patch_number > 0;
3143 $patch_idx < @$difftree;
3145 # read and prepare patch information
3146 if (ref($difftree->[$patch_idx]) eq "HASH") {
3147 # pre-parsed (or generated by hand)
3148 $diffinfo = $difftree->[$patch_idx];
3150 $diffinfo = parse_difftree_raw_line
($difftree->[$patch_idx]);
3153 # generate anchor for "patch" links in difftree / whatchanged part
3154 print "<div class=\"patch\" id=\"patch". ($patch_idx+1) ."\">\n" .
3155 format_diff_cc_simplified
($diffinfo, @hash_parents) .
3156 "</div>\n"; # class="patch"
3161 if ($patch_number == 0) {
3162 if (@hash_parents > 1) {
3163 print "<div class=\"diff nodifferences\">Trivial merge</div>\n";
3165 print "<div class=\"diff nodifferences\">No differences found</div>\n";
3169 print "</div>\n"; # class="patchset"
3172 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3174 sub git_project_list_body
{
3175 my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
3177 my ($check_forks) = gitweb_check_feature
('forks');
3180 foreach my $pr (@$projlist) {
3181 my (@aa) = git_get_last_activity
($pr->{'path'});
3185 ($pr->{'age'}, $pr->{'age_string'}) = @aa;
3186 if (!defined $pr->{'descr'}) {
3187 my $descr = git_get_project_description
($pr->{'path'}) || "";
3188 $pr->{'descr_long'} = to_utf8
($descr);
3189 $pr->{'descr'} = chop_str
($descr, $projects_list_description_width, 5);
3191 if (!defined $pr->{'owner'}) {
3192 $pr->{'owner'} = git_get_project_owner
("$pr->{'path'}") || "";
3195 my $pname = $pr->{'path'};
3196 if (($pname =~ s/\.git$//) &&
3197 ($pname !~ /\/$/) &&
3198 (-d
"$projectroot/$pname")) {
3199 $pr->{'forks'} = "-d $projectroot/$pname";
3205 push @projects, $pr;
3208 $order ||= $default_projects_order;
3209 $from = 0 unless defined $from;
3210 $to = $#projects if (!defined $to || $#projects < $to);
3212 print "<table class=\"project_list\">\n";
3213 unless ($no_header) {
3216 print "<th></th>\n";
3218 if ($order eq "project") {
3219 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
3220 print "<th>Project</th>\n";
3223 $cgi->a({-href
=> href
(project
=>undef, order
=>'project'),
3224 -class => "header"}, "Project") .
3227 if ($order eq "descr") {
3228 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
3229 print "<th>Description</th>\n";
3232 $cgi->a({-href
=> href
(project
=>undef, order
=>'descr'),
3233 -class => "header"}, "Description") .
3236 if ($order eq "owner") {
3237 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
3238 print "<th>Owner</th>\n";
3241 $cgi->a({-href
=> href
(project
=>undef, order
=>'owner'),
3242 -class => "header"}, "Owner") .
3245 if ($order eq "age") {
3246 @projects = sort {$a->{'age'} <=> $b->{'age'}} @projects;
3247 print "<th>Last Change</th>\n";
3250 $cgi->a({-href
=> href
(project
=>undef, order
=>'age'),
3251 -class => "header"}, "Last Change") .
3254 print "<th></th>\n" .
3258 for (my $i = $from; $i <= $to; $i++) {
3259 my $pr = $projects[$i];
3261 print "<tr class=\"dark\">\n";
3263 print "<tr class=\"light\">\n";
3268 if ($pr->{'forks'}) {
3269 print "<!-- $pr->{'forks'} -->\n";
3270 print $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"forks")}, "+");
3274 print "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
3275 -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
3276 "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
3277 -class => "list", -title
=> $pr->{'descr_long'}},
3278 esc_html
($pr->{'descr'})) . "</td>\n" .
3279 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
3280 print "<td class=\"". age_class
($pr->{'age'}) . "\">" .
3281 (defined $pr->{'age_string'} ? $pr->{'age_string'} : "No commits") . "</td>\n" .
3282 "<td class=\"link\">" .
3283 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary")}, "summary") . " | " .
3284 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"shortlog")}, "shortlog") . " | " .
3285 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"log")}, "log") . " | " .
3286 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"tree")}, "tree") .
3287 ($pr->{'forks'} ? " | " . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"forks")}, "forks") : '') .
3291 if (defined $extra) {
3294 print "<td></td>\n";
3296 print "<td colspan=\"5\">$extra</td>\n" .
3302 sub git_shortlog_body
{
3303 # uses global variable $project
3304 my ($commitlist, $from, $to, $refs, $extra) = @_;
3306 my $have_snapshot = gitweb_have_snapshot
();
3308 $from = 0 unless defined $from;
3309 $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
3311 print "<table class=\"shortlog\" cellspacing=\"0\">\n";
3313 for (my $i = $from; $i <= $to; $i++) {
3314 my %co = %{$commitlist->[$i]};
3315 my $commit = $co{'id'};
3316 my $ref = format_ref_marker
($refs, $commit);
3318 print "<tr class=\"dark\">\n";
3320 print "<tr class=\"light\">\n";
3323 # git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
3324 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
3325 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
3327 print format_subject_html
($co{'title'}, $co{'title_short'},
3328 href
(action
=>"commit", hash
=>$commit), $ref);
3330 "<td class=\"link\">" .
3331 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
3332 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") . " | " .
3333 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$commit, hash_base
=>$commit)}, "tree");
3334 if ($have_snapshot) {
3335 print " | " . $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$commit)}, "snapshot");
3340 if (defined $extra) {
3342 "<td colspan=\"4\">$extra</td>\n" .
3348 sub git_history_body
{
3349 # Warning: assumes constant type (blob or tree) during history
3350 my ($commitlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;
3352 $from = 0 unless defined $from;
3353 $to = $#{$commitlist} unless (defined $to && $to <= $#{$commitlist});
3355 print "<table class=\"history\" cellspacing=\"0\">\n";
3357 for (my $i = $from; $i <= $to; $i++) {
3358 my %co = %{$commitlist->[$i]};
3362 my $commit = $co{'id'};
3364 my $ref = format_ref_marker
($refs, $commit);
3367 print "<tr class=\"dark\">\n";
3369 print "<tr class=\"light\">\n";
3372 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
3373 # shortlog uses chop_str($co{'author_name'}, 10)
3374 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
3376 # originally git_history used chop_str($co{'title'}, 50)
3377 print format_subject_html
($co{'title'}, $co{'title_short'},
3378 href
(action
=>"commit", hash
=>$commit), $ref);
3380 "<td class=\"link\">" .
3381 $cgi->a({-href
=> href
(action
=>$ftype, hash_base
=>$commit, file_name
=>$file_name)}, $ftype) . " | " .
3382 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff");
3384 if ($ftype eq 'blob') {
3385 my $blob_current = git_get_hash_by_path
($hash_base, $file_name);
3386 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
3387 if (defined $blob_current && defined $blob_parent &&
3388 $blob_current ne $blob_parent) {
3390 $cgi->a({-href
=> href
(action
=>"blobdiff",
3391 hash
=>$blob_current, hash_parent
=>$blob_parent,
3392 hash_base
=>$hash_base, hash_parent_base
=>$commit,
3393 file_name
=>$file_name)},
3400 if (defined $extra) {
3402 "<td colspan=\"4\">$extra</td>\n" .
3409 # uses global variable $project
3410 my ($taglist, $from, $to, $extra) = @_;
3411 $from = 0 unless defined $from;
3412 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
3414 print "<table class=\"tags\" cellspacing=\"0\">\n";
3416 for (my $i = $from; $i <= $to; $i++) {
3417 my $entry = $taglist->[$i];
3419 my $comment = $tag{'subject'};
3421 if (defined $comment) {
3422 $comment_short = chop_str
($comment, 30, 5);
3425 print "<tr class=\"dark\">\n";
3427 print "<tr class=\"light\">\n";
3430 if (defined $tag{'age'}) {
3431 print "<td><i>$tag{'age'}</i></td>\n";
3433 print "<td></td>\n";
3436 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'}),
3437 -class => "list name"}, esc_html
($tag{'name'})) .
3440 if (defined $comment) {
3441 print format_subject_html
($comment, $comment_short,
3442 href
(action
=>"tag", hash
=>$tag{'id'}));
3445 "<td class=\"selflink\">";
3446 if ($tag{'type'} eq "tag") {
3447 print $cgi->a({-href
=> href
(action
=>"tag", hash
=>$tag{'id'})}, "tag");
3452 "<td class=\"link\">" . " | " .
3453 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'})}, $tag{'reftype'});
3454 if ($tag{'reftype'} eq "commit") {
3455 print " | " . $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") .
3456 " | " . $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'name'})}, "log");
3457 } elsif ($tag{'reftype'} eq "blob") {
3458 print " | " . $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$tag{'refid'})}, "raw");
3463 if (defined $extra) {
3465 "<td colspan=\"5\">$extra</td>\n" .
3471 sub git_heads_body
{
3472 # uses global variable $project
3473 my ($headlist, $head, $from, $to, $extra) = @_;
3474 $from = 0 unless defined $from;
3475 $to = $#{$headlist} if (!defined $to || $#{$headlist} < $to);
3477 print "<table class=\"heads\" cellspacing=\"0\">\n";
3479 for (my $i = $from; $i <= $to; $i++) {
3480 my $entry = $headlist->[$i];
3482 my $curr = $ref{'id'} eq $head;
3484 print "<tr class=\"dark\">\n";
3486 print "<tr class=\"light\">\n";
3489 print "<td><i>$ref{'age'}</i></td>\n" .
3490 ($curr ? "<td class=\"current_head\">" : "<td>") .
3491 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$ref{'name'}),
3492 -class => "list name"},esc_html
($ref{'name'})) .
3494 "<td class=\"link\">" .
3495 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$ref{'name'})}, "shortlog") . " | " .
3496 $cgi->a({-href
=> href
(action
=>"log", hash
=>$ref{'name'})}, "log") . " | " .
3497 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$ref{'name'}, hash_base
=>$ref{'name'})}, "tree") .
3501 if (defined $extra) {
3503 "<td colspan=\"3\">$extra</td>\n" .
3509 sub git_search_grep_body
{
3510 my ($commitlist, $from, $to, $extra) = @_;
3511 $from = 0 unless defined $from;
3512 $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
3514 print "<table class=\"grep\" cellspacing=\"0\">\n";
3516 for (my $i = $from; $i <= $to; $i++) {
3517 my %co = %{$commitlist->[$i]};
3521 my $commit = $co{'id'};
3523 print "<tr class=\"dark\">\n";
3525 print "<tr class=\"light\">\n";
3528 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
3529 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
3531 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}), -class => "list subject"},
3532 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
3533 my $comment = $co{'comment'};
3534 foreach my $line (@$comment) {
3535 if ($line =~ m/^(.*)($search_regexp)(.*)$/i) {
3536 my $lead = esc_html
($1) || "";
3537 $lead = chop_str
($lead, 30, 10);
3538 my $match = esc_html
($2) || "";
3539 my $trail = esc_html
($3) || "";
3540 $trail = chop_str
($trail, 30, 10);
3541 my $text = "$lead<span class=\"match\">$match</span>$trail";
3542 print chop_str
($text, 80, 5) . "<br/>\n";
3546 "<td class=\"link\">" .
3547 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
3549 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
3553 if (defined $extra) {
3555 "<td colspan=\"3\">$extra</td>\n" .
3561 ## ======================================================================
3562 ## ======================================================================
3565 sub git_project_list
{
3566 my $order = $cgi->param('o');
3567 if (defined $order && $order !~ m/none|project|descr|owner|age/) {
3568 die_error
(undef, "Unknown order parameter");
3571 my @list = git_get_projects_list
();
3573 die_error
(undef, "No projects found");
3577 if (-f
$home_text) {
3578 print "<div class=\"index_include\">\n";
3579 open (my $fd, $home_text);
3584 git_project_list_body
(\
@list, $order);
3589 my $order = $cgi->param('o');
3590 if (defined $order && $order !~ m/none|project|descr|owner|age/) {
3591 die_error
(undef, "Unknown order parameter");
3594 my @list = git_get_projects_list
($project);
3596 die_error
(undef, "No forks found");
3600 git_print_page_nav
('','');
3601 git_print_header_div
('summary', "$project forks");
3602 git_project_list_body
(\
@list, $order);
3606 sub git_project_index
{
3607 my @projects = git_get_projects_list
($project);
3610 -type
=> 'text/plain',
3611 -charset
=> 'utf-8',
3612 -content_disposition
=> 'inline; filename="index.aux"');
3614 foreach my $pr (@projects) {
3615 if (!exists $pr->{'owner'}) {
3616 $pr->{'owner'} = git_get_project_owner
("$pr->{'path'}");
3619 my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});
3620 # quote as in CGI::Util::encode, but keep the slash, and use '+' for ' '
3621 $path =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf
("%%%02X", ord($1))/eg
;
3622 $owner =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf
("%%%02X", ord($1))/eg
;
3626 print "$path $owner\n";
3631 my $descr = git_get_project_description
($project) || "none";
3632 my %co = parse_commit
("HEAD");
3633 my %cd = %co ? parse_date
($co{'committer_epoch'}, $co{'committer_tz'}) : ();
3634 my $head = $co{'id'};
3636 my $owner = git_get_project_owner
($project);
3638 my $refs = git_get_references
();
3639 # These get_*_list functions return one more to allow us to see if
3640 # there are more ...
3641 my @taglist = git_get_tags_list
(16);
3642 my @headlist = git_get_heads_list
(16);
3644 my ($check_forks) = gitweb_check_feature
('forks');
3647 @forklist = git_get_projects_list
($project);
3651 git_print_page_nav
('summary','', $head);
3653 print "<div class=\"title\"> </div>\n";
3654 print "<table cellspacing=\"0\">\n" .
3655 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
3656 "<tr><td>owner</td><td>$owner</td></tr>\n";
3657 if (defined $cd{'rfc2822'}) {
3658 print "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
3661 # use per project git URL list in $projectroot/$project/cloneurl
3662 # or make project git URL from git base URL and project name
3663 my $url_tag = "URL";
3664 my @url_list = git_get_project_url_list
($project);
3665 @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
3666 foreach my $git_url (@url_list) {
3667 next unless $git_url;
3668 print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
3673 if (-s
"$projectroot/$project/README.html") {
3674 if (open my $fd, "$projectroot/$project/README.html") {
3675 print "<div class=\"title\">readme</div>\n";
3676 print $_ while (<$fd>);
3681 # we need to request one more than 16 (0..15) to check if
3683 my @commitlist = $head ? parse_commits
($head, 17) : ();
3685 git_print_header_div
('shortlog');
3686 git_shortlog_body
(\
@commitlist, 0, 15, $refs,
3687 $#commitlist <= 15 ? undef :
3688 $cgi->a({-href
=> href
(action
=>"shortlog")}, "..."));
3692 git_print_header_div
('tags');
3693 git_tags_body
(\
@taglist, 0, 15,
3694 $#taglist <= 15 ? undef :
3695 $cgi->a({-href
=> href
(action
=>"tags")}, "..."));
3699 git_print_header_div
('heads');
3700 git_heads_body
(\
@headlist, $head, 0, 15,
3701 $#headlist <= 15 ? undef :
3702 $cgi->a({-href
=> href
(action
=>"heads")}, "..."));
3706 git_print_header_div
('forks');
3707 git_project_list_body
(\
@forklist, undef, 0, 15,
3708 $#forklist <= 15 ? undef :
3709 $cgi->a({-href
=> href
(action
=>"forks")}, "..."),
3717 my $head = git_get_head_hash
($project);
3719 git_print_page_nav
('','', $head,undef,$head);
3720 my %tag = parse_tag
($hash);
3723 die_error
(undef, "Unknown tag object");
3726 git_print_header_div
('commit', esc_html
($tag{'name'}), $hash);
3727 print "<div class=\"title_text\">\n" .
3728 "<table cellspacing=\"0\">\n" .
3730 "<td>object</td>\n" .
3731 "<td>" . $cgi->a({-class => "list", -href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
3732 $tag{'object'}) . "</td>\n" .
3733 "<td class=\"link\">" . $cgi->a({-href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
3734 $tag{'type'}) . "</td>\n" .
3736 if (defined($tag{'author'})) {
3737 my %ad = parse_date
($tag{'epoch'}, $tag{'tz'});
3738 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
3739 print "<tr><td></td><td>" . $ad{'rfc2822'} .
3740 sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) .
3743 print "</table>\n\n" .
3745 print "<div class=\"page_body\">";
3746 my $comment = $tag{'comment'};
3747 foreach my $line (@$comment) {
3749 print esc_html
($line, -nbsp
=>1) . "<br/>\n";
3759 my ($have_blame) = gitweb_check_feature
('blame');
3761 die_error
('403 Permission denied', "Permission denied");
3763 die_error
('404 Not Found', "File name not defined") if (!$file_name);
3764 $hash_base ||= git_get_head_hash
($project);
3765 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
3766 my %co = parse_commit
($hash_base)
3767 or die_error
(undef, "Reading commit failed");
3768 if (!defined $hash) {
3769 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
3770 or die_error
(undef, "Error looking up file");
3772 $ftype = git_get_type
($hash);
3773 if ($ftype !~ "blob") {
3774 die_error
('400 Bad Request', "Object is not a blob");
3776 open ($fd, "-|", git_cmd
(), "blame", '-p', '--',
3777 $file_name, $hash_base)
3778 or die_error
(undef, "Open git-blame failed");
3781 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3784 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3787 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
3789 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3790 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3791 git_print_page_path
($file_name, $ftype, $hash_base);
3792 my @rev_color = (qw(light2 dark2));
3793 my $num_colors = scalar(@rev_color);
3794 my $current_color = 0;
3797 <div class="page_body">
3798 <table class="blame">
3799 <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
3804 last unless defined $_;
3805 my ($full_rev, $orig_lineno, $lineno, $group_size) =
3806 /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/;
3807 if (!exists $metainfo{$full_rev}) {
3808 $metainfo{$full_rev} = {};
3810 my $meta = $metainfo{$full_rev};
3813 if (/^(\S+) (.*)$/) {
3819 my $rev = substr($full_rev, 0, 8);
3820 my $author = $meta->{'author'};
3821 my %date = parse_date
($meta->{'author-time'},
3822 $meta->{'author-tz'});
3823 my $date = $date{'iso-tz'};
3825 $current_color = ++$current_color % $num_colors;
3827 print "<tr class=\"$rev_color[$current_color]\">\n";
3829 print "<td class=\"sha1\"";
3830 print " title=\"". esc_html
($author) . ", $date\"";
3831 print " rowspan=\"$group_size\"" if ($group_size > 1);
3833 print $cgi->a({-href
=> href
(action
=>"commit",
3835 file_name
=>$file_name)},
3839 open (my $dd, "-|", git_cmd
(), "rev-parse", "$full_rev^")
3840 or die_error
(undef, "Open git-rev-parse failed");
3841 my $parent_commit = <$dd>;
3843 chomp($parent_commit);
3844 my $blamed = href
(action
=> 'blame',
3845 file_name
=> $meta->{'filename'},
3846 hash_base
=> $parent_commit);
3847 print "<td class=\"linenr\">";
3848 print $cgi->a({ -href
=> "$blamed#l$orig_lineno",
3850 -class => "linenr" },
3853 print "<td class=\"pre\">" . esc_html
($data) . "</td>\n";
3859 or print "Reading blob failed\n";
3866 my ($have_blame) = gitweb_check_feature
('blame');
3868 die_error
('403 Permission denied', "Permission denied");
3870 die_error
('404 Not Found', "File name not defined") if (!$file_name);
3871 $hash_base ||= git_get_head_hash
($project);
3872 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
3873 my %co = parse_commit
($hash_base)
3874 or die_error
(undef, "Reading commit failed");
3875 if (!defined $hash) {
3876 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
3877 or die_error
(undef, "Error lookup file");
3879 open ($fd, "-|", git_cmd
(), "annotate", '-l', '-t', '-r', $file_name, $hash_base)
3880 or die_error
(undef, "Open git-annotate failed");
3883 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3886 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3889 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
3891 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3892 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3893 git_print_page_path
($file_name, 'blob', $hash_base);
3894 print "<div class=\"page_body\">\n";
3896 <table class="blame">
3905 my @line_class = (qw(light dark));
3906 my $line_class_len = scalar (@line_class);
3907 my $line_class_num = $#line_class;
3908 while (my $line = <$fd>) {
3920 $line_class_num = ($line_class_num + 1) % $line_class_len;
3922 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
3929 print qq( <tr><td colspan="5" class="error">Unable to parse: $line</td></tr>\n);
3932 $short_rev = substr ($long_rev, 0, 8);
3933 $age = time () - $time;
3934 $age_str = age_string
($age);
3935 $age_str =~ s/ / /g;
3936 $age_class = age_class
($age);
3937 $author = esc_html
($author);
3938 $author =~ s/ / /g;
3940 $data = untabify
($data);
3941 $data = esc_html
($data);
3944 <tr class="$line_class[$line_class_num]">
3945 <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
3946 <td class="$age_class">$age_str</td>
3948 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
3949 <td class="pre">$data</td>
3952 } # while (my $line = <$fd>)
3953 print "</table>\n\n";
3955 or print "Reading blob failed.\n";
3961 my $head = git_get_head_hash
($project);
3963 git_print_page_nav
('','', $head,undef,$head);
3964 git_print_header_div
('summary', $project);
3966 my @tagslist = git_get_tags_list
();
3968 git_tags_body
(\
@tagslist);
3974 my $head = git_get_head_hash
($project);
3976 git_print_page_nav
('','', $head,undef,$head);
3977 git_print_header_div
('summary', $project);
3979 my @headslist = git_get_heads_list
();
3981 git_heads_body
(\
@headslist, $head);
3986 sub git_blob_plain
{
3989 if (!defined $hash) {
3990 if (defined $file_name) {
3991 my $base = $hash_base || git_get_head_hash
($project);
3992 $hash = git_get_hash_by_path
($base, $file_name, "blob")
3993 or die_error
(undef, "Error lookup file");
3995 die_error
(undef, "No file name defined");
3997 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3998 # blobs defined by non-textual hash id's can be cached
4003 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
4004 or die_error
(undef, "Couldn't cat $file_name, $hash");
4006 $type ||= blob_mimetype
($fd, $file_name);
4008 # save as filename, even when no $file_name is given
4009 my $save_as = "$hash";
4010 if (defined $file_name) {
4011 $save_as = $file_name;
4012 } elsif ($type =~ m/^text\//) {
4019 -content_disposition
=> 'inline; filename="' . "$save_as" . '"');
4021 binmode STDOUT
, ':raw';
4023 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
4031 if (!defined $hash) {
4032 if (defined $file_name) {
4033 my $base = $hash_base || git_get_head_hash
($project);
4034 $hash = git_get_hash_by_path
($base, $file_name, "blob")
4035 or die_error
(undef, "Error lookup file");
4037 die_error
(undef, "No file name defined");
4039 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
4040 # blobs defined by non-textual hash id's can be cached
4044 my ($have_blame) = gitweb_check_feature
('blame');
4045 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
4046 or die_error
(undef, "Couldn't cat $file_name, $hash");
4047 my $mimetype = blob_mimetype
($fd, $file_name);
4048 if ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)!) {
4050 return git_blob_plain
($mimetype);
4052 # we can have blame only for text/* mimetype
4053 $have_blame &&= ($mimetype =~ m!^text/!);
4055 git_header_html
(undef, $expires);
4056 my $formats_nav = '';
4057 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
4058 if (defined $file_name) {
4061 $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash_base,
4062 hash
=>$hash, file_name
=>$file_name)},
4067 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
4068 hash
=>$hash, file_name
=>$file_name)},
4071 $cgi->a({-href
=> href
(action
=>"blob_plain",
4072 hash
=>$hash, file_name
=>$file_name)},
4075 $cgi->a({-href
=> href
(action
=>"blob",
4076 hash_base
=>"HEAD", file_name
=>$file_name)},
4080 $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$hash)}, "raw");
4082 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
4083 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
4085 print "<div class=\"page_nav\">\n" .
4086 "<br/><br/></div>\n" .
4087 "<div class=\"title\">$hash</div>\n";
4089 git_print_page_path
($file_name, "blob", $hash_base);
4090 print "<div class=\"page_body\">\n";
4091 if ($mimetype =~ m!^text/!) {
4093 while (my $line = <$fd>) {
4096 $line = untabify
($line);
4097 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
4098 $nr, $nr, $nr, esc_html
($line, -nbsp
=>1);
4100 } elsif ($mimetype =~ m!^image/!) {
4101 print qq
!<img type
="$mimetype"!;
4103 print qq
! alt
="$file_name" title
="$file_name"!;
4106 href(action=>"blob_plain
", hash=>$hash,
4107 hash_base=>$hash_base, file_name=>$file_name) .
4111 or print "Reading blob failed.\n";
4117 my $have_snapshot = gitweb_have_snapshot
();
4119 if (!defined $hash_base) {
4120 $hash_base = "HEAD";
4122 if (!defined $hash) {
4123 if (defined $file_name) {
4124 $hash = git_get_hash_by_path
($hash_base, $file_name, "tree");
4130 open my $fd, "-|", git_cmd
(), "ls-tree", '-z', $hash
4131 or die_error
(undef, "Open git-ls-tree failed");
4132 my @entries = map { chomp; $_ } <$fd>;
4133 close $fd or die_error
(undef, "Reading tree failed");
4136 my $refs = git_get_references
();
4137 my $ref = format_ref_marker
($refs, $hash_base);
4140 my ($have_blame) = gitweb_check_feature
('blame');
4141 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
4143 if (defined $file_name) {
4145 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
4146 hash
=>$hash, file_name
=>$file_name)},
4148 $cgi->a({-href
=> href
(action
=>"tree",
4149 hash_base
=>"HEAD", file_name
=>$file_name)},
4152 if ($have_snapshot) {
4153 # FIXME: Should be available when we have no hash base as well.
4155 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)},
4158 git_print_page_nav
('tree','', $hash_base, undef, undef, join(' | ', @views_nav));
4159 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash_base);
4162 print "<div class=\"page_nav\">\n";
4163 print "<br/><br/></div>\n";
4164 print "<div class=\"title\">$hash</div>\n";
4166 if (defined $file_name) {
4167 $basedir = $file_name;
4168 if ($basedir ne '' && substr($basedir, -1) ne '/') {
4172 git_print_page_path
($file_name, 'tree', $hash_base);
4173 print "<div class=\"page_body\">\n";
4174 print "<table cellspacing=\"0\">\n";
4176 # '..' (top directory) link if possible
4177 if (defined $hash_base &&
4178 defined $file_name && $file_name =~ m![^/]+$!) {
4180 print "<tr class=\"dark\">\n";
4182 print "<tr class=\"light\">\n";
4186 my $up = $file_name;
4187 $up =~ s!/?[^/]+$!!;
4188 undef $up unless $up;
4189 # based on git_print_tree_entry
4190 print '<td class="mode">' . mode_str
('040000') . "</td>\n";
4191 print '<td class="list">';
4192 print $cgi->a({-href
=> href
(action
=>"tree", hash_base
=>$hash_base,
4196 print "<td class=\"link\"></td>\n";
4200 foreach my $line (@entries) {
4201 my %t = parse_ls_tree_line
($line, -z
=> 1);
4204 print "<tr class=\"dark\">\n";
4206 print "<tr class=\"light\">\n";
4210 git_print_tree_entry
(\
%t, $basedir, $hash_base, $have_blame);
4214 print "</table>\n" .
4220 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
4221 my $have_snapshot = (defined $ctype && defined $suffix);
4222 if (!$have_snapshot) {
4223 die_error
('403 Permission denied', "Permission denied");
4226 if (!defined $hash) {
4227 $hash = git_get_head_hash
($project);
4230 my $git = git_cmd_str
();
4231 my $name = $project;
4232 $name =~ s
,([^/])/*\
.git
$,$1,;
4233 $name = basename
($name);
4234 my $filename = to_utf8
($name);
4235 $name =~ s/\047/\047\\\047\047/g;
4237 if ($suffix eq 'zip') {
4238 $filename .= "-$hash.$suffix";
4239 $cmd = "$git archive --format=zip --prefix=\'$name\'/ $hash";
4241 $filename .= "-$hash.tar.$suffix";
4242 $cmd = "$git archive --format=tar --prefix=\'$name\'/ $hash | $command";
4246 -type
=> "application/$ctype",
4247 -content_disposition
=> 'inline; filename="' . "$filename" . '"',
4248 -status
=> '200 OK');
4250 open my $fd, "-|", $cmd
4251 or die_error
(undef, "Execute git-archive failed");
4252 binmode STDOUT
, ':raw';
4254 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
4260 my $head = git_get_head_hash
($project);
4261 if (!defined $hash) {
4264 if (!defined $page) {
4267 my $refs = git_get_references
();
4269 my @commitlist = parse_commits
($hash, 101, (100 * $page));
4271 my $paging_nav = format_paging_nav
('log', $hash, $head, $page, (100 * ($page+1)));
4274 git_print_page_nav
('log','', $hash,undef,undef, $paging_nav);
4277 my %co = parse_commit
($hash);
4279 git_print_header_div
('summary', $project);
4280 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
4282 my $to = ($#commitlist >= 99) ? (99) : ($#commitlist);
4283 for (my $i = 0; $i <= $to; $i++) {
4284 my %co = %{$commitlist[$i]};
4286 my $commit = $co{'id'};
4287 my $ref = format_ref_marker
($refs, $commit);
4288 my %ad = parse_date
($co{'author_epoch'});
4289 git_print_header_div
('commit',
4290 "<span class=\"age\">$co{'age_string'}</span>" .
4291 esc_html
($co{'title'}) . $ref,
4293 print "<div class=\"title_text\">\n" .
4294 "<div class=\"log_link\">\n" .
4295 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") .
4297 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") .
4299 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$commit, hash_base
=>$commit)}, "tree") .
4302 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
4305 print "<div class=\"log_body\">\n";
4306 git_print_log
($co{'comment'}, -final_empty_line
=> 1);
4309 if ($#commitlist >= 100) {
4310 print "<div class=\"page_nav\">\n";
4311 print $cgi->a({-href
=> href
(action
=>"log", hash
=>$hash, page
=>$page+1),
4312 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4319 $hash ||= $hash_base || "HEAD";
4320 my %co = parse_commit
($hash);
4322 die_error
(undef, "Unknown commit object");
4324 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
4325 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
4327 my $parent = $co{'parent'};
4328 my $parents = $co{'parents'}; # listref
4330 # we need to prepare $formats_nav before any parameter munging
4332 if (!defined $parent) {
4334 $formats_nav .= '(initial)';
4335 } elsif (@$parents == 1) {
4336 # single parent commit
4339 $cgi->a({-href
=> href
(action
=>"commit",
4341 esc_html
(substr($parent, 0, 7))) .
4348 $cgi->a({-href
=> href
(action
=>"commit",
4350 esc_html
(substr($_, 0, 7)));
4355 if (!defined $parent) {
4359 open my $fd, "-|", git_cmd
(), "diff-tree", '-r', "--no-commit-id",
4361 (@$parents <= 1 ? $parent : '-c'),
4363 or die_error
(undef, "Open git-diff-tree failed");
4364 @difftree = map { chomp; $_ } <$fd>;
4365 close $fd or die_error
(undef, "Reading git-diff-tree failed");
4367 # non-textual hash id's can be cached
4369 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
4372 my $refs = git_get_references
();
4373 my $ref = format_ref_marker
($refs, $co{'id'});
4375 my $have_snapshot = gitweb_have_snapshot
();
4377 git_header_html
(undef, $expires);
4378 git_print_page_nav
('commit', '',
4379 $hash, $co{'tree'}, $hash,
4382 if (defined $co{'parent'}) {
4383 git_print_header_div
('commitdiff', esc_html
($co{'title'}) . $ref, $hash);
4385 git_print_header_div
('tree', esc_html
($co{'title'}) . $ref, $co{'tree'}, $hash);
4387 print "<div class=\"title_text\">\n" .
4388 "<table cellspacing=\"0\">\n";
4389 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
4391 "<td></td><td> $ad{'rfc2822'}";
4392 if ($ad{'hour_local'} < 6) {
4393 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
4394 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
4396 printf(" (%02d:%02d %s)",
4397 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
4401 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
4402 print "<tr><td></td><td> $cd{'rfc2822'}" .
4403 sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
4405 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
4408 "<td class=\"sha1\">" .
4409 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash),
4410 class => "list"}, $co{'tree'}) .
4412 "<td class=\"link\">" .
4413 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash)},
4415 if ($have_snapshot) {
4417 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)}, "snapshot");
4422 foreach my $par (@$parents) {
4425 "<td class=\"sha1\">" .
4426 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par),
4427 class => "list"}, $par) .
4429 "<td class=\"link\">" .
4430 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par)}, "commit") .
4432 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$hash, hash_parent
=>$par)}, "diff") .
4439 print "<div class=\"page_body\">\n";
4440 git_print_log
($co{'comment'});
4443 git_difftree_body
(\
@difftree, $hash, @$parents);
4449 # object is defined by:
4450 # - hash or hash_base alone
4451 # - hash_base and file_name
4454 # - hash or hash_base alone
4455 if ($hash || ($hash_base && !defined $file_name)) {
4456 my $object_id = $hash || $hash_base;
4458 my $git_command = git_cmd_str
();
4459 open my $fd, "-|", "$git_command cat-file -t $object_id 2>/dev/null"
4460 or die_error
('404 Not Found', "Object does not exist");
4464 or die_error
('404 Not Found', "Object does not exist");
4466 # - hash_base and file_name
4467 } elsif ($hash_base && defined $file_name) {
4468 $file_name =~ s
,/+$,,;
4470 system(git_cmd
(), "cat-file", '-e', $hash_base) == 0
4471 or die_error
('404 Not Found', "Base object does not exist");
4473 # here errors should not hapen
4474 open my $fd, "-|", git_cmd
(), "ls-tree", $hash_base, "--", $file_name
4475 or die_error
(undef, "Open git-ls-tree failed");
4479 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
4480 unless ($line && $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/) {
4481 die_error
('404 Not Found', "File or directory for given base does not exist");
4486 die_error
('404 Not Found', "Not enough information to find object");
4489 print $cgi->redirect(-uri
=> href
(action
=>$type, -full
=>1,
4490 hash
=>$hash, hash_base
=>$hash_base,
4491 file_name
=>$file_name),
4492 -status
=> '302 Found');
4496 my $format = shift || 'html';
4503 # preparing $fd and %diffinfo for git_patchset_body
4505 if (defined $hash_base && defined $hash_parent_base) {
4506 if (defined $file_name) {
4508 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4509 $hash_parent_base, $hash_base,
4510 "--", (defined $file_parent ? $file_parent : ()), $file_name
4511 or die_error
(undef, "Open git-diff-tree failed");
4512 @difftree = map { chomp; $_ } <$fd>;
4514 or die_error
(undef, "Reading git-diff-tree failed");
4516 or die_error
('404 Not Found', "Blob diff not found");
4518 } elsif (defined $hash &&
4519 $hash =~ /[0-9a-fA-F]{40}/) {
4520 # try to find filename from $hash
4522 # read filtered raw output
4523 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4524 $hash_parent_base, $hash_base, "--"
4525 or die_error
(undef, "Open git-diff-tree failed");
4527 # ':100644 100644 03b21826... 3b93d5e7... M ls-files.c'
4529 grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
4530 map { chomp; $_ } <$fd>;
4532 or die_error
(undef, "Reading git-diff-tree failed");
4534 or die_error
('404 Not Found', "Blob diff not found");
4537 die_error
('404 Not Found', "Missing one of the blob diff parameters");
4540 if (@difftree > 1) {
4541 die_error
('404 Not Found', "Ambiguous blob diff specification");
4544 %diffinfo = parse_difftree_raw_line
($difftree[0]);
4545 $file_parent ||= $diffinfo{'from_file'} || $file_name || $diffinfo{'file'};
4546 $file_name ||= $diffinfo{'to_file'} || $diffinfo{'file'};
4548 $hash_parent ||= $diffinfo{'from_id'};
4549 $hash ||= $diffinfo{'to_id'};
4551 # non-textual hash id's can be cached
4552 if ($hash_base =~ m/^[0-9a-fA-F]{40}$/ &&
4553 $hash_parent_base =~ m/^[0-9a-fA-F]{40}$/) {
4558 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4559 '-p', ($format eq 'html' ? "--full-index" : ()),
4560 $hash_parent_base, $hash_base,
4561 "--", (defined $file_parent ? $file_parent : ()), $file_name
4562 or die_error
(undef, "Open git-diff-tree failed");
4565 # old/legacy style URI
4566 if (!%diffinfo && # if new style URI failed
4567 defined $hash && defined $hash_parent) {
4568 # fake git-diff-tree raw output
4569 $diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
4570 $diffinfo{'from_id'} = $hash_parent;
4571 $diffinfo{'to_id'} = $hash;
4572 if (defined $file_name) {
4573 if (defined $file_parent) {
4574 $diffinfo{'status'} = '2';
4575 $diffinfo{'from_file'} = $file_parent;
4576 $diffinfo{'to_file'} = $file_name;
4577 } else { # assume not renamed
4578 $diffinfo{'status'} = '1';
4579 $diffinfo{'from_file'} = $file_name;
4580 $diffinfo{'to_file'} = $file_name;
4582 } else { # no filename given
4583 $diffinfo{'status'} = '2';
4584 $diffinfo{'from_file'} = $hash_parent;
4585 $diffinfo{'to_file'} = $hash;
4588 # non-textual hash id's can be cached
4589 if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
4590 $hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
4595 open $fd, "-|", git_cmd
(), "diff", @diff_opts,
4596 '-p', ($format eq 'html' ? "--full-index" : ()),
4597 $hash_parent, $hash, "--"
4598 or die_error
(undef, "Open git-diff failed");
4600 die_error
('404 Not Found', "Missing one of the blob diff parameters")
4605 if ($format eq 'html') {
4607 $cgi->a({-href
=> href
(action
=>"blobdiff_plain",
4608 hash
=>$hash, hash_parent
=>$hash_parent,
4609 hash_base
=>$hash_base, hash_parent_base
=>$hash_parent_base,
4610 file_name
=>$file_name, file_parent
=>$file_parent)},
4612 git_header_html
(undef, $expires);
4613 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
4614 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
4615 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
4617 print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
4618 print "<div class=\"title\">$hash vs $hash_parent</div>\n";
4620 if (defined $file_name) {
4621 git_print_page_path
($file_name, "blob", $hash_base);
4623 print "<div class=\"page_path\"></div>\n";
4626 } elsif ($format eq 'plain') {
4628 -type
=> 'text/plain',
4629 -charset
=> 'utf-8',
4630 -expires
=> $expires,
4631 -content_disposition
=> 'inline; filename="' . "$file_name" . '.patch"');
4633 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
4636 die_error
(undef, "Unknown blobdiff format");
4640 if ($format eq 'html') {
4641 print "<div class=\"page_body\">\n";
4643 git_patchset_body
($fd, [ \
%diffinfo ], $hash_base, $hash_parent_base);
4646 print "</div>\n"; # class="page_body"
4650 while (my $line = <$fd>) {
4651 $line =~ s!a/($hash|$hash_parent)!'a/'.esc_path($diffinfo{'from_file'})!eg;
4652 $line =~ s!b/($hash|$hash_parent)!'b/'.esc_path($diffinfo{'to_file'})!eg;
4656 last if $line =~ m!^\+\+\+!;
4664 sub git_blobdiff_plain
{
4665 git_blobdiff
('plain');
4668 sub git_commitdiff
{
4669 my $format = shift || 'html';
4670 $hash ||= $hash_base || "HEAD";
4671 my %co = parse_commit
($hash);
4673 die_error
(undef, "Unknown commit object");
4676 # choose format for commitdiff for merge
4677 if (! defined $hash_parent && @{$co{'parents'}} > 1) {
4678 $hash_parent = '--cc';
4680 # we need to prepare $formats_nav before almost any parameter munging
4682 if ($format eq 'html') {
4684 $cgi->a({-href
=> href
(action
=>"commitdiff_plain",
4685 hash
=>$hash, hash_parent
=>$hash_parent)},
4688 if (defined $hash_parent &&
4689 $hash_parent ne '-c' && $hash_parent ne '--cc') {
4690 # commitdiff with two commits given
4691 my $hash_parent_short = $hash_parent;
4692 if ($hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
4693 $hash_parent_short = substr($hash_parent, 0, 7);
4697 for (my $i = 0; $i < @{$co{'parents'}}; $i++) {
4698 if ($co{'parents'}[$i] eq $hash_parent) {
4699 $formats_nav .= ' parent ' . ($i+1);
4703 $formats_nav .= ': ' .
4704 $cgi->a({-href
=> href
(action
=>"commitdiff",
4705 hash
=>$hash_parent)},
4706 esc_html
($hash_parent_short)) .
4708 } elsif (!$co{'parent'}) {
4710 $formats_nav .= ' (initial)';
4711 } elsif (scalar @{$co{'parents'}} == 1) {
4712 # single parent commit
4715 $cgi->a({-href
=> href
(action
=>"commitdiff",
4716 hash
=>$co{'parent'})},
4717 esc_html
(substr($co{'parent'}, 0, 7))) .
4721 if ($hash_parent eq '--cc') {
4722 $formats_nav .= ' | ' .
4723 $cgi->a({-href
=> href
(action
=>"commitdiff",
4724 hash
=>$hash, hash_parent
=>'-c')},
4726 } else { # $hash_parent eq '-c'
4727 $formats_nav .= ' | ' .
4728 $cgi->a({-href
=> href
(action
=>"commitdiff",
4729 hash
=>$hash, hash_parent
=>'--cc')},
4735 $cgi->a({-href
=> href
(action
=>"commitdiff",
4737 esc_html
(substr($_, 0, 7)));
4738 } @{$co{'parents'}} ) .
4743 my $hash_parent_param = $hash_parent;
4744 if (!defined $hash_parent_param) {
4745 # --cc for multiple parents, --root for parentless
4746 $hash_parent_param =
4747 @{$co{'parents'}} > 1 ? '--cc' : $co{'parent'} || '--root';
4753 if ($format eq 'html') {
4754 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4755 "--no-commit-id", "--patch-with-raw", "--full-index",
4756 $hash_parent_param, $hash, "--"
4757 or die_error
(undef, "Open git-diff-tree failed");
4759 while (my $line = <$fd>) {
4761 # empty line ends raw part of diff-tree output
4763 push @difftree, scalar parse_difftree_raw_line
($line);
4766 } elsif ($format eq 'plain') {
4767 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4768 '-p', $hash_parent_param, $hash, "--"
4769 or die_error
(undef, "Open git-diff-tree failed");
4772 die_error
(undef, "Unknown commitdiff format");
4775 # non-textual hash id's can be cached
4777 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
4781 # write commit message
4782 if ($format eq 'html') {
4783 my $refs = git_get_references
();
4784 my $ref = format_ref_marker
($refs, $co{'id'});
4786 git_header_html
(undef, $expires);
4787 git_print_page_nav
('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
4788 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash);
4789 git_print_authorship
(\
%co);
4790 print "<div class=\"page_body\">\n";
4791 if (@{$co{'comment'}} > 1) {
4792 print "<div class=\"log\">\n";
4793 git_print_log
($co{'comment'}, -final_empty_line
=> 1, -remove_title
=> 1);
4794 print "</div>\n"; # class="log"
4797 } elsif ($format eq 'plain') {
4798 my $refs = git_get_references
("tags");
4799 my $tagname = git_get_rev_name_tags
($hash);
4800 my $filename = basename
($project) . "-$hash.patch";
4803 -type
=> 'text/plain',
4804 -charset
=> 'utf-8',
4805 -expires
=> $expires,
4806 -content_disposition
=> 'inline; filename="' . "$filename" . '"');
4807 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
4810 Date: $ad{'rfc2822'} ($ad{'tz_local'})
4811 Subject: $co{'title'}
4813 print "X-Git-Tag: $tagname\n" if $tagname;
4814 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
4816 foreach my $line (@{$co{'comment'}}) {
4823 if ($format eq 'html') {
4824 my $use_parents = !defined $hash_parent ||
4825 $hash_parent eq '-c' || $hash_parent eq '--cc';
4826 git_difftree_body
(\
@difftree, $hash,
4827 $use_parents ? @{$co{'parents'}} : $hash_parent);
4830 git_patchset_body
($fd, \
@difftree, $hash,
4831 $use_parents ? @{$co{'parents'}} : $hash_parent);
4833 print "</div>\n"; # class="page_body"
4836 } elsif ($format eq 'plain') {
4840 or print "Reading git-diff-tree failed\n";
4844 sub git_commitdiff_plain
{
4845 git_commitdiff
('plain');
4849 if (!defined $hash_base) {
4850 $hash_base = git_get_head_hash
($project);
4852 if (!defined $page) {
4856 my %co = parse_commit
($hash_base);
4858 die_error
(undef, "Unknown commit object");
4861 my $refs = git_get_references
();
4862 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
4864 if (!defined $hash && defined $file_name) {
4865 $hash = git_get_hash_by_path
($hash_base, $file_name);
4867 if (defined $hash) {
4868 $ftype = git_get_type
($hash);
4871 my @commitlist = parse_commits
($hash_base, 101, (100 * $page), "--full-history", $file_name);
4873 my $paging_nav = '';
4876 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4877 file_name
=>$file_name)},
4879 $paging_nav .= " ⋅ " .
4880 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4881 file_name
=>$file_name, page
=>$page-1),
4882 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
4884 $paging_nav .= "first";
4885 $paging_nav .= " ⋅ prev";
4887 if ($#commitlist >= 100) {
4888 $paging_nav .= " ⋅ " .
4889 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4890 file_name
=>$file_name, page
=>$page+1),
4891 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4893 $paging_nav .= " ⋅ next";
4896 if ($#commitlist >= 100) {
4898 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4899 file_name
=>$file_name, page
=>$page+1),
4900 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4904 git_print_page_nav
('history','', $hash_base,$co{'tree'},$hash_base, $paging_nav);
4905 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
4906 git_print_page_path
($file_name, $ftype, $hash_base);
4908 git_history_body
(\
@commitlist, 0, 99,
4909 $refs, $hash_base, $ftype, $next_link);
4915 my ($have_search) = gitweb_check_feature
('search');
4916 if (!$have_search) {
4917 die_error
('403 Permission denied', "Permission denied");
4919 if (!defined $searchtext) {
4920 die_error
(undef, "Text field empty");
4922 if (!defined $hash) {
4923 $hash = git_get_head_hash
($project);
4925 my %co = parse_commit
($hash);
4927 die_error
(undef, "Unknown commit object");
4929 if (!defined $page) {
4933 $searchtype ||= 'commit';
4934 if ($searchtype eq 'pickaxe') {
4935 # pickaxe may take all resources of your box and run for several minutes
4936 # with every query - so decide by yourself how public you make this feature
4937 my ($have_pickaxe) = gitweb_check_feature
('pickaxe');
4938 if (!$have_pickaxe) {
4939 die_error
('403 Permission denied', "Permission denied");
4942 if ($searchtype eq 'grep') {
4943 my ($have_grep) = gitweb_check_feature
('grep');
4945 die_error
('403 Permission denied', "Permission denied");
4951 if ($searchtype eq 'commit' or $searchtype eq 'author' or $searchtype eq 'committer') {
4953 if ($searchtype eq 'commit') {
4954 $greptype = "--grep=";
4955 } elsif ($searchtype eq 'author') {
4956 $greptype = "--author=";
4957 } elsif ($searchtype eq 'committer') {
4958 $greptype = "--committer=";
4960 $greptype .= $search_regexp;
4961 my @commitlist = parse_commits
($hash, 101, (100 * $page), $greptype);
4963 my $paging_nav = '';
4966 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4967 searchtext
=>$searchtext, searchtype
=>$searchtype)},
4969 $paging_nav .= " ⋅ " .
4970 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4971 searchtext
=>$searchtext, searchtype
=>$searchtype,
4973 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
4975 $paging_nav .= "first";
4976 $paging_nav .= " ⋅ prev";
4978 if ($#commitlist >= 100) {
4979 $paging_nav .= " ⋅ " .
4980 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4981 searchtext
=>$searchtext, searchtype
=>$searchtype,
4983 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4985 $paging_nav .= " ⋅ next";
4988 if ($#commitlist >= 100) {
4990 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4991 searchtext
=>$searchtext, searchtype
=>$searchtype,
4993 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4996 git_print_page_nav
('','', $hash,$co{'tree'},$hash, $paging_nav);
4997 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
4998 git_search_grep_body
(\
@commitlist, 0, 99, $next_link);
5001 if ($searchtype eq 'pickaxe') {
5002 git_print_page_nav
('','', $hash,$co{'tree'},$hash);
5003 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
5005 print "<table cellspacing=\"0\">\n";
5008 my $git_command = git_cmd_str
();
5009 my $searchqtext = $searchtext;
5010 $searchqtext =~ s/'/'\\''/;
5011 open my $fd, "-|", "$git_command rev-list $hash | " .
5012 "$git_command diff-tree -r --stdin -S\'$searchqtext\'";
5015 while (my $line = <$fd>) {
5016 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
5019 $set{'from_id'} = $3;
5021 $set{'id'} = $set{'to_id'};
5022 if ($set{'id'} =~ m/0{40}/) {
5023 $set{'id'} = $set{'from_id'};
5025 if ($set{'id'} =~ m/0{40}/) {
5029 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
5032 print "<tr class=\"dark\">\n";
5034 print "<tr class=\"light\">\n";
5037 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
5038 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
5040 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}),
5041 -class => "list subject"},
5042 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
5043 while (my $setref = shift @files) {
5045 print $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$co{'id'},
5046 hash
=>$set{'id'}, file_name
=>$set{'file'}),
5048 "<span class=\"match\">" . esc_path
($set{'file'}) . "</span>") .
5052 "<td class=\"link\">" .
5053 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
5055 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
5059 %co = parse_commit
($1);
5067 if ($searchtype eq 'grep') {
5068 git_print_page_nav
('','', $hash,$co{'tree'},$hash);
5069 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
5071 print "<table cellspacing=\"0\">\n";
5075 open my $fd, "-|", git_cmd
(), 'grep', '-n', '-i', '-E', $searchtext, $co{'tree'};
5077 while (my $line = <$fd>) {
5079 my ($file, $lno, $ltext, $binary);
5080 last if ($matches++ > 1000);
5081 if ($line =~ /^Binary file (.+) matches$/) {
5085 (undef, $file, $lno, $ltext) = split(/:/, $line, 4);
5087 if ($file ne $lastfile) {
5088 $lastfile and print "</td></tr>\n";
5090 print "<tr class=\"dark\">\n";
5092 print "<tr class=\"light\">\n";
5094 print "<td class=\"list\">".
5095 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$co{'hash'},
5096 file_name
=>"$file"),
5097 -class => "list"}, esc_path
($file));
5098 print "</td><td>\n";
5102 print "<div class=\"binary\">Binary file</div>\n";
5104 $ltext = untabify
($ltext);
5105 if ($ltext =~ m/^(.*)($searchtext)(.*)$/i) {
5106 $ltext = esc_html
($1, -nbsp
=>1);
5107 $ltext .= '<span class="match">';
5108 $ltext .= esc_html
($2, -nbsp
=>1);
5109 $ltext .= '</span>';
5110 $ltext .= esc_html
($3, -nbsp
=>1);
5112 $ltext = esc_html
($ltext, -nbsp
=>1);
5114 print "<div class=\"pre\">" .
5115 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$co{'hash'},
5116 file_name
=>"$file").'#l'.$lno,
5117 -class => "linenr"}, sprintf('%4i', $lno))
5118 . ' ' . $ltext . "</div>\n";
5122 print "</td></tr>\n";
5123 if ($matches > 1000) {
5124 print "<div class=\"diff nodifferences\">Too many matches, listing trimmed</div>\n";
5127 print "<div class=\"diff nodifferences\">No matches found</div>\n";
5136 sub git_search_help
{
5138 git_print_page_nav
('','', $hash,$hash,$hash);
5141 <dt><b>commit</b></dt>
5142 <dd>The commit messages and authorship information will be scanned for the given string.</dd>
5144 my ($have_grep) = gitweb_check_feature
('grep');
5147 <dt><b>grep</b></dt>
5148 <dd>All files in the currently selected tree (HEAD unless you are explicitly browsing
5149 a different one) are searched for the given
5150 <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expression</a>
5151 (POSIX extended) and the matches are listed. On large
5152 trees, this search can take a while and put some strain on the server, so please use it with
5153 some consideration.</dd>
5157 <dt><b>author</b></dt>
5158 <dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given string.</dd>
5159 <dt><b>committer</b></dt>
5160 <dd>Name and e-mail of the committer and date of commit will be scanned for the given string.</dd>
5162 my ($have_pickaxe) = gitweb_check_feature
('pickaxe');
5163 if ($have_pickaxe) {
5165 <dt><b>pickaxe</b></dt>
5166 <dd>All commits that caused the string to appear or disappear from any file (changes that
5167 added, removed or "modified" the string) will be listed. This search can take a while and
5168 takes a lot of strain on the server, so please use it wisely.</dd>
5176 my $head = git_get_head_hash
($project);
5177 if (!defined $hash) {
5180 if (!defined $page) {
5183 my $refs = git_get_references
();
5185 my @commitlist = parse_commits
($hash, 101, (100 * $page));
5187 my $paging_nav = format_paging_nav
('shortlog', $hash, $head, $page, (100 * ($page+1)));
5189 if ($#commitlist >= 100) {
5191 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$hash, page
=>$page+1),
5192 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
5196 git_print_page_nav
('shortlog','', $hash,$hash,$hash, $paging_nav);
5197 git_print_header_div
('summary', $project);
5199 git_shortlog_body
(\
@commitlist, 0, 99, $refs, $next_link);
5204 ## ......................................................................
5205 ## feeds (RSS, Atom; OPML)
5208 my $format = shift || 'atom';
5209 my ($have_blame) = gitweb_check_feature
('blame');
5211 # Atom: http://www.atomenabled.org/developers/syndication/
5212 # RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
5213 if ($format ne 'rss' && $format ne 'atom') {
5214 die_error
(undef, "Unknown web feed format");
5217 # log/feed of current (HEAD) branch, log of given branch, history of file/directory
5218 my $head = $hash || 'HEAD';
5219 my @commitlist = parse_commits
($head, 150);
5223 my $content_type = "application/$format+xml";
5224 if (defined $cgi->http('HTTP_ACCEPT') &&
5225 $cgi->Accept('text/xml') > $cgi->Accept($content_type)) {
5226 # browser (feed reader) prefers text/xml
5227 $content_type = 'text/xml';
5229 if (defined($commitlist[0])) {
5230 %latest_commit = %{$commitlist[0]};
5231 %latest_date = parse_date
($latest_commit{'author_epoch'});
5233 -type
=> $content_type,
5234 -charset
=> 'utf-8',
5235 -last_modified
=> $latest_date{'rfc2822'});
5238 -type
=> $content_type,
5239 -charset
=> 'utf-8');
5242 # Optimization: skip generating the body if client asks only
5243 # for Last-Modified date.
5244 return if ($cgi->request_method() eq 'HEAD');
5247 my $title = "$site_name - $project/$action";
5248 my $feed_type = 'log';
5249 if (defined $hash) {
5250 $title .= " - '$hash'";
5251 $feed_type = 'branch log';
5252 if (defined $file_name) {
5253 $title .= " :: $file_name";
5254 $feed_type = 'history';
5256 } elsif (defined $file_name) {
5257 $title .= " - $file_name";
5258 $feed_type = 'history';
5260 $title .= " $feed_type";
5261 my $descr = git_get_project_description
($project);
5262 if (defined $descr) {
5263 $descr = esc_html
($descr);
5265 $descr = "$project " .
5266 ($format eq 'rss' ? 'RSS' : 'Atom') .
5269 my $owner = git_get_project_owner
($project);
5270 $owner = esc_html
($owner);
5274 if (defined $file_name) {
5275 $alt_url = href
(-full
=>1, action
=>"history", hash
=>$hash, file_name
=>$file_name);
5276 } elsif (defined $hash) {
5277 $alt_url = href
(-full
=>1, action
=>"log", hash
=>$hash);
5279 $alt_url = href
(-full
=>1, action
=>"summary");
5281 print qq
!<?xml version
="1.0" encoding
="utf-8"?>\n!;
5282 if ($format eq 'rss') {
5284 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
5287 print "<title>$title</title>\n" .
5288 "<link>$alt_url</link>\n" .
5289 "<description>$descr</description>\n" .
5290 "<language>en</language>\n";
5291 } elsif ($format eq 'atom') {
5293 <feed xmlns="http://www.w3.org/2005/Atom">
5295 print "<title>$title</title>\n" .
5296 "<subtitle>$descr</subtitle>\n" .
5297 '<link rel="alternate" type="text/html" href="' .
5298 $alt_url . '" />' . "\n" .
5299 '<link rel="self" type="' . $content_type . '" href="' .
5300 $cgi->self_url() . '" />' . "\n" .
5301 "<id>" . href
(-full
=>1) . "</id>\n" .
5302 # use project owner for feed author
5303 "<author><name>$owner</name></author>\n";
5304 if (defined $favicon) {
5305 print "<icon>" . esc_url
($favicon) . "</icon>\n";
5307 if (defined $logo_url) {
5308 # not twice as wide as tall: 72 x 27 pixels
5309 print "<logo>" . esc_url
($logo) . "</logo>\n";
5311 if (! %latest_date) {
5312 # dummy date to keep the feed valid until commits trickle in:
5313 print "<updated>1970-01-01T00:00:00Z</updated>\n";
5315 print "<updated>$latest_date{'iso-8601'}</updated>\n";
5320 for (my $i = 0; $i <= $#commitlist; $i++) {
5321 my %co = %{$commitlist[$i]};
5322 my $commit = $co{'id'};
5323 # we read 150, we always show 30 and the ones more recent than 48 hours
5324 if (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) {
5327 my %cd = parse_date
($co{'author_epoch'});
5329 # get list of changed files
5330 open my $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
5331 $co{'parent'} || "--root",
5332 $co{'id'}, "--", (defined $file_name ? $file_name : ())
5334 my @difftree = map { chomp; $_ } <$fd>;
5338 # print element (entry, item)
5339 my $co_url = href
(-full
=>1, action
=>"commit", hash
=>$commit);
5340 if ($format eq 'rss') {
5342 "<title>" . esc_html
($co{'title'}) . "</title>\n" .
5343 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
5344 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
5345 "<guid isPermaLink=\"true\">$co_url</guid>\n" .
5346 "<link>$co_url</link>\n" .
5347 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
5348 "<content:encoded>" .
5350 } elsif ($format eq 'atom') {
5352 "<title type=\"html\">" . esc_html
($co{'title'}) . "</title>\n" .
5353 "<updated>$cd{'iso-8601'}</updated>\n" .
5355 " <name>" . esc_html
($co{'author_name'}) . "</name>\n";
5356 if ($co{'author_email'}) {
5357 print " <email>" . esc_html
($co{'author_email'}) . "</email>\n";
5359 print "</author>\n" .
5360 # use committer for contributor
5362 " <name>" . esc_html
($co{'committer_name'}) . "</name>\n";
5363 if ($co{'committer_email'}) {
5364 print " <email>" . esc_html
($co{'committer_email'}) . "</email>\n";
5366 print "</contributor>\n" .
5367 "<published>$cd{'iso-8601'}</published>\n" .
5368 "<link rel=\"alternate\" type=\"text/html\" href=\"$co_url\" />\n" .
5369 "<id>$co_url</id>\n" .
5370 "<content type=\"xhtml\" xml:base=\"" . esc_url
($my_url) . "\">\n" .
5371 "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
5373 my $comment = $co{'comment'};
5375 foreach my $line (@$comment) {
5376 $line = esc_html
($line);
5379 print "</pre><ul>\n";
5380 foreach my $difftree_line (@difftree) {
5381 my %difftree = parse_difftree_raw_line
($difftree_line);
5382 next if !$difftree{'from_id'};
5384 my $file = $difftree{'file'} || $difftree{'to_file'};
5388 $cgi->a({-href
=> href
(-full
=>1, action
=>"blobdiff",
5389 hash
=>$difftree{'to_id'}, hash_parent
=>$difftree{'from_id'},
5390 hash_base
=>$co{'id'}, hash_parent_base
=>$co{'parent'},
5391 file_name
=>$file, file_parent
=>$difftree{'from_file'}),
5392 -title
=> "diff"}, 'D');
5394 print $cgi->a({-href
=> href
(-full
=>1, action
=>"blame",
5395 file_name
=>$file, hash_base
=>$commit),
5396 -title
=> "blame"}, 'B');
5398 # if this is not a feed of a file history
5399 if (!defined $file_name || $file_name ne $file) {
5400 print $cgi->a({-href
=> href
(-full
=>1, action
=>"history",
5401 file_name
=>$file, hash
=>$commit),
5402 -title
=> "history"}, 'H');
5404 $file = esc_path
($file);
5408 if ($format eq 'rss') {
5409 print "</ul>]]>\n" .
5410 "</content:encoded>\n" .
5412 } elsif ($format eq 'atom') {
5413 print "</ul>\n</div>\n" .
5420 if ($format eq 'rss') {
5421 print "</channel>\n</rss>\n";
5422 } elsif ($format eq 'atom') {
5436 my @list = git_get_projects_list
();
5438 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
5440 <?xml version="1.0" encoding="utf-8"?>
5441 <opml version="1.0">
5443 <title>$site_name OPML Export</title>
5446 <outline text="git RSS feeds">
5449 foreach my $pr (@list) {
5451 my $head = git_get_head_hash
($proj{'path'});
5452 if (!defined $head) {
5455 $git_dir = "$projectroot/$proj{'path'}";
5456 my %co = parse_commit
($head);
5461 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
5462 my $rss = "$my_url?p=$proj{'path'};a=rss";
5463 my $html = "$my_url?p=$proj{'path'};a=summary";
5464 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";