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;
60 # URI of GIT logo (72x27 size)
61 our $logo = "++GITWEB_LOGO++";
62 # URI of GIT favicon, assumed to be image/png type
63 our $favicon = "++GITWEB_FAVICON++";
65 # URI and label (title) of GIT logo link
66 #our $logo_url = "http://www.kernel.org/pub/software/scm/git/docs/";
67 #our $logo_label = "git documentation";
68 our $logo_url = "http://git.or.cz/";
69 our $logo_label = "git homepage";
71 # source of projects list
72 our $projects_list = "++GITWEB_LIST++";
74 # show repository only if this file exists
75 # (only effective if this variable evaluates to true)
76 our $export_ok = "++GITWEB_EXPORT_OK++";
78 # only allow viewing of repositories also shown on the overview page
79 our $strict_export = "++GITWEB_STRICT_EXPORT++";
81 # list of git base URLs used for URL to where fetch project from,
82 # i.e. full URL is "$git_base_url/$project"
83 our @git_base_url_list = grep { $_ ne '' } ("++GITWEB_BASE_URL++");
85 # default blob_plain mimetype and default charset for text/plain blob
86 our $default_blob_plain_mimetype = 'text/plain';
87 our $default_text_plain_charset = undef;
89 # file to use for guessing MIME types before trying /etc/mime.types
90 # (relative to the current git repository)
91 our $mimetypes_file = undef;
93 # You define site-wide feature defaults here; override them with
94 # $GITWEB_CONFIG as necessary.
97 # 'sub' => feature-sub (subroutine),
98 # 'override' => allow-override (boolean),
99 # 'default' => [ default options...] (array reference)}
101 # if feature is overridable (it means that allow-override has true value,
102 # then feature-sub will be called with default options as parameters;
103 # return value of feature-sub indicates if to enable specified feature
105 # use gitweb_check_feature(<feature>) to check if <feature> is enabled
107 # Enable the 'blame' blob view, showing the last commit that modified
108 # each line in the file. This can be very CPU-intensive.
110 # To enable system wide have in $GITWEB_CONFIG
111 # $feature{'blame'}{'default'} = [1];
112 # To have project specific config enable override in $GITWEB_CONFIG
113 # $feature{'blame'}{'override'} = 1;
114 # and in project config gitweb.blame = 0|1;
116 'sub' => \
&feature_blame
,
120 # Enable the 'snapshot' link, providing a compressed tarball of any
121 # tree. This can potentially generate high traffic if you have large
124 # To disable system wide have in $GITWEB_CONFIG
125 # $feature{'snapshot'}{'default'} = [undef];
126 # To have project specific config enable override in $GITWEB_CONFIG
127 # $feature{'snapshot'}{'override'} = 1;
128 # and in project config gitweb.snapshot = none|gzip|bzip2;
130 'sub' => \
&feature_snapshot
,
132 # => [content-encoding, suffix, program]
133 'default' => ['x-gzip', 'gz', 'gzip']},
135 # Enable text search, which will list the commits which match author,
136 # committer or commit text to a given string. Enabled by default.
141 # Enable the pickaxe search, which will list the commits that modified
142 # a given string in a file. This can be practical and quite faster
143 # alternative to 'blame', but still potentially CPU-intensive.
145 # To enable system wide have in $GITWEB_CONFIG
146 # $feature{'pickaxe'}{'default'} = [1];
147 # To have project specific config enable override in $GITWEB_CONFIG
148 # $feature{'pickaxe'}{'override'} = 1;
149 # and in project config gitweb.pickaxe = 0|1;
151 'sub' => \
&feature_pickaxe
,
155 # Make gitweb use an alternative format of the URLs which can be
156 # more readable and natural-looking: project name is embedded
157 # directly in the path and the query string contains other
158 # auxiliary information. All gitweb installations recognize
159 # URL in either format; this configures in which formats gitweb
162 # To enable system wide have in $GITWEB_CONFIG
163 # $feature{'pathinfo'}{'default'} = [1];
164 # Project specific override is not supported.
166 # Note that you will need to change the default location of CSS,
167 # favicon, logo and possibly other files to an absolute URL. Also,
168 # if gitweb.cgi serves as your indexfile, you will need to force
169 # $my_uri to contain the script name in your $GITWEB_CONFIG.
174 # Make gitweb consider projects in project root subdirectories
175 # to be forks of existing projects. Given project $projname.git,
176 # projects matching $projname/*.git will not be shown in the main
177 # projects list, instead a '+' mark will be added to $projname
178 # there and a 'forks' view will be enabled for the project, listing
179 # all the forks. This feature is supported only if project list
180 # is taken from a directory, not file.
182 # To enable system wide have in $GITWEB_CONFIG
183 # $feature{'forks'}{'default'} = [1];
184 # Project specific override is not supported.
190 sub gitweb_check_feature
{
192 return unless exists $feature{$name};
193 my ($sub, $override, @defaults) = (
194 $feature{$name}{'sub'},
195 $feature{$name}{'override'},
196 @
{$feature{$name}{'default'}});
197 if (!$override) { return @defaults; }
199 warn "feature $name is not overrideable";
202 return $sub->(@defaults);
206 my ($val) = git_get_project_config
('blame', '--bool');
208 if ($val eq 'true') {
210 } elsif ($val eq 'false') {
217 sub feature_snapshot
{
218 my ($ctype, $suffix, $command) = @_;
220 my ($val) = git_get_project_config
('snapshot');
222 if ($val eq 'gzip') {
223 return ('x-gzip', 'gz', 'gzip');
224 } elsif ($val eq 'bzip2') {
225 return ('x-bzip2', 'bz2', 'bzip2');
226 } elsif ($val eq 'none') {
230 return ($ctype, $suffix, $command);
233 sub gitweb_have_snapshot
{
234 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
235 my $have_snapshot = (defined $ctype && defined $suffix);
237 return $have_snapshot;
240 sub feature_pickaxe
{
241 my ($val) = git_get_project_config
('pickaxe', '--bool');
243 if ($val eq 'true') {
245 } elsif ($val eq 'false') {
252 # checking HEAD file with -e is fragile if the repository was
253 # initialized long time ago (i.e. symlink HEAD) and was pack-ref'ed
255 sub check_head_link
{
257 my $headfile = "$dir/HEAD";
258 return ((-e
$headfile) ||
259 (-l
$headfile && readlink($headfile) =~ /^refs\/heads\
//));
262 sub check_export_ok
{
264 return (check_head_link
($dir) &&
265 (!$export_ok || -e
"$dir/$export_ok"));
268 # rename detection options for git-diff and git-diff-tree
269 # - default is '-M', with the cost proportional to
270 # (number of removed files) * (number of new files).
271 # - more costly is '-C' (or '-C', '-M'), with the cost proportional to
272 # (number of changed files + number of removed files) * (number of new files)
273 # - even more costly is '-C', '--find-copies-harder' with cost
274 # (number of files in the original tree) * (number of new files)
275 # - one might want to include '-B' option, e.g. '-B', '-M'
276 our @diff_opts = ('-M'); # taken from git_commit
278 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
279 do $GITWEB_CONFIG if -e
$GITWEB_CONFIG;
281 # version of the core git binary
282 our $git_version = qx($GIT --version
) =~ m/git version (.*)$/ ?
$1 : "unknown";
284 $projects_list ||= $projectroot;
286 # ======================================================================
287 # input validation and dispatch
288 our $action = $cgi->param('a');
289 if (defined $action) {
290 if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
291 die_error
(undef, "Invalid action parameter");
295 # parameters which are pathnames
296 our $project = $cgi->param('p');
297 if (defined $project) {
298 if (!validate_pathname
($project) ||
299 !(-d
"$projectroot/$project") ||
300 !check_head_link
("$projectroot/$project") ||
301 ($export_ok && !(-e
"$projectroot/$project/$export_ok")) ||
302 ($strict_export && !project_in_list
($project))) {
304 die_error
(undef, "No such project");
308 our $file_name = $cgi->param('f');
309 if (defined $file_name) {
310 if (!validate_pathname
($file_name)) {
311 die_error
(undef, "Invalid file parameter");
315 our $file_parent = $cgi->param('fp');
316 if (defined $file_parent) {
317 if (!validate_pathname
($file_parent)) {
318 die_error
(undef, "Invalid file parent parameter");
322 # parameters which are refnames
323 our $hash = $cgi->param('h');
325 if (!validate_refname
($hash)) {
326 die_error
(undef, "Invalid hash parameter");
330 our $hash_parent = $cgi->param('hp');
331 if (defined $hash_parent) {
332 if (!validate_refname
($hash_parent)) {
333 die_error
(undef, "Invalid hash parent parameter");
337 our $hash_base = $cgi->param('hb');
338 if (defined $hash_base) {
339 if (!validate_refname
($hash_base)) {
340 die_error
(undef, "Invalid hash base parameter");
344 our $hash_parent_base = $cgi->param('hpb');
345 if (defined $hash_parent_base) {
346 if (!validate_refname
($hash_parent_base)) {
347 die_error
(undef, "Invalid hash parent base parameter");
352 our $page = $cgi->param('pg');
354 if ($page =~ m/[^0-9]/) {
355 die_error
(undef, "Invalid page parameter");
359 our $searchtext = $cgi->param('s');
360 if (defined $searchtext) {
361 if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\
-\
+\
:\@
]/) {
362 die_error
(undef, "Invalid search parameter");
364 if (length($searchtext) < 2) {
365 die_error
(undef, "At least two characters are required for search parameter");
367 $searchtext = quotemeta $searchtext;
370 our $searchtype = $cgi->param('st');
371 if (defined $searchtype) {
372 if ($searchtype =~ m/[^a-z]/) {
373 die_error
(undef, "Invalid searchtype parameter");
377 # now read PATH_INFO and use it as alternative to parameters
378 sub evaluate_path_info
{
379 return if defined $project;
380 my $path_info = $ENV{"PATH_INFO"};
381 return if !$path_info;
382 $path_info =~ s
,^/+,,;
383 return if !$path_info;
384 # find which part of PATH_INFO is project
385 $project = $path_info;
387 while ($project && !check_head_link
("$projectroot/$project")) {
388 $project =~ s
,/*[^/]*$,,;
391 $project = validate_pathname
($project);
393 ($export_ok && !-e
"$projectroot/$project/$export_ok") ||
394 ($strict_export && !project_in_list
($project))) {
398 # do not change any parameters if an action is given using the query string
400 $path_info =~ s
,^$project/*,,;
401 my ($refname, $pathname) = split(/:/, $path_info, 2);
402 if (defined $pathname) {
403 # we got "project.git/branch:filename" or "project.git/branch:dir/"
404 # we could use git_get_type(branch:pathname), but it needs $git_dir
405 $pathname =~ s
,^/+,,;
406 if (!$pathname || substr($pathname, -1) eq "/") {
410 $action ||= "blob_plain";
412 $hash_base ||= validate_refname
($refname);
413 $file_name ||= validate_pathname
($pathname);
414 } elsif (defined $refname) {
415 # we got "project.git/branch"
416 $action ||= "shortlog";
417 $hash ||= validate_refname
($refname);
420 evaluate_path_info
();
422 # path to the current git repository
424 $git_dir = "$projectroot/$project" if $project;
428 "blame" => \
&git_blame2
,
429 "blobdiff" => \
&git_blobdiff
,
430 "blobdiff_plain" => \
&git_blobdiff_plain
,
431 "blob" => \
&git_blob
,
432 "blob_plain" => \
&git_blob_plain
,
433 "commitdiff" => \
&git_commitdiff
,
434 "commitdiff_plain" => \
&git_commitdiff_plain
,
435 "commit" => \
&git_commit
,
436 "forks" => \
&git_forks
,
437 "heads" => \
&git_heads
,
438 "history" => \
&git_history
,
441 "atom" => \
&git_atom
,
442 "search" => \
&git_search
,
443 "search_help" => \
&git_search_help
,
444 "shortlog" => \
&git_shortlog
,
445 "summary" => \
&git_summary
,
447 "tags" => \
&git_tags
,
448 "tree" => \
&git_tree
,
449 "snapshot" => \
&git_snapshot
,
450 "object" => \
&git_object
,
451 # those below don't need $project
452 "opml" => \
&git_opml
,
453 "project_list" => \
&git_project_list
,
454 "project_index" => \
&git_project_index
,
457 if (defined $project) {
458 $action ||= 'summary';
460 $action ||= 'project_list';
462 if (!defined($actions{$action})) {
463 die_error
(undef, "Unknown action");
465 if ($action !~ m/^(opml|project_list|project_index)$/ &&
467 die_error
(undef, "Project needed");
469 $actions{$action}->();
472 ## ======================================================================
477 # default is to use -absolute url() i.e. $my_uri
478 my $href = $params{-full
} ?
$my_url : $my_uri;
480 # XXX: Warning: If you touch this, check the search form for updating,
491 hash_parent_base
=> "hpb",
497 my %mapping = @mapping;
499 $params{'project'} = $project unless exists $params{'project'};
501 my ($use_pathinfo) = gitweb_check_feature
('pathinfo');
503 # use PATH_INFO for project name
504 $href .= "/$params{'project'}" if defined $params{'project'};
505 delete $params{'project'};
507 # Summary just uses the project path URL
508 if (defined $params{'action'} && $params{'action'} eq 'summary') {
509 delete $params{'action'};
513 # now encode the parameters explicitly
515 for (my $i = 0; $i < @mapping; $i += 2) {
516 my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
517 if (defined $params{$name}) {
518 push @result, $symbol . "=" . esc_param
($params{$name});
521 $href .= "?" . join(';', @result) if scalar @result;
527 ## ======================================================================
528 ## validation, quoting/unquoting and escaping
530 sub validate_pathname
{
531 my $input = shift || return undef;
533 # no '.' or '..' as elements of path, i.e. no '.' nor '..'
534 # at the beginning, at the end, and between slashes.
535 # also this catches doubled slashes
536 if ($input =~ m!(^|/)(|\.|\.\.)(/|$)!) {
540 if ($input =~ m!\0!) {
546 sub validate_refname
{
547 my $input = shift || return undef;
549 # textual hashes are O.K.
550 if ($input =~ m/^[0-9a-fA-F]{40}$/) {
553 # it must be correct pathname
554 $input = validate_pathname
($input)
556 # restrictions on ref name according to git-check-ref-format
557 if ($input =~ m!(/\.|\.\.|[\000-\040\177 ~^:?*\[]|/$)!) {
563 # quote unsafe chars, but keep the slash, even when it's not
564 # correct, but quoted slashes look too horrible in bookmarks
567 $str =~ s/([^A-Za-z0-9\-_.~()\/:@])/sprintf
("%%%02X", ord($1))/eg
;
573 # quote unsafe chars in whole URL, so some charactrs cannot be quoted
576 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
582 # replace invalid utf8 character with SUBSTITUTION sequence
587 $str = decode_utf8
($str);
588 $str = $cgi->escapeHTML($str);
589 if ($opts{'-nbsp'}) {
590 $str =~ s/ / /g;
592 $str =~ s
|([[:cntrl
:]])|(($1 ne "\t") ? quot_cec
($1) : $1)|eg
;
596 # quote control characters and escape filename to HTML
601 $str = decode_utf8
($str);
602 $str = $cgi->escapeHTML($str);
603 if ($opts{'-nbsp'}) {
604 $str =~ s/ / /g;
606 $str =~ s
|([[:cntrl
:]])|quot_cec
($1)|eg
;
610 # Make control characters "printable", using character escape codes (CEC)
613 my %es = ( # character escape codes, aka escape sequences
614 "\t" => '\t', # tab (HT)
615 "\n" => '\n', # line feed (LF)
616 "\r" => '\r', # carrige return (CR)
617 "\f" => '\f', # form feed (FF)
618 "\b" => '\b', # backspace (BS)
619 "\a" => '\a', # alarm (bell) (BEL)
620 "\e" => '\e', # escape (ESC)
621 "\013" => '\v', # vertical tab (VT)
622 "\000" => '\0', # nul character (NUL)
624 my $chr = ( (exists $es{$cntrl})
626 : sprintf('\%03o', ord($cntrl)) );
627 return "<span class=\"cntrl\">$chr</span>";
630 # Alternatively use unicode control pictures codepoints,
631 # Unicode "printable representation" (PR)
634 my $chr = sprintf('&#%04d;', 0x2400+ord($cntrl));
635 return "<span class=\"cntrl\">$chr</span>";
638 # git may return quoted and escaped filenames
644 my %es = ( # character escape codes, aka escape sequences
645 't' => "\t", # tab (HT, TAB)
646 'n' => "\n", # newline (NL)
647 'r' => "\r", # return (CR)
648 'f' => "\f", # form feed (FF)
649 'b' => "\b", # backspace (BS)
650 'a' => "\a", # alarm (bell) (BEL)
651 'e' => "\e", # escape (ESC)
652 'v' => "\013", # vertical tab (VT)
655 if ($seq =~ m/^[0-7]{1,3}$/) {
656 # octal char sequence
657 return chr(oct($seq));
658 } elsif (exists $es{$seq}) {
659 # C escape sequence, aka character escape code
662 # quoted ordinary character
666 if ($str =~ m/^"(.*)"$/) {
669 $str =~ s/\\([^0-7]|[0-7]{1,3})/unq($1)/eg;
674 # escape tabs (convert tabs to spaces)
678 while ((my $pos = index($line, "\t")) != -1) {
679 if (my $count = (8 - ($pos % 8))) {
680 my $spaces = ' ' x
$count;
681 $line =~ s/\t/$spaces/;
688 sub project_in_list
{
690 my @list = git_get_projects_list
();
691 return @list && scalar(grep { $_->{'path'} eq $project } @list);
694 ## ----------------------------------------------------------------------
695 ## HTML aware string manipulation
700 my $add_len = shift || 10;
702 # allow only $len chars, but don't cut a word if it would fit in $add_len
703 # if it doesn't fit, cut it if it's still longer than the dots we would add
704 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@
]{0,$add_len})(.*)/;
707 if (length($tail) > 4) {
709 $body =~ s/&[^;]*$//; # remove chopped character entities
714 ## ----------------------------------------------------------------------
715 ## functions returning short strings
717 # CSS class for given age value (in seconds)
721 if ($age < 60*60*2) {
723 } elsif ($age < 60*60*24*2) {
730 # convert age in seconds to "nn units ago" string
735 if ($age > 60*60*24*365*2) {
736 $age_str = (int $age/60/60/24/365);
737 $age_str .= " years ago";
738 } elsif ($age > 60*60*24*(365/12)*2) {
739 $age_str = int $age/60/60/24/(365/12);
740 $age_str .= " months ago";
741 } elsif ($age > 60*60*24*7*2) {
742 $age_str = int $age/60/60/24/7;
743 $age_str .= " weeks ago";
744 } elsif ($age > 60*60*24*2) {
745 $age_str = int $age/60/60/24;
746 $age_str .= " days ago";
747 } elsif ($age > 60*60*2) {
748 $age_str = int $age/60/60;
749 $age_str .= " hours ago";
750 } elsif ($age > 60*2) {
751 $age_str = int $age/60;
752 $age_str .= " min ago";
755 $age_str .= " sec ago";
757 $age_str .= " right now";
762 # convert file mode in octal to symbolic file mode string
764 my $mode = oct shift;
766 if (S_ISDIR
($mode & S_IFMT
)) {
768 } elsif (S_ISLNK
($mode)) {
770 } elsif (S_ISREG
($mode)) {
771 # git cares only about the executable bit
772 if ($mode & S_IXUSR
) {
782 # convert file mode in octal to file type string
786 if ($mode !~ m/^[0-7]+$/) {
792 if (S_ISDIR
($mode & S_IFMT
)) {
794 } elsif (S_ISLNK
($mode)) {
796 } elsif (S_ISREG
($mode)) {
803 # convert file mode in octal to file type description string
807 if ($mode !~ m/^[0-7]+$/) {
813 if (S_ISDIR
($mode & S_IFMT
)) {
815 } elsif (S_ISLNK
($mode)) {
817 } elsif (S_ISREG
($mode)) {
818 if ($mode & S_IXUSR
) {
829 ## ----------------------------------------------------------------------
830 ## functions returning short HTML fragments, or transforming HTML fragments
831 ## which don't belong to other sections
833 # format line of commit message.
834 sub format_log_line_html
{
837 $line = esc_html
($line, -nbsp
=>1);
838 if ($line =~ m/([0-9a-fA-F]{8,40})/) {
841 $cgi->a({-href
=> href
(action
=>"object", hash
=>$hash_text),
842 -class => "text"}, $hash_text);
843 $line =~ s/$hash_text/$link/;
848 # format marker of refs pointing to given object
849 sub format_ref_marker
{
850 my ($refs, $id) = @_;
853 if (defined $refs->{$id}) {
854 foreach my $ref (@
{$refs->{$id}}) {
855 my ($type, $name) = qw();
856 # e.g. tags/v2.6.11 or heads/next
857 if ($ref =~ m!^(.*?)s?/(.*)$!) {
865 $markers .= " <span class=\"$type\" title=\"$ref\">" .
866 esc_html
($name) . "</span>";
871 return ' <span class="refs">'. $markers . '</span>';
877 # format, perhaps shortened and with markers, title line
878 sub format_subject_html
{
879 my ($long, $short, $href, $extra) = @_;
880 $extra = '' unless defined($extra);
882 if (length($short) < length($long)) {
883 return $cgi->a({-href
=> $href, -class => "list subject",
884 -title
=> decode_utf8
($long)},
885 esc_html
($short) . $extra);
887 return $cgi->a({-href
=> $href, -class => "list subject"},
888 esc_html
($long) . $extra);
892 # format patch (diff) line (rather not to be used for diff headers)
893 sub format_diff_line
{
895 my ($from, $to) = @_;
896 my $char = substr($line, 0, 1);
902 $diff_class = " add";
903 } elsif ($char eq "-") {
904 $diff_class = " rem";
905 } elsif ($char eq "@") {
906 $diff_class = " chunk_header";
907 } elsif ($char eq "\\") {
908 $diff_class = " incomplete";
910 $line = untabify
($line);
911 if ($from && $to && $line =~ m/^\@{2} /) {
912 my ($from_text, $from_start, $from_lines, $to_text, $to_start, $to_lines, $section) =
913 $line =~ m/^\@{2} (-(\d+)(?:,(\d+))?) (\+(\d+)(?:,(\d+))?) \@{2}(.*)$/;
915 $from_lines = 0 unless defined $from_lines;
916 $to_lines = 0 unless defined $to_lines;
918 if ($from->{'href'}) {
919 $from_text = $cgi->a({-href
=>"$from->{'href'}#l$from_start",
920 -class=>"list"}, $from_text);
923 $to_text = $cgi->a({-href
=>"$to->{'href'}#l$to_start",
924 -class=>"list"}, $to_text);
926 $line = "<span class=\"chunk_info\">@@ $from_text $to_text @@</span>" .
927 "<span class=\"section\">" . esc_html
($section, -nbsp
=>1) . "</span>";
928 return "<div class=\"diff$diff_class\">$line</div>\n";
930 return "<div class=\"diff$diff_class\">" . esc_html
($line, -nbsp
=>1) . "</div>\n";
933 ## ----------------------------------------------------------------------
934 ## git utility subroutines, invoking git commands
936 # returns path to the core git executable and the --git-dir parameter as list
938 return $GIT, '--git-dir='.$git_dir;
941 # returns path to the core git executable and the --git-dir parameter as string
943 return join(' ', git_cmd
());
946 # get HEAD ref of given project as hash
947 sub git_get_head_hash
{
949 my $o_git_dir = $git_dir;
951 $git_dir = "$projectroot/$project";
952 if (open my $fd, "-|", git_cmd
(), "rev-parse", "--verify", "HEAD") {
955 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
959 if (defined $o_git_dir) {
960 $git_dir = $o_git_dir;
965 # get type of given object
969 open my $fd, "-|", git_cmd
(), "cat-file", '-t', $hash or return;
976 sub git_get_project_config
{
977 my ($key, $type) = @_;
979 return unless ($key);
980 $key =~ s/^gitweb\.//;
981 return if ($key =~ m/\W/);
983 my @x = (git_cmd
(), 'config');
984 if (defined $type) { push @x, $type; }
986 push @x, "gitweb.$key";
992 # get hash of given path at given ref
993 sub git_get_hash_by_path
{
995 my $path = shift || return undef;
1000 open my $fd, "-|", git_cmd
(), "ls-tree", $base, "--", $path
1001 or die_error
(undef, "Open git-ls-tree failed");
1003 close $fd or return undef;
1005 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1006 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/;
1007 if (defined $type && $type ne $2) {
1008 # type doesn't match
1014 ## ......................................................................
1015 ## git utility functions, directly accessing git repository
1017 sub git_get_project_description
{
1020 open my $fd, "$projectroot/$path/description" or return undef;
1027 sub git_get_project_url_list
{
1030 open my $fd, "$projectroot/$path/cloneurl" or return;
1031 my @git_project_url_list = map { chomp; $_ } <$fd>;
1034 return wantarray ?
@git_project_url_list : \
@git_project_url_list;
1037 sub git_get_projects_list
{
1042 $filter =~ s/\.git$//;
1044 if (-d
$projects_list) {
1045 # search in directory
1046 my $dir = $projects_list . ($filter ?
"/$filter" : '');
1047 # remove the trailing "/"
1049 my $pfxlen = length("$dir");
1051 my ($check_forks) = gitweb_check_feature
('forks');
1054 follow_fast
=> 1, # follow symbolic links
1055 dangling_symlinks
=> 0, # ignore dangling symlinks, silently
1057 # skip project-list toplevel, if we get it.
1058 return if (m!^[/.]$!);
1059 # only directories can be git repositories
1060 return unless (-d
$_);
1062 my $subdir = substr($File::Find
::name
, $pfxlen + 1);
1063 # we check related file in $projectroot
1064 if ($check_forks and $subdir =~ m
#/.#) {
1065 $File::Find
::prune
= 1;
1066 } elsif (check_export_ok
("$projectroot/$filter/$subdir")) {
1067 push @list, { path
=> ($filter ?
"$filter/" : '') . $subdir };
1068 $File::Find
::prune
= 1;
1073 } elsif (-f
$projects_list) {
1074 # read from file(url-encoded):
1075 # 'git%2Fgit.git Linus+Torvalds'
1076 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
1077 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
1078 open my ($fd), $projects_list or return;
1079 while (my $line = <$fd>) {
1081 my ($path, $owner) = split ' ', $line;
1082 $path = unescape
($path);
1083 $owner = unescape
($owner);
1084 if (!defined $path) {
1087 if ($filter ne '') {
1088 # looking for forks;
1089 my $pfx = substr($path, 0, length($filter));
1090 if ($pfx ne $filter) {
1093 my $sfx = substr($path, length($filter));
1094 if ($sfx !~ /^\/.*\
.git
$/) {
1098 if (check_export_ok
("$projectroot/$path")) {
1101 owner
=> decode_utf8
($owner),
1108 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
1112 sub git_get_project_owner
{
1113 my $project = shift;
1116 return undef unless $project;
1118 # read from file (url-encoded):
1119 # 'git%2Fgit.git Linus+Torvalds'
1120 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
1121 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
1122 if (-f
$projects_list) {
1123 open (my $fd , $projects_list);
1124 while (my $line = <$fd>) {
1126 my ($pr, $ow) = split ' ', $line;
1127 $pr = unescape
($pr);
1128 $ow = unescape
($ow);
1129 if ($pr eq $project) {
1130 $owner = decode_utf8
($ow);
1136 if (!defined $owner) {
1137 $owner = get_file_owner
("$projectroot/$project");
1143 sub git_get_last_activity
{
1147 $git_dir = "$projectroot/$path";
1148 open($fd, "-|", git_cmd
(), 'for-each-ref',
1149 '--format=%(committer)',
1150 '--sort=-committerdate',
1152 'refs/heads') or return;
1153 my $most_recent = <$fd>;
1154 close $fd or return;
1155 if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
1157 my $age = time - $timestamp;
1158 return ($age, age_string
($age));
1162 sub git_get_references
{
1163 my $type = shift || "";
1165 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
1166 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
1167 open my $fd, "-|", git_cmd
(), "show-ref", "--dereference",
1168 ($type ?
("--", "refs/$type") : ()) # use -- <pattern> if $type
1171 while (my $line = <$fd>) {
1173 if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)!) {
1174 if (defined $refs{$1}) {
1175 push @
{$refs{$1}}, $2;
1181 close $fd or return;
1185 sub git_get_rev_name_tags
{
1186 my $hash = shift || return undef;
1188 open my $fd, "-|", git_cmd
(), "name-rev", "--tags", $hash
1190 my $name_rev = <$fd>;
1193 if ($name_rev =~ m
|^$hash tags
/(.*)$|) {
1196 # catches also '$hash undefined' output
1201 ## ----------------------------------------------------------------------
1202 ## parse to hash functions
1206 my $tz = shift || "-0000";
1209 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
1210 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
1211 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
1212 $date{'hour'} = $hour;
1213 $date{'minute'} = $min;
1214 $date{'mday'} = $mday;
1215 $date{'day'} = $days[$wday];
1216 $date{'month'} = $months[$mon];
1217 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000",
1218 $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
1219 $date{'mday-time'} = sprintf "%d %s %02d:%02d",
1220 $mday, $months[$mon], $hour ,$min;
1221 $date{'iso-8601'} = sprintf "%04d-%02d-%02dT%02d:%02d:%02dZ",
1222 1900+$year, $mon, $mday, $hour ,$min, $sec;
1224 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
1225 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
1226 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
1227 $date{'hour_local'} = $hour;
1228 $date{'minute_local'} = $min;
1229 $date{'tz_local'} = $tz;
1230 $date{'iso-tz'} = sprintf("%04d-%02d-%02d %02d:%02d:%02d %s",
1231 1900+$year, $mon+1, $mday,
1232 $hour, $min, $sec, $tz);
1241 open my $fd, "-|", git_cmd
(), "cat-file", "tag", $tag_id or return;
1242 $tag{'id'} = $tag_id;
1243 while (my $line = <$fd>) {
1245 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
1246 $tag{'object'} = $1;
1247 } elsif ($line =~ m/^type (.+)$/) {
1249 } elsif ($line =~ m/^tag (.+)$/) {
1251 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
1252 $tag{'author'} = $1;
1255 } elsif ($line =~ m/--BEGIN/) {
1256 push @comment, $line;
1258 } elsif ($line eq "") {
1262 push @comment, <$fd>;
1263 $tag{'comment'} = \
@comment;
1264 close $fd or return;
1265 if (!defined $tag{'name'}) {
1271 sub parse_commit_text
{
1272 my ($commit_text, $withparents) = @_;
1273 my @commit_lines = split '\n', $commit_text;
1276 pop @commit_lines; # Remove '\0'
1278 my $header = shift @commit_lines;
1279 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
1282 ($co{'id'}, my @parents) = split ' ', $header;
1283 while (my $line = shift @commit_lines) {
1284 last if $line eq "\n";
1285 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
1287 } elsif ((!defined $withparents) && ($line =~ m/^parent ([0-9a-fA-F]{40})$/)) {
1289 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
1291 $co{'author_epoch'} = $2;
1292 $co{'author_tz'} = $3;
1293 if ($co{'author'} =~ m/^([^<]+) <([^>]*)>/) {
1294 $co{'author_name'} = $1;
1295 $co{'author_email'} = $2;
1297 $co{'author_name'} = $co{'author'};
1299 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
1300 $co{'committer'} = $1;
1301 $co{'committer_epoch'} = $2;
1302 $co{'committer_tz'} = $3;
1303 $co{'committer_name'} = $co{'committer'};
1304 if ($co{'committer'} =~ m/^([^<]+) <([^>]*)>/) {
1305 $co{'committer_name'} = $1;
1306 $co{'committer_email'} = $2;
1308 $co{'committer_name'} = $co{'committer'};
1312 if (!defined $co{'tree'}) {
1315 $co{'parents'} = \
@parents;
1316 $co{'parent'} = $parents[0];
1318 foreach my $title (@commit_lines) {
1321 $co{'title'} = chop_str
($title, 80, 5);
1322 # remove leading stuff of merges to make the interesting part visible
1323 if (length($title) > 50) {
1324 $title =~ s/^Automatic //;
1325 $title =~ s/^merge (of|with) /Merge ... /i;
1326 if (length($title) > 50) {
1327 $title =~ s/(http|rsync):\/\///;
1329 if (length($title) > 50) {
1330 $title =~ s/(master|www|rsync)\.//;
1332 if (length($title) > 50) {
1333 $title =~ s/kernel.org:?//;
1335 if (length($title) > 50) {
1336 $title =~ s/\/pub\/scm//;
1339 $co{'title_short'} = chop_str
($title, 50, 5);
1343 if ($co{'title'} eq "") {
1344 $co{'title'} = $co{'title_short'} = '(no commit message)';
1346 # remove added spaces
1347 foreach my $line (@commit_lines) {
1350 $co{'comment'} = \
@commit_lines;
1352 my $age = time - $co{'committer_epoch'};
1354 $co{'age_string'} = age_string
($age);
1355 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
1356 if ($age > 60*60*24*7*2) {
1357 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
1358 $co{'age_string_age'} = $co{'age_string'};
1360 $co{'age_string_date'} = $co{'age_string'};
1361 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
1367 my ($commit_id) = @_;
1372 open my $fd, "-|", git_cmd
(), "rev-list",
1378 or die_error
(undef, "Open git-rev-list failed");
1379 %co = parse_commit_text
(<$fd>, 1);
1386 my ($commit_id, $maxcount, $skip, $arg, $filename) = @_;
1394 open my $fd, "-|", git_cmd
(), "rev-list",
1396 ($arg ?
($arg) : ()),
1397 ("--max-count=" . $maxcount),
1398 ("--skip=" . $skip),
1401 ($filename ?
($filename) : ())
1402 or die_error
(undef, "Open git-rev-list failed");
1403 while (my $line = <$fd>) {
1404 my %co = parse_commit_text
($line);
1409 return wantarray ?
@cos : \
@cos;
1412 # parse ref from ref_file, given by ref_id, with given type
1414 my $ref_file = shift;
1416 my $type = shift || git_get_type
($ref_id);
1419 $ref_item{'type'} = $type;
1420 $ref_item{'id'} = $ref_id;
1421 $ref_item{'epoch'} = 0;
1422 $ref_item{'age'} = "unknown";
1423 if ($type eq "tag") {
1424 my %tag = parse_tag
($ref_id);
1425 $ref_item{'comment'} = $tag{'comment'};
1426 if ($tag{'type'} eq "commit") {
1427 my %co = parse_commit
($tag{'object'});
1428 $ref_item{'epoch'} = $co{'committer_epoch'};
1429 $ref_item{'age'} = $co{'age_string'};
1430 } elsif (defined($tag{'epoch'})) {
1431 my $age = time - $tag{'epoch'};
1432 $ref_item{'epoch'} = $tag{'epoch'};
1433 $ref_item{'age'} = age_string
($age);
1435 $ref_item{'reftype'} = $tag{'type'};
1436 $ref_item{'name'} = $tag{'name'};
1437 $ref_item{'refid'} = $tag{'object'};
1438 } elsif ($type eq "commit"){
1439 my %co = parse_commit
($ref_id);
1440 $ref_item{'reftype'} = "commit";
1441 $ref_item{'name'} = $ref_file;
1442 $ref_item{'title'} = $co{'title'};
1443 $ref_item{'refid'} = $ref_id;
1444 $ref_item{'epoch'} = $co{'committer_epoch'};
1445 $ref_item{'age'} = $co{'age_string'};
1447 $ref_item{'reftype'} = $type;
1448 $ref_item{'name'} = $ref_file;
1449 $ref_item{'refid'} = $ref_id;
1455 # parse line of git-diff-tree "raw" output
1456 sub parse_difftree_raw_line
{
1460 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1461 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1462 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
1463 $res{'from_mode'} = $1;
1464 $res{'to_mode'} = $2;
1465 $res{'from_id'} = $3;
1467 $res{'status'} = $5;
1468 $res{'similarity'} = $6;
1469 if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
1470 ($res{'from_file'}, $res{'to_file'}) = map { unquote
($_) } split("\t", $7);
1472 $res{'file'} = unquote
($7);
1475 # 'c512b523472485aef4fff9e57b229d9d243c967f'
1476 elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
1477 $res{'commit'} = $1;
1480 return wantarray ?
%res : \
%res;
1483 # parse line of git-ls-tree output
1484 sub parse_ls_tree_line
($;%) {
1489 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1490 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/s;
1498 $res{'name'} = unquote
($4);
1501 return wantarray ?
%res : \
%res;
1504 ## ......................................................................
1505 ## parse to array of hashes functions
1507 sub git_get_heads_list
{
1511 open my $fd, '-|', git_cmd
(), 'for-each-ref',
1512 ($limit ?
'--count='.($limit+1) : ()), '--sort=-committerdate',
1513 '--format=%(objectname) %(refname) %(subject)%00%(committer)',
1516 while (my $line = <$fd>) {
1520 my ($refinfo, $committerinfo) = split(/\0/, $line);
1521 my ($hash, $name, $title) = split(' ', $refinfo, 3);
1522 my ($committer, $epoch, $tz) =
1523 ($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
1524 $name =~ s!^refs/heads/!!;
1526 $ref_item{'name'} = $name;
1527 $ref_item{'id'} = $hash;
1528 $ref_item{'title'} = $title || '(no commit message)';
1529 $ref_item{'epoch'} = $epoch;
1531 $ref_item{'age'} = age_string
(time - $ref_item{'epoch'});
1533 $ref_item{'age'} = "unknown";
1536 push @headslist, \
%ref_item;
1540 return wantarray ?
@headslist : \
@headslist;
1543 sub git_get_tags_list
{
1547 open my $fd, '-|', git_cmd
(), 'for-each-ref',
1548 ($limit ?
'--count='.($limit+1) : ()), '--sort=-creatordate',
1549 '--format=%(objectname) %(objecttype) %(refname) '.
1550 '%(*objectname) %(*objecttype) %(subject)%00%(creator)',
1553 while (my $line = <$fd>) {
1557 my ($refinfo, $creatorinfo) = split(/\0/, $line);
1558 my ($id, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);
1559 my ($creator, $epoch, $tz) =
1560 ($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);
1561 $name =~ s!^refs/tags/!!;
1563 $ref_item{'type'} = $type;
1564 $ref_item{'id'} = $id;
1565 $ref_item{'name'} = $name;
1566 if ($type eq "tag") {
1567 $ref_item{'subject'} = $title;
1568 $ref_item{'reftype'} = $reftype;
1569 $ref_item{'refid'} = $refid;
1571 $ref_item{'reftype'} = $type;
1572 $ref_item{'refid'} = $id;
1575 if ($type eq "tag" || $type eq "commit") {
1576 $ref_item{'epoch'} = $epoch;
1578 $ref_item{'age'} = age_string
(time - $ref_item{'epoch'});
1580 $ref_item{'age'} = "unknown";
1584 push @tagslist, \
%ref_item;
1588 return wantarray ?
@tagslist : \
@tagslist;
1591 ## ----------------------------------------------------------------------
1592 ## filesystem-related functions
1594 sub get_file_owner
{
1597 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
1598 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
1599 if (!defined $gcos) {
1603 $owner =~ s/[,;].*$//;
1604 return decode_utf8
($owner);
1607 ## ......................................................................
1608 ## mimetype related functions
1610 sub mimetype_guess_file
{
1611 my $filename = shift;
1612 my $mimemap = shift;
1613 -r
$mimemap or return undef;
1616 open(MIME
, $mimemap) or return undef;
1618 next if m/^#/; # skip comments
1619 my ($mime, $exts) = split(/\t+/);
1620 if (defined $exts) {
1621 my @exts = split(/\s+/, $exts);
1622 foreach my $ext (@exts) {
1623 $mimemap{$ext} = $mime;
1629 $filename =~ /\.([^.]*)$/;
1630 return $mimemap{$1};
1633 sub mimetype_guess
{
1634 my $filename = shift;
1636 $filename =~ /\./ or return undef;
1638 if ($mimetypes_file) {
1639 my $file = $mimetypes_file;
1640 if ($file !~ m!^/!) { # if it is relative path
1641 # it is relative to project
1642 $file = "$projectroot/$project/$file";
1644 $mime = mimetype_guess_file
($filename, $file);
1646 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
1652 my $filename = shift;
1655 my $mime = mimetype_guess
($filename);
1656 $mime and return $mime;
1660 return $default_blob_plain_mimetype unless $fd;
1663 return 'text/plain' .
1664 ($default_text_plain_charset ?
'; charset='.$default_text_plain_charset : '');
1665 } elsif (! $filename) {
1666 return 'application/octet-stream';
1667 } elsif ($filename =~ m/\.png$/i) {
1669 } elsif ($filename =~ m/\.gif$/i) {
1671 } elsif ($filename =~ m/\.jpe?g$/i) {
1672 return 'image/jpeg';
1674 return 'application/octet-stream';
1678 ## ======================================================================
1679 ## functions printing HTML: header, footer, error page
1681 sub git_header_html
{
1682 my $status = shift || "200 OK";
1683 my $expires = shift;
1685 my $title = "$site_name";
1686 if (defined $project) {
1687 $title .= " - " . decode_utf8
($project);
1688 if (defined $action) {
1689 $title .= "/$action";
1690 if (defined $file_name) {
1691 $title .= " - " . esc_path
($file_name);
1692 if ($action eq "tree" && $file_name !~ m
|/$|) {
1699 # require explicit support from the UA if we are to send the page as
1700 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
1701 # we have to do this because MSIE sometimes globs '*/*', pretending to
1702 # support xhtml+xml but choking when it gets what it asked for.
1703 if (defined $cgi->http('HTTP_ACCEPT') &&
1704 $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ &&
1705 $cgi->Accept('application/xhtml+xml') != 0) {
1706 $content_type = 'application/xhtml+xml';
1708 $content_type = 'text/html';
1710 print $cgi->header(-type
=>$content_type, -charset
=> 'utf-8',
1711 -status
=> $status, -expires
=> $expires);
1712 my $mod_perl_version = $ENV{'MOD_PERL'} ?
" $ENV{'MOD_PERL'}" : '';
1714 <?xml version="1.0" encoding="utf-8"?>
1715 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1716 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
1717 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
1718 <!-- git core binaries version $git_version -->
1720 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
1721 <meta name="generator" content="gitweb/$version git/$git_version$mod_perl_version"/>
1722 <meta name="robots" content="index, nofollow"/>
1723 <title>$title</title>
1725 # print out each stylesheet that exist
1726 if (defined $stylesheet) {
1727 #provides backwards capability for those people who define style sheet in a config file
1728 print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
1730 foreach my $stylesheet (@stylesheets) {
1731 next unless $stylesheet;
1732 print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
1735 if (defined $project) {
1736 printf('<link rel="alternate" title="%s log RSS feed" '.
1737 'href="%s" type="application/rss+xml" />'."\n",
1738 esc_param
($project), href
(action
=>"rss"));
1739 printf('<link rel="alternate" title="%s log Atom feed" '.
1740 'href="%s" type="application/atom+xml" />'."\n",
1741 esc_param
($project), href
(action
=>"atom"));
1743 printf('<link rel="alternate" title="%s projects list" '.
1744 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
1745 $site_name, href
(project
=>undef, action
=>"project_index"));
1746 printf('<link rel="alternate" title="%s projects feeds" '.
1747 'href="%s" type="text/x-opml"/>'."\n",
1748 $site_name, href
(project
=>undef, action
=>"opml"));
1750 if (defined $favicon) {
1751 print qq(<link rel
="shortcut icon" href
="$favicon" type
="image/png"/>\n);
1757 if (-f
$site_header) {
1758 open (my $fd, $site_header);
1763 print "<div class=\"page_header\">\n" .
1764 $cgi->a({-href
=> esc_url
($logo_url),
1765 -title
=> $logo_label},
1766 qq(<img src
="$logo" width
="72" height
="27" alt
="git" class="logo"/>));
1767 print $cgi->a({-href
=> esc_url
($home_link)}, $home_link_str) . " / ";
1768 if (defined $project) {
1769 print $cgi->a({-href
=> href
(action
=>"summary")}, esc_html
($project));
1770 if (defined $action) {
1775 my ($have_search) = gitweb_check_feature
('search');
1776 if ((defined $project) && ($have_search)) {
1777 if (!defined $searchtext) {
1781 if (defined $hash_base) {
1782 $search_hash = $hash_base;
1783 } elsif (defined $hash) {
1784 $search_hash = $hash;
1786 $search_hash = "HEAD";
1788 $cgi->param("a", "search");
1789 $cgi->param("h", $search_hash);
1790 $cgi->param("p", $project);
1791 print $cgi->startform(-method
=> "get", -action
=> $my_uri) .
1792 "<div class=\"search\">\n" .
1793 $cgi->hidden(-name
=> "p") . "\n" .
1794 $cgi->hidden(-name
=> "a") . "\n" .
1795 $cgi->hidden(-name
=> "h") . "\n" .
1796 $cgi->popup_menu(-name
=> 'st', -default => 'commit',
1797 -values => ['commit', 'author', 'committer', 'pickaxe']) .
1798 $cgi->sup($cgi->a({-href
=> href
(action
=>"search_help")}, "?")) .
1800 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
1802 $cgi->end_form() . "\n";
1807 sub git_footer_html
{
1808 print "<div class=\"page_footer\">\n";
1809 if (defined $project) {
1810 my $descr = git_get_project_description
($project);
1811 if (defined $descr) {
1812 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
1814 print $cgi->a({-href
=> href
(action
=>"rss"),
1815 -class => "rss_logo"}, "RSS") . " ";
1816 print $cgi->a({-href
=> href
(action
=>"atom"),
1817 -class => "rss_logo"}, "Atom") . "\n";
1819 print $cgi->a({-href
=> href
(project
=>undef, action
=>"opml"),
1820 -class => "rss_logo"}, "OPML") . " ";
1821 print $cgi->a({-href
=> href
(project
=>undef, action
=>"project_index"),
1822 -class => "rss_logo"}, "TXT") . "\n";
1826 if (-f
$site_footer) {
1827 open (my $fd, $site_footer);
1837 my $status = shift || "403 Forbidden";
1838 my $error = shift || "Malformed query, file missing or permission denied";
1840 git_header_html
($status);
1842 <div class="page_body">
1852 ## ----------------------------------------------------------------------
1853 ## functions printing or outputting HTML: navigation
1855 sub git_print_page_nav
{
1856 my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
1857 $extra = '' if !defined $extra; # pager or formats
1859 my @navs = qw(summary shortlog log commit commitdiff tree);
1861 @navs = grep { $_ ne $suppress } @navs;
1864 my %arg = map { $_ => {action
=>$_} } @navs;
1865 if (defined $head) {
1866 for (qw(commit commitdiff)) {
1867 $arg{$_}{hash
} = $head;
1869 if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
1870 for (qw(shortlog log)) {
1871 $arg{$_}{hash
} = $head;
1875 $arg{tree
}{hash
} = $treehead if defined $treehead;
1876 $arg{tree
}{hash_base
} = $treebase if defined $treebase;
1878 print "<div class=\"page_nav\">\n" .
1880 map { $_ eq $current ?
1881 $_ : $cgi->a({-href
=> href
(%{$arg{$_}})}, "$_")
1883 print "<br/>\n$extra<br/>\n" .
1887 sub format_paging_nav
{
1888 my ($action, $hash, $head, $page, $nrevs) = @_;
1892 if ($hash ne $head || $page) {
1893 $paging_nav .= $cgi->a({-href
=> href
(action
=>$action)}, "HEAD");
1895 $paging_nav .= "HEAD";
1899 $paging_nav .= " ⋅ " .
1900 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page-1),
1901 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1903 $paging_nav .= " ⋅ prev";
1906 if ($nrevs >= (100 * ($page+1)-1)) {
1907 $paging_nav .= " ⋅ " .
1908 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page+1),
1909 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1911 $paging_nav .= " ⋅ next";
1917 ## ......................................................................
1918 ## functions printing or outputting HTML: div
1920 sub git_print_header_div
{
1921 my ($action, $title, $hash, $hash_base) = @_;
1924 $args{action
} = $action;
1925 $args{hash
} = $hash if $hash;
1926 $args{hash_base
} = $hash_base if $hash_base;
1928 print "<div class=\"header\">\n" .
1929 $cgi->a({-href
=> href
(%args), -class => "title"},
1930 $title ?
$title : $action) .
1934 #sub git_print_authorship (\%) {
1935 sub git_print_authorship
{
1938 my %ad = parse_date
($co->{'author_epoch'}, $co->{'author_tz'});
1939 print "<div class=\"author_date\">" .
1940 esc_html
($co->{'author_name'}) .
1942 if ($ad{'hour_local'} < 6) {
1943 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
1944 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1946 printf(" (%02d:%02d %s)",
1947 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1952 sub git_print_page_path
{
1958 print "<div class=\"page_path\">";
1959 print $cgi->a({-href
=> href
(action
=>"tree", hash_base
=>$hb),
1960 -title
=> 'tree root'}, decode_utf8
("[$project]"));
1962 if (defined $name) {
1963 my @dirname = split '/', $name;
1964 my $basename = pop @dirname;
1967 foreach my $dir (@dirname) {
1968 $fullname .= ($fullname ?
'/' : '') . $dir;
1969 print $cgi->a({-href
=> href
(action
=>"tree", file_name
=>$fullname,
1971 -title
=> $fullname}, esc_path
($dir));
1974 if (defined $type && $type eq 'blob') {
1975 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name,
1977 -title
=> $name}, esc_path
($basename));
1978 } elsif (defined $type && $type eq 'tree') {
1979 print $cgi->a({-href
=> href
(action
=>"tree", file_name
=>$file_name,
1981 -title
=> $name}, esc_path
($basename));
1984 print esc_path
($basename);
1987 print "<br/></div>\n";
1990 # sub git_print_log (\@;%) {
1991 sub git_print_log
($;%) {
1995 if ($opts{'-remove_title'}) {
1996 # remove title, i.e. first line of log
1999 # remove leading empty lines
2000 while (defined $log->[0] && $log->[0] eq "") {
2007 foreach my $line (@
$log) {
2008 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2011 if (! $opts{'-remove_signoff'}) {
2012 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
2015 # remove signoff lines
2022 # print only one empty line
2023 # do not print empty line after signoff
2025 next if ($empty || $signoff);
2031 print format_log_line_html
($line) . "<br/>\n";
2034 if ($opts{'-final_empty_line'}) {
2035 # end with single empty line
2036 print "<br/>\n" unless $empty;
2040 # return link target (what link points to)
2041 sub git_get_link_target
{
2046 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
2050 $link_target = <$fd>;
2055 return $link_target;
2058 # given link target, and the directory (basedir) the link is in,
2059 # return target of link relative to top directory (top tree);
2060 # return undef if it is not possible (including absolute links).
2061 sub normalize_link_target
{
2062 my ($link_target, $basedir, $hash_base) = @_;
2064 # we can normalize symlink target only if $hash_base is provided
2065 return unless $hash_base;
2067 # absolute symlinks (beginning with '/') cannot be normalized
2068 return if (substr($link_target, 0, 1) eq '/');
2070 # normalize link target to path from top (root) tree (dir)
2073 $path = $basedir . '/' . $link_target;
2075 # we are in top (root) tree (dir)
2076 $path = $link_target;
2079 # remove //, /./, and /../
2081 foreach my $part (split('/', $path)) {
2082 # discard '.' and ''
2083 next if (!$part || $part eq '.');
2085 if ($part eq '..') {
2089 # link leads outside repository (outside top dir)
2093 push @path_parts, $part;
2096 $path = join('/', @path_parts);
2101 # print tree entry (row of git_tree), but without encompassing <tr> element
2102 sub git_print_tree_entry
{
2103 my ($t, $basedir, $hash_base, $have_blame) = @_;
2106 $base_key{'hash_base'} = $hash_base if defined $hash_base;
2108 # The format of a table row is: mode list link. Where mode is
2109 # the mode of the entry, list is the name of the entry, an href,
2110 # and link is the action links of the entry.
2112 print "<td class=\"mode\">" . mode_str
($t->{'mode'}) . "</td>\n";
2113 if ($t->{'type'} eq "blob") {
2114 print "<td class=\"list\">" .
2115 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t->{'hash'},
2116 file_name
=>"$basedir$t->{'name'}", %base_key),
2117 -class => "list"}, esc_path
($t->{'name'}));
2118 if (S_ISLNK
(oct $t->{'mode'})) {
2119 my $link_target = git_get_link_target
($t->{'hash'});
2121 my $norm_target = normalize_link_target
($link_target, $basedir, $hash_base);
2122 if (defined $norm_target) {
2124 $cgi->a({-href
=> href
(action
=>"object", hash_base
=>$hash_base,
2125 file_name
=>$norm_target),
2126 -title
=> $norm_target}, esc_path
($link_target));
2128 print " -> " . esc_path
($link_target);
2133 print "<td class=\"link\">";
2134 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t->{'hash'},
2135 file_name
=>"$basedir$t->{'name'}", %base_key)},
2139 $cgi->a({-href
=> href
(action
=>"blame", hash
=>$t->{'hash'},
2140 file_name
=>"$basedir$t->{'name'}", %base_key)},
2143 if (defined $hash_base) {
2145 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2146 hash
=>$t->{'hash'}, file_name
=>"$basedir$t->{'name'}")},
2150 $cgi->a({-href
=> href
(action
=>"blob_plain", hash_base
=>$hash_base,
2151 file_name
=>"$basedir$t->{'name'}")},
2155 } elsif ($t->{'type'} eq "tree") {
2156 print "<td class=\"list\">";
2157 print $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t->{'hash'},
2158 file_name
=>"$basedir$t->{'name'}", %base_key)},
2159 esc_path
($t->{'name'}));
2161 print "<td class=\"link\">";
2162 print $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t->{'hash'},
2163 file_name
=>"$basedir$t->{'name'}", %base_key)},
2165 if (defined $hash_base) {
2167 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2168 file_name
=>"$basedir$t->{'name'}")},
2175 ## ......................................................................
2176 ## functions printing large fragments of HTML
2178 sub git_difftree_body
{
2179 my ($difftree, $hash, $parent) = @_;
2180 my ($have_blame) = gitweb_check_feature
('blame');
2181 print "<div class=\"list_head\">\n";
2182 if ($#{$difftree} > 10) {
2183 print(($#{$difftree} + 1) . " files changed:\n");
2187 print "<table class=\"diff_tree\">\n";
2190 foreach my $line (@
{$difftree}) {
2191 my %diff = parse_difftree_raw_line
($line);
2194 print "<tr class=\"dark\">\n";
2196 print "<tr class=\"light\">\n";
2200 my ($to_mode_oct, $to_mode_str, $to_file_type);
2201 my ($from_mode_oct, $from_mode_str, $from_file_type);
2202 if ($diff{'to_mode'} ne ('0' x
6)) {
2203 $to_mode_oct = oct $diff{'to_mode'};
2204 if (S_ISREG
($to_mode_oct)) { # only for regular file
2205 $to_mode_str = sprintf("%04o", $to_mode_oct & 0777); # permission bits
2207 $to_file_type = file_type
($diff{'to_mode'});
2209 if ($diff{'from_mode'} ne ('0' x
6)) {
2210 $from_mode_oct = oct $diff{'from_mode'};
2211 if (S_ISREG
($to_mode_oct)) { # only for regular file
2212 $from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
2214 $from_file_type = file_type
($diff{'from_mode'});
2217 if ($diff{'status'} eq "A") { # created
2218 my $mode_chng = "<span class=\"file_status new\">[new $to_file_type";
2219 $mode_chng .= " with mode: $to_mode_str" if $to_mode_str;
2220 $mode_chng .= "]</span>";
2222 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2223 hash_base
=>$hash, file_name
=>$diff{'file'}),
2224 -class => "list"}, esc_path
($diff{'file'}));
2226 print "<td>$mode_chng</td>\n";
2227 print "<td class=\"link\">";
2228 if ($action eq 'commitdiff') {
2231 print $cgi->a({-href
=> "#patch$patchno"}, "patch");
2234 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2235 hash_base
=>$hash, file_name
=>$diff{'file'})},
2239 } elsif ($diff{'status'} eq "D") { # deleted
2240 my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
2242 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
2243 hash_base
=>$parent, file_name
=>$diff{'file'}),
2244 -class => "list"}, esc_path
($diff{'file'}));
2246 print "<td>$mode_chng</td>\n";
2247 print "<td class=\"link\">";
2248 if ($action eq 'commitdiff') {
2251 print $cgi->a({-href
=> "#patch$patchno"}, "patch");
2254 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
2255 hash_base
=>$parent, file_name
=>$diff{'file'})},
2258 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$parent,
2259 file_name
=>$diff{'file'})},
2262 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$parent,
2263 file_name
=>$diff{'file'})},
2267 } elsif ($diff{'status'} eq "M" || $diff{'status'} eq "T") { # modified, or type changed
2268 my $mode_chnge = "";
2269 if ($diff{'from_mode'} != $diff{'to_mode'}) {
2270 $mode_chnge = "<span class=\"file_status mode_chnge\">[changed";
2271 if ($from_file_type ne $to_file_type) {
2272 $mode_chnge .= " from $from_file_type to $to_file_type";
2274 if (($from_mode_oct & 0777) != ($to_mode_oct & 0777)) {
2275 if ($from_mode_str && $to_mode_str) {
2276 $mode_chnge .= " mode: $from_mode_str->$to_mode_str";
2277 } elsif ($to_mode_str) {
2278 $mode_chnge .= " mode: $to_mode_str";
2281 $mode_chnge .= "]</span>\n";
2284 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2285 hash_base
=>$hash, file_name
=>$diff{'file'}),
2286 -class => "list"}, esc_path
($diff{'file'}));
2288 print "<td>$mode_chnge</td>\n";
2289 print "<td class=\"link\">";
2290 if ($action eq 'commitdiff') {
2293 print $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2295 } elsif ($diff{'to_id'} ne $diff{'from_id'}) {
2296 # "commit" view and modified file (not onlu mode changed)
2297 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2298 hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
2299 hash_base
=>$hash, hash_parent_base
=>$parent,
2300 file_name
=>$diff{'file'})},
2304 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2305 hash_base
=>$hash, file_name
=>$diff{'file'})},
2308 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash,
2309 file_name
=>$diff{'file'})},
2312 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash,
2313 file_name
=>$diff{'file'})},
2317 } elsif ($diff{'status'} eq "R" || $diff{'status'} eq "C") { # renamed or copied
2318 my %status_name = ('R' => 'moved', 'C' => 'copied');
2319 my $nstatus = $status_name{$diff{'status'}};
2321 if ($diff{'from_mode'} != $diff{'to_mode'}) {
2322 # mode also for directories, so we cannot use $to_mode_str
2323 $mode_chng = sprintf(", mode: %04o", $to_mode_oct & 0777);
2326 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
2327 hash
=>$diff{'to_id'}, file_name
=>$diff{'to_file'}),
2328 -class => "list"}, esc_path
($diff{'to_file'})) . "</td>\n" .
2329 "<td><span class=\"file_status $nstatus\">[$nstatus from " .
2330 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$parent,
2331 hash
=>$diff{'from_id'}, file_name
=>$diff{'from_file'}),
2332 -class => "list"}, esc_path
($diff{'from_file'})) .
2333 " with " . (int $diff{'similarity'}) . "% similarity$mode_chng]</span></td>\n" .
2334 "<td class=\"link\">";
2335 if ($action eq 'commitdiff') {
2338 print $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2340 } elsif ($diff{'to_id'} ne $diff{'from_id'}) {
2341 # "commit" view and modified file (not only pure rename or copy)
2342 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2343 hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
2344 hash_base
=>$hash, hash_parent_base
=>$parent,
2345 file_name
=>$diff{'to_file'}, file_parent
=>$diff{'from_file'})},
2349 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2350 hash_base
=>$parent, file_name
=>$diff{'to_file'})},
2353 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash,
2354 file_name
=>$diff{'to_file'})},
2357 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash,
2358 file_name
=>$diff{'to_file'})},
2362 } # we should not encounter Unmerged (U) or Unknown (X) status
2368 sub git_patchset_body
{
2369 my ($fd, $difftree, $hash, $hash_parent) = @_;
2376 print "<div class=\"patchset\">\n";
2378 # skip to first patch
2379 while ($patch_line = <$fd>) {
2382 last if ($patch_line =~ m/^diff /);
2386 while ($patch_line) {
2388 my ($from_id, $to_id);
2391 #assert($patch_line =~ m/^diff /) if DEBUG;
2392 #assert($patch_line !~ m!$/$!) if DEBUG; # is chomp-ed
2393 push @diff_header, $patch_line;
2395 # extended diff header
2397 while ($patch_line = <$fd>) {
2400 last EXTENDED_HEADER
if ($patch_line =~ m/^--- |^diff /);
2402 if ($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/) {
2407 push @diff_header, $patch_line;
2409 my $last_patch_line = $patch_line;
2411 # check if current patch belong to current raw line
2412 # and parse raw git-diff line if needed
2413 if (defined $diffinfo &&
2414 $diffinfo->{'from_id'} eq $from_id &&
2415 $diffinfo->{'to_id'} eq $to_id) {
2416 # this is split patch
2417 print "<div class=\"patch cont\">\n";
2419 # advance raw git-diff output if needed
2420 $patch_idx++ if defined $diffinfo;
2422 # read and prepare patch information
2423 if (ref($difftree->[$patch_idx]) eq "HASH") {
2424 # pre-parsed (or generated by hand)
2425 $diffinfo = $difftree->[$patch_idx];
2427 $diffinfo = parse_difftree_raw_line
($difftree->[$patch_idx]);
2429 $from{'file'} = $diffinfo->{'from_file'} || $diffinfo->{'file'};
2430 $to{'file'} = $diffinfo->{'to_file'} || $diffinfo->{'file'};
2431 if ($diffinfo->{'status'} ne "A") { # not new (added) file
2432 $from{'href'} = href
(action
=>"blob", hash_base
=>$hash_parent,
2433 hash
=>$diffinfo->{'from_id'},
2434 file_name
=>$from{'file'});
2436 delete $from{'href'};
2438 if ($diffinfo->{'status'} ne "D") { # not deleted file
2439 $to{'href'} = href
(action
=>"blob", hash_base
=>$hash,
2440 hash
=>$diffinfo->{'to_id'},
2441 file_name
=>$to{'file'});
2445 # this is first patch for raw difftree line with $patch_idx index
2446 # we index @$difftree array from 0, but number patches from 1
2447 print "<div class=\"patch\" id=\"patch". ($patch_idx+1) ."\">\n";
2450 # print "git diff" header
2451 $patch_line = shift @diff_header;
2452 $patch_line =~ s!^(diff (.*?) )"?a/.*$!$1!;
2453 if ($from{'href'}) {
2454 $patch_line .= $cgi->a({-href
=> $from{'href'}, -class => "path"},
2455 'a/' . esc_path
($from{'file'}));
2456 } else { # file was added
2457 $patch_line .= 'a/' . esc_path
($from{'file'});
2461 $patch_line .= $cgi->a({-href
=> $to{'href'}, -class => "path"},
2462 'b/' . esc_path
($to{'file'}));
2463 } else { # file was deleted
2464 $patch_line .= 'b/' . esc_path
($to{'file'});
2466 print "<div class=\"diff header\">$patch_line</div>\n";
2468 # print extended diff header
2469 print "<div class=\"diff extended_header\">\n" if (@diff_header > 0);
2471 foreach $patch_line (@diff_header) {
2473 if ($patch_line =~ s!^((copy|rename) from ).*$!$1! && $from{'href'}) {
2474 $patch_line .= $cgi->a({-href
=>$from{'href'}, -class=>"path"},
2475 esc_path
($from{'file'}));
2477 if ($patch_line =~ s!^((copy|rename) to ).*$!$1! && $to{'href'}) {
2478 $patch_line .= $cgi->a({-href
=>$to{'href'}, -class=>"path"},
2479 esc_path
($to{'file'}));
2482 if ($patch_line =~ m/\s(\d{6})$/) {
2483 $patch_line .= '<span class="info"> (' .
2484 file_type_long
($1) .
2488 if ($patch_line =~ m/^index/) {
2489 my ($from_link, $to_link);
2490 if ($from{'href'}) {
2491 $from_link = $cgi->a({-href
=>$from{'href'}, -class=>"hash"},
2492 substr($diffinfo->{'from_id'},0,7));
2494 $from_link = '0' x
7;
2497 $to_link = $cgi->a({-href
=>$to{'href'}, -class=>"hash"},
2498 substr($diffinfo->{'to_id'},0,7));
2503 # my ($from_hash, $to_hash) =
2504 # ($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/);
2505 # my ($from_id, $to_id) =
2506 # ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});
2507 # ($from_hash eq $from_id) && ($to_hash eq $to_id);
2509 my ($from_id, $to_id) = ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});
2510 $patch_line =~ s!$from_id\.\.$to_id!$from_link..$to_link!;
2512 print $patch_line . "<br/>\n";
2514 print "</div>\n" if (@diff_header > 0); # class="diff extended_header"
2516 # from-file/to-file diff header
2517 $patch_line = $last_patch_line;
2518 if (! $patch_line) {
2519 print "</div>\n"; # class="patch"
2522 next PATCH
if ($patch_line =~ m/^diff /);
2523 #assert($patch_line =~ m/^---/) if DEBUG;
2524 if ($from{'href'} && $patch_line =~ m!^--- "?a/!) {
2525 $patch_line = '--- a/' .
2526 $cgi->a({-href
=>$from{'href'}, -class=>"path"},
2527 esc_path
($from{'file'}));
2529 print "<div class=\"diff from_file\">$patch_line</div>\n";
2531 $patch_line = <$fd>;
2534 #assert($patch_line =~ m/^+++/) if DEBUG;
2535 if ($to{'href'} && $patch_line =~ m!^\+\+\+ "?b/!) {
2536 $patch_line = '+++ b/' .
2537 $cgi->a({-href
=>$to{'href'}, -class=>"path"},
2538 esc_path
($to{'file'}));
2540 print "<div class=\"diff to_file\">$patch_line</div>\n";
2544 while ($patch_line = <$fd>) {
2547 next PATCH
if ($patch_line =~ m/^diff /);
2549 print format_diff_line
($patch_line, \
%from, \
%to);
2553 print "</div>\n"; # class="patch"
2556 print "</div>\n"; # class="patchset"
2559 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2561 sub git_project_list_body
{
2562 my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
2564 my ($check_forks) = gitweb_check_feature
('forks');
2567 foreach my $pr (@
$projlist) {
2568 my (@aa) = git_get_last_activity
($pr->{'path'});
2572 ($pr->{'age'}, $pr->{'age_string'}) = @aa;
2573 if (!defined $pr->{'descr'}) {
2574 my $descr = git_get_project_description
($pr->{'path'}) || "";
2575 $pr->{'descr_long'} = decode_utf8
($descr);
2576 $pr->{'descr'} = chop_str
($descr, 25, 5);
2578 if (!defined $pr->{'owner'}) {
2579 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
2582 my $pname = $pr->{'path'};
2583 if (($pname =~ s/\.git$//) &&
2584 ($pname !~ /\/$/) &&
2585 (-d
"$projectroot/$pname")) {
2586 $pr->{'forks'} = "-d $projectroot/$pname";
2592 push @projects, $pr;
2595 $order ||= "project";
2596 $from = 0 unless defined $from;
2597 $to = $#projects if (!defined $to || $#projects < $to);
2599 print "<table class=\"project_list\">\n";
2600 unless ($no_header) {
2603 print "<th></th>\n";
2605 if ($order eq "project") {
2606 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
2607 print "<th>Project</th>\n";
2610 $cgi->a({-href
=> href
(project
=>undef, order
=>'project'),
2611 -class => "header"}, "Project") .
2614 if ($order eq "descr") {
2615 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
2616 print "<th>Description</th>\n";
2619 $cgi->a({-href
=> href
(project
=>undef, order
=>'descr'),
2620 -class => "header"}, "Description") .
2623 if ($order eq "owner") {
2624 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
2625 print "<th>Owner</th>\n";
2628 $cgi->a({-href
=> href
(project
=>undef, order
=>'owner'),
2629 -class => "header"}, "Owner") .
2632 if ($order eq "age") {
2633 @projects = sort {$a->{'age'} <=> $b->{'age'}} @projects;
2634 print "<th>Last Change</th>\n";
2637 $cgi->a({-href
=> href
(project
=>undef, order
=>'age'),
2638 -class => "header"}, "Last Change") .
2641 print "<th></th>\n" .
2645 for (my $i = $from; $i <= $to; $i++) {
2646 my $pr = $projects[$i];
2648 print "<tr class=\"dark\">\n";
2650 print "<tr class=\"light\">\n";
2655 if ($pr->{'forks'}) {
2656 print "<!-- $pr->{'forks'} -->\n";
2657 print $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"forks")}, "+");
2661 print "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
2662 -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
2663 "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
2664 -class => "list", -title
=> $pr->{'descr_long'}},
2665 esc_html
($pr->{'descr'})) . "</td>\n" .
2666 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
2667 print "<td class=\"". age_class
($pr->{'age'}) . "\">" .
2668 $pr->{'age_string'} . "</td>\n" .
2669 "<td class=\"link\">" .
2670 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary")}, "summary") . " | " .
2671 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"shortlog")}, "shortlog") . " | " .
2672 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"log")}, "log") . " | " .
2673 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"tree")}, "tree") .
2674 ($pr->{'forks'} ?
" | " . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"forks")}, "forks") : '') .
2678 if (defined $extra) {
2681 print "<td></td>\n";
2683 print "<td colspan=\"5\">$extra</td>\n" .
2689 sub git_shortlog_body
{
2690 # uses global variable $project
2691 my ($commitlist, $from, $to, $refs, $extra) = @_;
2693 my $have_snapshot = gitweb_have_snapshot
();
2695 $from = 0 unless defined $from;
2696 $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
2698 print "<table class=\"shortlog\" cellspacing=\"0\">\n";
2700 for (my $i = $from; $i <= $to; $i++) {
2701 my %co = %{$commitlist->[$i]};
2702 my $commit = $co{'id'};
2703 my $ref = format_ref_marker
($refs, $commit);
2705 print "<tr class=\"dark\">\n";
2707 print "<tr class=\"light\">\n";
2710 # git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
2711 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2712 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
2714 print format_subject_html
($co{'title'}, $co{'title_short'},
2715 href
(action
=>"commit", hash
=>$commit), $ref);
2717 "<td class=\"link\">" .
2718 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
2719 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") . " | " .
2720 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$commit, hash_base
=>$commit)}, "tree");
2721 if ($have_snapshot) {
2722 print " | " . $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$commit)}, "snapshot");
2727 if (defined $extra) {
2729 "<td colspan=\"4\">$extra</td>\n" .
2735 sub git_history_body
{
2736 # Warning: assumes constant type (blob or tree) during history
2737 my ($commitlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;
2739 $from = 0 unless defined $from;
2740 $to = $#{$commitlist} unless (defined $to && $to <= $#{$commitlist});
2742 print "<table class=\"history\" cellspacing=\"0\">\n";
2744 for (my $i = $from; $i <= $to; $i++) {
2745 my %co = %{$commitlist->[$i]};
2749 my $commit = $co{'id'};
2751 my $ref = format_ref_marker
($refs, $commit);
2754 print "<tr class=\"dark\">\n";
2756 print "<tr class=\"light\">\n";
2759 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2760 # shortlog uses chop_str($co{'author_name'}, 10)
2761 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2763 # originally git_history used chop_str($co{'title'}, 50)
2764 print format_subject_html
($co{'title'}, $co{'title_short'},
2765 href
(action
=>"commit", hash
=>$commit), $ref);
2767 "<td class=\"link\">" .
2768 $cgi->a({-href
=> href
(action
=>$ftype, hash_base
=>$commit, file_name
=>$file_name)}, $ftype) . " | " .
2769 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff");
2771 if ($ftype eq 'blob') {
2772 my $blob_current = git_get_hash_by_path
($hash_base, $file_name);
2773 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
2774 if (defined $blob_current && defined $blob_parent &&
2775 $blob_current ne $blob_parent) {
2777 $cgi->a({-href
=> href
(action
=>"blobdiff",
2778 hash
=>$blob_current, hash_parent
=>$blob_parent,
2779 hash_base
=>$hash_base, hash_parent_base
=>$commit,
2780 file_name
=>$file_name)},
2787 if (defined $extra) {
2789 "<td colspan=\"4\">$extra</td>\n" .
2796 # uses global variable $project
2797 my ($taglist, $from, $to, $extra) = @_;
2798 $from = 0 unless defined $from;
2799 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
2801 print "<table class=\"tags\" cellspacing=\"0\">\n";
2803 for (my $i = $from; $i <= $to; $i++) {
2804 my $entry = $taglist->[$i];
2806 my $comment = $tag{'subject'};
2808 if (defined $comment) {
2809 $comment_short = chop_str
($comment, 30, 5);
2812 print "<tr class=\"dark\">\n";
2814 print "<tr class=\"light\">\n";
2817 if (defined $tag{'age'}) {
2818 print "<td><i>$tag{'age'}</i></td>\n";
2820 print "<td></td>\n";
2823 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'}),
2824 -class => "list name"}, esc_html
($tag{'name'})) .
2827 if (defined $comment) {
2828 print format_subject_html
($comment, $comment_short,
2829 href
(action
=>"tag", hash
=>$tag{'id'}));
2832 "<td class=\"selflink\">";
2833 if ($tag{'type'} eq "tag") {
2834 print $cgi->a({-href
=> href
(action
=>"tag", hash
=>$tag{'id'})}, "tag");
2839 "<td class=\"link\">" . " | " .
2840 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'})}, $tag{'reftype'});
2841 if ($tag{'reftype'} eq "commit") {
2842 print " | " . $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") .
2843 " | " . $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'name'})}, "log");
2844 } elsif ($tag{'reftype'} eq "blob") {
2845 print " | " . $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$tag{'refid'})}, "raw");
2850 if (defined $extra) {
2852 "<td colspan=\"5\">$extra</td>\n" .
2858 sub git_heads_body
{
2859 # uses global variable $project
2860 my ($headlist, $head, $from, $to, $extra) = @_;
2861 $from = 0 unless defined $from;
2862 $to = $#{$headlist} if (!defined $to || $#{$headlist} < $to);
2864 print "<table class=\"heads\" cellspacing=\"0\">\n";
2866 for (my $i = $from; $i <= $to; $i++) {
2867 my $entry = $headlist->[$i];
2869 my $curr = $ref{'id'} eq $head;
2871 print "<tr class=\"dark\">\n";
2873 print "<tr class=\"light\">\n";
2876 print "<td><i>$ref{'age'}</i></td>\n" .
2877 ($curr ?
"<td class=\"current_head\">" : "<td>") .
2878 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$ref{'name'}),
2879 -class => "list name"},esc_html
($ref{'name'})) .
2881 "<td class=\"link\">" .
2882 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$ref{'name'})}, "shortlog") . " | " .
2883 $cgi->a({-href
=> href
(action
=>"log", hash
=>$ref{'name'})}, "log") . " | " .
2884 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$ref{'name'}, hash_base
=>$ref{'name'})}, "tree") .
2888 if (defined $extra) {
2890 "<td colspan=\"3\">$extra</td>\n" .
2896 sub git_search_grep_body
{
2897 my ($commitlist, $from, $to, $extra) = @_;
2898 $from = 0 unless defined $from;
2899 $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
2901 print "<table class=\"grep\" cellspacing=\"0\">\n";
2903 for (my $i = $from; $i <= $to; $i++) {
2904 my %co = %{$commitlist->[$i]};
2908 my $commit = $co{'id'};
2910 print "<tr class=\"dark\">\n";
2912 print "<tr class=\"light\">\n";
2915 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2916 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2918 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}), -class => "list subject"},
2919 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
2920 my $comment = $co{'comment'};
2921 foreach my $line (@
$comment) {
2922 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2923 my $lead = esc_html
($1) || "";
2924 $lead = chop_str
($lead, 30, 10);
2925 my $match = esc_html
($2) || "";
2926 my $trail = esc_html
($3) || "";
2927 $trail = chop_str
($trail, 30, 10);
2928 my $text = "$lead<span class=\"match\">$match</span>$trail";
2929 print chop_str
($text, 80, 5) . "<br/>\n";
2933 "<td class=\"link\">" .
2934 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
2936 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
2940 if (defined $extra) {
2942 "<td colspan=\"3\">$extra</td>\n" .
2948 ## ======================================================================
2949 ## ======================================================================
2952 sub git_project_list
{
2953 my $order = $cgi->param('o');
2954 if (defined $order && $order !~ m/project|descr|owner|age/) {
2955 die_error
(undef, "Unknown order parameter");
2958 my @list = git_get_projects_list
();
2960 die_error
(undef, "No projects found");
2964 if (-f
$home_text) {
2965 print "<div class=\"index_include\">\n";
2966 open (my $fd, $home_text);
2971 git_project_list_body
(\
@list, $order);
2976 my $order = $cgi->param('o');
2977 if (defined $order && $order !~ m/project|descr|owner|age/) {
2978 die_error
(undef, "Unknown order parameter");
2981 my @list = git_get_projects_list
($project);
2983 die_error
(undef, "No forks found");
2987 git_print_page_nav
('','');
2988 git_print_header_div
('summary', "$project forks");
2989 git_project_list_body
(\
@list, $order);
2993 sub git_project_index
{
2994 my @projects = git_get_projects_list
($project);
2997 -type
=> 'text/plain',
2998 -charset
=> 'utf-8',
2999 -content_disposition
=> 'inline; filename="index.aux"');
3001 foreach my $pr (@projects) {
3002 if (!exists $pr->{'owner'}) {
3003 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}");
3006 my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});
3007 # quote as in CGI::Util::encode, but keep the slash, and use '+' for ' '
3008 $path =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf
("%%%02X", ord($1))/eg
;
3009 $owner =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf
("%%%02X", ord($1))/eg
;
3013 print "$path $owner\n";
3018 my $descr = git_get_project_description
($project) || "none";
3019 my %co = parse_commit
("HEAD");
3020 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
3021 my $head = $co{'id'};
3023 my $owner = git_get_project_owner
($project);
3025 my $refs = git_get_references
();
3026 # These get_*_list functions return one more to allow us to see if
3027 # there are more ...
3028 my @taglist = git_get_tags_list
(16);
3029 my @headlist = git_get_heads_list
(16);
3031 my ($check_forks) = gitweb_check_feature
('forks');
3034 @forklist = git_get_projects_list
($project);
3038 git_print_page_nav
('summary','', $head);
3040 print "<div class=\"title\"> </div>\n";
3041 print "<table cellspacing=\"0\">\n" .
3042 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
3043 "<tr><td>owner</td><td>$owner</td></tr>\n" .
3044 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
3045 # use per project git URL list in $projectroot/$project/cloneurl
3046 # or make project git URL from git base URL and project name
3047 my $url_tag = "URL";
3048 my @url_list = git_get_project_url_list
($project);
3049 @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
3050 foreach my $git_url (@url_list) {
3051 next unless $git_url;
3052 print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
3057 if (-s
"$projectroot/$project/README.html") {
3058 if (open my $fd, "$projectroot/$project/README.html") {
3059 print "<div class=\"title\">readme</div>\n";
3060 print $_ while (<$fd>);
3065 # we need to request one more than 16 (0..15) to check if
3067 my @commitlist = parse_commits
($head, 17);
3068 git_print_header_div
('shortlog');
3069 git_shortlog_body
(\
@commitlist, 0, 15, $refs,
3070 $#commitlist <= 15 ?
undef :
3071 $cgi->a({-href
=> href
(action
=>"shortlog")}, "..."));
3074 git_print_header_div
('tags');
3075 git_tags_body
(\
@taglist, 0, 15,
3076 $#taglist <= 15 ?
undef :
3077 $cgi->a({-href
=> href
(action
=>"tags")}, "..."));
3081 git_print_header_div
('heads');
3082 git_heads_body
(\
@headlist, $head, 0, 15,
3083 $#headlist <= 15 ?
undef :
3084 $cgi->a({-href
=> href
(action
=>"heads")}, "..."));
3088 git_print_header_div
('forks');
3089 git_project_list_body
(\
@forklist, undef, 0, 15,
3090 $#forklist <= 15 ?
undef :
3091 $cgi->a({-href
=> href
(action
=>"forks")}, "..."),
3099 my $head = git_get_head_hash
($project);
3101 git_print_page_nav
('','', $head,undef,$head);
3102 my %tag = parse_tag
($hash);
3103 git_print_header_div
('commit', esc_html
($tag{'name'}), $hash);
3104 print "<div class=\"title_text\">\n" .
3105 "<table cellspacing=\"0\">\n" .
3107 "<td>object</td>\n" .
3108 "<td>" . $cgi->a({-class => "list", -href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
3109 $tag{'object'}) . "</td>\n" .
3110 "<td class=\"link\">" . $cgi->a({-href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
3111 $tag{'type'}) . "</td>\n" .
3113 if (defined($tag{'author'})) {
3114 my %ad = parse_date
($tag{'epoch'}, $tag{'tz'});
3115 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
3116 print "<tr><td></td><td>" . $ad{'rfc2822'} .
3117 sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) .
3120 print "</table>\n\n" .
3122 print "<div class=\"page_body\">";
3123 my $comment = $tag{'comment'};
3124 foreach my $line (@
$comment) {
3126 print esc_html
($line, -nbsp
=>1) . "<br/>\n";
3136 my ($have_blame) = gitweb_check_feature
('blame');
3138 die_error
('403 Permission denied', "Permission denied");
3140 die_error
('404 Not Found', "File name not defined") if (!$file_name);
3141 $hash_base ||= git_get_head_hash
($project);
3142 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
3143 my %co = parse_commit
($hash_base)
3144 or die_error
(undef, "Reading commit failed");
3145 if (!defined $hash) {
3146 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
3147 or die_error
(undef, "Error looking up file");
3149 $ftype = git_get_type
($hash);
3150 if ($ftype !~ "blob") {
3151 die_error
('400 Bad Request', "Object is not a blob");
3153 open ($fd, "-|", git_cmd
(), "blame", '-p', '--',
3154 $file_name, $hash_base)
3155 or die_error
(undef, "Open git-blame failed");
3158 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3161 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3164 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
3166 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3167 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3168 git_print_page_path
($file_name, $ftype, $hash_base);
3169 my @rev_color = (qw(light2 dark2));
3170 my $num_colors = scalar(@rev_color);
3171 my $current_color = 0;
3174 <div class="page_body">
3175 <table class="blame">
3176 <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
3181 last unless defined $_;
3182 my ($full_rev, $orig_lineno, $lineno, $group_size) =
3183 /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/;
3184 if (!exists $metainfo{$full_rev}) {
3185 $metainfo{$full_rev} = {};
3187 my $meta = $metainfo{$full_rev};
3190 if (/^(\S+) (.*)$/) {
3196 my $rev = substr($full_rev, 0, 8);
3197 my $author = $meta->{'author'};
3198 my %date = parse_date
($meta->{'author-time'},
3199 $meta->{'author-tz'});
3200 my $date = $date{'iso-tz'};
3202 $current_color = ++$current_color % $num_colors;
3204 print "<tr class=\"$rev_color[$current_color]\">\n";
3206 print "<td class=\"sha1\"";
3207 print " title=\"". esc_html
($author) . ", $date\"";
3208 print " rowspan=\"$group_size\"" if ($group_size > 1);
3210 print $cgi->a({-href
=> href
(action
=>"commit",
3212 file_name
=>$file_name)},
3216 open (my $dd, "-|", git_cmd
(), "rev-parse", "$full_rev^")
3217 or die_error
(undef, "Open git-rev-parse failed");
3218 my $parent_commit = <$dd>;
3220 chomp($parent_commit);
3221 my $blamed = href
(action
=> 'blame',
3222 file_name
=> $meta->{'filename'},
3223 hash_base
=> $parent_commit);
3224 print "<td class=\"linenr\">";
3225 print $cgi->a({ -href
=> "$blamed#l$orig_lineno",
3227 -class => "linenr" },
3230 print "<td class=\"pre\">" . esc_html
($data) . "</td>\n";
3236 or print "Reading blob failed\n";
3243 my ($have_blame) = gitweb_check_feature
('blame');
3245 die_error
('403 Permission denied', "Permission denied");
3247 die_error
('404 Not Found', "File name not defined") if (!$file_name);
3248 $hash_base ||= git_get_head_hash
($project);
3249 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
3250 my %co = parse_commit
($hash_base)
3251 or die_error
(undef, "Reading commit failed");
3252 if (!defined $hash) {
3253 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
3254 or die_error
(undef, "Error lookup file");
3256 open ($fd, "-|", git_cmd
(), "annotate", '-l', '-t', '-r', $file_name, $hash_base)
3257 or die_error
(undef, "Open git-annotate failed");
3260 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3263 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3266 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
3268 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3269 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3270 git_print_page_path
($file_name, 'blob', $hash_base);
3271 print "<div class=\"page_body\">\n";
3273 <table class="blame">
3282 my @line_class = (qw(light dark));
3283 my $line_class_len = scalar (@line_class);
3284 my $line_class_num = $#line_class;
3285 while (my $line = <$fd>) {
3297 $line_class_num = ($line_class_num + 1) % $line_class_len;
3299 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
3306 print qq( <tr
><td colspan
="5" class="error">Unable to parse
: $line</td></tr
>\n);
3309 $short_rev = substr ($long_rev, 0, 8);
3310 $age = time () - $time;
3311 $age_str = age_string
($age);
3312 $age_str =~ s/ / /g;
3313 $age_class = age_class
($age);
3314 $author = esc_html
($author);
3315 $author =~ s/ / /g;
3317 $data = untabify
($data);
3318 $data = esc_html
($data);
3321 <tr class="$line_class[$line_class_num]">
3322 <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
3323 <td class="$age_class">$age_str</td>
3325 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
3326 <td class="pre">$data</td>
3329 } # while (my $line = <$fd>)
3330 print "</table>\n\n";
3332 or print "Reading blob failed.\n";
3338 my $head = git_get_head_hash
($project);
3340 git_print_page_nav
('','', $head,undef,$head);
3341 git_print_header_div
('summary', $project);
3343 my @tagslist = git_get_tags_list
();
3345 git_tags_body
(\
@tagslist);
3351 my $head = git_get_head_hash
($project);
3353 git_print_page_nav
('','', $head,undef,$head);
3354 git_print_header_div
('summary', $project);
3356 my @headslist = git_get_heads_list
();
3358 git_heads_body
(\
@headslist, $head);
3363 sub git_blob_plain
{
3366 if (!defined $hash) {
3367 if (defined $file_name) {
3368 my $base = $hash_base || git_get_head_hash
($project);
3369 $hash = git_get_hash_by_path
($base, $file_name, "blob")
3370 or die_error
(undef, "Error lookup file");
3372 die_error
(undef, "No file name defined");
3374 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3375 # blobs defined by non-textual hash id's can be cached
3380 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
3381 or die_error
(undef, "Couldn't cat $file_name, $hash");
3383 $type ||= blob_mimetype
($fd, $file_name);
3385 # save as filename, even when no $file_name is given
3386 my $save_as = "$hash";
3387 if (defined $file_name) {
3388 $save_as = $file_name;
3389 } elsif ($type =~ m/^text\//) {
3396 -content_disposition
=> 'inline; filename="' . "$save_as" . '"');
3398 binmode STDOUT
, ':raw';
3400 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
3408 if (!defined $hash) {
3409 if (defined $file_name) {
3410 my $base = $hash_base || git_get_head_hash
($project);
3411 $hash = git_get_hash_by_path
($base, $file_name, "blob")
3412 or die_error
(undef, "Error lookup file");
3414 die_error
(undef, "No file name defined");
3416 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3417 # blobs defined by non-textual hash id's can be cached
3421 my ($have_blame) = gitweb_check_feature
('blame');
3422 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
3423 or die_error
(undef, "Couldn't cat $file_name, $hash");
3424 my $mimetype = blob_mimetype
($fd, $file_name);
3425 if ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)!) {
3427 return git_blob_plain
($mimetype);
3429 # we can have blame only for text/* mimetype
3430 $have_blame &&= ($mimetype =~ m!^text/!);
3432 git_header_html
(undef, $expires);
3433 my $formats_nav = '';
3434 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
3435 if (defined $file_name) {
3438 $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash_base,
3439 hash
=>$hash, file_name
=>$file_name)},
3444 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
3445 hash
=>$hash, file_name
=>$file_name)},
3448 $cgi->a({-href
=> href
(action
=>"blob_plain",
3449 hash
=>$hash, file_name
=>$file_name)},
3452 $cgi->a({-href
=> href
(action
=>"blob",
3453 hash_base
=>"HEAD", file_name
=>$file_name)},
3457 $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$hash)}, "raw");
3459 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3460 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3462 print "<div class=\"page_nav\">\n" .
3463 "<br/><br/></div>\n" .
3464 "<div class=\"title\">$hash</div>\n";
3466 git_print_page_path
($file_name, "blob", $hash_base);
3467 print "<div class=\"page_body\">\n";
3468 if ($mimetype =~ m!^text/!) {
3470 while (my $line = <$fd>) {
3473 $line = untabify
($line);
3474 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
3475 $nr, $nr, $nr, esc_html
($line, -nbsp
=>1);
3477 } elsif ($mimetype =~ m!^image/!) {
3478 print qq!<img type
="$mimetype"!;
3480 print qq! alt
="$file_name" title
="$file_name"!;
3483 href(action=>"blob_plain
", hash=>$hash,
3484 hash_base=>$hash_base, file_name=>$file_name) .
3488 or print "Reading blob failed.\n";
3494 my $have_snapshot = gitweb_have_snapshot
();
3496 if (!defined $hash_base) {
3497 $hash_base = "HEAD";
3499 if (!defined $hash) {
3500 if (defined $file_name) {
3501 $hash = git_get_hash_by_path
($hash_base, $file_name, "tree");
3507 open my $fd, "-|", git_cmd
(), "ls-tree", '-z', $hash
3508 or die_error
(undef, "Open git-ls-tree failed");
3509 my @entries = map { chomp; $_ } <$fd>;
3510 close $fd or die_error
(undef, "Reading tree failed");
3513 my $refs = git_get_references
();
3514 my $ref = format_ref_marker
($refs, $hash_base);
3517 my ($have_blame) = gitweb_check_feature
('blame');
3518 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
3520 if (defined $file_name) {
3522 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
3523 hash
=>$hash, file_name
=>$file_name)},
3525 $cgi->a({-href
=> href
(action
=>"tree",
3526 hash_base
=>"HEAD", file_name
=>$file_name)},
3529 if ($have_snapshot) {
3530 # FIXME: Should be available when we have no hash base as well.
3532 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)},
3535 git_print_page_nav
('tree','', $hash_base, undef, undef, join(' | ', @views_nav));
3536 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash_base);
3539 print "<div class=\"page_nav\">\n";
3540 print "<br/><br/></div>\n";
3541 print "<div class=\"title\">$hash</div>\n";
3543 if (defined $file_name) {
3544 $basedir = $file_name;
3545 if ($basedir ne '' && substr($basedir, -1) ne '/') {
3549 git_print_page_path
($file_name, 'tree', $hash_base);
3550 print "<div class=\"page_body\">\n";
3551 print "<table cellspacing=\"0\">\n";
3553 # '..' (top directory) link if possible
3554 if (defined $hash_base &&
3555 defined $file_name && $file_name =~ m![^/]+$!) {
3557 print "<tr class=\"dark\">\n";
3559 print "<tr class=\"light\">\n";
3563 my $up = $file_name;
3564 $up =~ s!/?[^/]+$!!;
3565 undef $up unless $up;
3566 # based on git_print_tree_entry
3567 print '<td class="mode">' . mode_str
('040000') . "</td>\n";
3568 print '<td class="list">';
3569 print $cgi->a({-href
=> href
(action
=>"tree", hash_base
=>$hash_base,
3573 print "<td class=\"link\"></td>\n";
3577 foreach my $line (@entries) {
3578 my %t = parse_ls_tree_line
($line, -z
=> 1);
3581 print "<tr class=\"dark\">\n";
3583 print "<tr class=\"light\">\n";
3587 git_print_tree_entry
(\
%t, $basedir, $hash_base, $have_blame);
3591 print "</table>\n" .
3597 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
3598 my $have_snapshot = (defined $ctype && defined $suffix);
3599 if (!$have_snapshot) {
3600 die_error
('403 Permission denied', "Permission denied");
3603 if (!defined $hash) {
3604 $hash = git_get_head_hash
($project);
3607 my $filename = decode_utf8
(basename
($project)) . "-$hash.tar.$suffix";
3610 -type
=> "application/$ctype",
3611 -content_disposition
=> 'inline; filename="' . "$filename" . '"',
3612 -status
=> '200 OK');
3614 my $git = git_cmd_str
();
3615 my $name = $project;
3616 $name =~ s/\047/\047\\\047\047/g;
3618 "$git archive --format=tar --prefix=\'$name\'/ $hash | $command"
3619 or die_error
(undef, "Execute git-tar-tree failed");
3620 binmode STDOUT
, ':raw';
3622 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
3628 my $head = git_get_head_hash
($project);
3629 if (!defined $hash) {
3632 if (!defined $page) {
3635 my $refs = git_get_references
();
3637 my @commitlist = parse_commits
($hash, 101, (100 * $page));
3639 my $paging_nav = format_paging_nav
('log', $hash, $head, $page, (100 * ($page+1)));
3642 git_print_page_nav
('log','', $hash,undef,undef, $paging_nav);
3645 my %co = parse_commit
($hash);
3647 git_print_header_div
('summary', $project);
3648 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
3650 my $to = ($#commitlist >= 99) ?
(99) : ($#commitlist);
3651 for (my $i = 0; $i <= $to; $i++) {
3652 my %co = %{$commitlist[$i]};
3654 my $commit = $co{'id'};
3655 my $ref = format_ref_marker
($refs, $commit);
3656 my %ad = parse_date
($co{'author_epoch'});
3657 git_print_header_div
('commit',
3658 "<span class=\"age\">$co{'age_string'}</span>" .
3659 esc_html
($co{'title'}) . $ref,
3661 print "<div class=\"title_text\">\n" .
3662 "<div class=\"log_link\">\n" .
3663 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") .
3665 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") .
3667 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$commit, hash_base
=>$commit)}, "tree") .
3670 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
3673 print "<div class=\"log_body\">\n";
3674 git_print_log
($co{'comment'}, -final_empty_line
=> 1);
3677 if ($#commitlist >= 100) {
3678 print "<div class=\"page_nav\">\n";
3679 print $cgi->a({-href
=> href
(action
=>"log", hash
=>$hash, page
=>$page+1),
3680 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
3687 $hash ||= $hash_base || "HEAD";
3688 my %co = parse_commit
($hash);
3690 die_error
(undef, "Unknown commit object");
3692 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
3693 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
3695 my $parent = $co{'parent'};
3696 my $parents = $co{'parents'}; # listref
3698 # we need to prepare $formats_nav before any parameter munging
3700 if (!defined $parent) {
3702 $formats_nav .= '(initial)';
3703 } elsif (@
$parents == 1) {
3704 # single parent commit
3707 $cgi->a({-href
=> href
(action
=>"commit",
3709 esc_html
(substr($parent, 0, 7))) .
3716 $cgi->a({-href
=> href
(action
=>"commit",
3718 esc_html
(substr($_, 0, 7)));
3723 if (!defined $parent) {
3727 if (@
$parents <= 1) {
3728 # difftree output is not printed for merges
3729 open my $fd, "-|", git_cmd
(), "diff-tree", '-r', "--no-commit-id",
3730 @diff_opts, $parent, $hash, "--"
3731 or die_error
(undef, "Open git-diff-tree failed");
3732 @difftree = map { chomp; $_ } <$fd>;
3733 close $fd or die_error
(undef, "Reading git-diff-tree failed");
3736 # non-textual hash id's can be cached
3738 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3741 my $refs = git_get_references
();
3742 my $ref = format_ref_marker
($refs, $co{'id'});
3744 my $have_snapshot = gitweb_have_snapshot
();
3746 git_header_html
(undef, $expires);
3747 git_print_page_nav
('commit', '',
3748 $hash, $co{'tree'}, $hash,
3751 if (defined $co{'parent'}) {
3752 git_print_header_div
('commitdiff', esc_html
($co{'title'}) . $ref, $hash);
3754 git_print_header_div
('tree', esc_html
($co{'title'}) . $ref, $co{'tree'}, $hash);
3756 print "<div class=\"title_text\">\n" .
3757 "<table cellspacing=\"0\">\n";
3758 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
3760 "<td></td><td> $ad{'rfc2822'}";
3761 if ($ad{'hour_local'} < 6) {
3762 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
3763 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
3765 printf(" (%02d:%02d %s)",
3766 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
3770 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
3771 print "<tr><td></td><td> $cd{'rfc2822'}" .
3772 sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
3774 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
3777 "<td class=\"sha1\">" .
3778 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash),
3779 class => "list"}, $co{'tree'}) .
3781 "<td class=\"link\">" .
3782 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash)},
3784 if ($have_snapshot) {
3786 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)}, "snapshot");
3791 foreach my $par (@
$parents) {
3794 "<td class=\"sha1\">" .
3795 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par),
3796 class => "list"}, $par) .
3798 "<td class=\"link\">" .
3799 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par)}, "commit") .
3801 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$hash, hash_parent
=>$par)}, "diff") .
3808 print "<div class=\"page_body\">\n";
3809 git_print_log
($co{'comment'});
3812 if (@
$parents <= 1) {
3813 # do not output difftree/whatchanged for merges
3814 git_difftree_body
(\
@difftree, $hash, $parent);
3821 # object is defined by:
3822 # - hash or hash_base alone
3823 # - hash_base and file_name
3826 # - hash or hash_base alone
3827 if ($hash || ($hash_base && !defined $file_name)) {
3828 my $object_id = $hash || $hash_base;
3830 my $git_command = git_cmd_str
();
3831 open my $fd, "-|", "$git_command cat-file -t $object_id 2>/dev/null"
3832 or die_error
('404 Not Found', "Object does not exist");
3836 or die_error
('404 Not Found', "Object does not exist");
3838 # - hash_base and file_name
3839 } elsif ($hash_base && defined $file_name) {
3840 $file_name =~ s
,/+$,,;
3842 system(git_cmd
(), "cat-file", '-e', $hash_base) == 0
3843 or die_error
('404 Not Found', "Base object does not exist");
3845 # here errors should not hapen
3846 open my $fd, "-|", git_cmd
(), "ls-tree", $hash_base, "--", $file_name
3847 or die_error
(undef, "Open git-ls-tree failed");
3851 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
3852 unless ($line && $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/) {
3853 die_error
('404 Not Found', "File or directory for given base does not exist");
3858 die_error
('404 Not Found', "Not enough information to find object");
3861 print $cgi->redirect(-uri
=> href
(action
=>$type, -full
=>1,
3862 hash
=>$hash, hash_base
=>$hash_base,
3863 file_name
=>$file_name),
3864 -status
=> '302 Found');
3868 my $format = shift || 'html';
3875 # preparing $fd and %diffinfo for git_patchset_body
3877 if (defined $hash_base && defined $hash_parent_base) {
3878 if (defined $file_name) {
3880 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
3881 $hash_parent_base, $hash_base,
3882 "--", (defined $file_parent ?
$file_parent : ()), $file_name
3883 or die_error
(undef, "Open git-diff-tree failed");
3884 @difftree = map { chomp; $_ } <$fd>;
3886 or die_error
(undef, "Reading git-diff-tree failed");
3888 or die_error
('404 Not Found', "Blob diff not found");
3890 } elsif (defined $hash &&
3891 $hash =~ /[0-9a-fA-F]{40}/) {
3892 # try to find filename from $hash
3894 # read filtered raw output
3895 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
3896 $hash_parent_base, $hash_base, "--"
3897 or die_error
(undef, "Open git-diff-tree failed");
3899 # ':100644 100644 03b21826... 3b93d5e7... M ls-files.c'
3901 grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
3902 map { chomp; $_ } <$fd>;
3904 or die_error
(undef, "Reading git-diff-tree failed");
3906 or die_error
('404 Not Found', "Blob diff not found");
3909 die_error
('404 Not Found', "Missing one of the blob diff parameters");
3912 if (@difftree > 1) {
3913 die_error
('404 Not Found', "Ambiguous blob diff specification");
3916 %diffinfo = parse_difftree_raw_line
($difftree[0]);
3917 $file_parent ||= $diffinfo{'from_file'} || $file_name || $diffinfo{'file'};
3918 $file_name ||= $diffinfo{'to_file'} || $diffinfo{'file'};
3920 $hash_parent ||= $diffinfo{'from_id'};
3921 $hash ||= $diffinfo{'to_id'};
3923 # non-textual hash id's can be cached
3924 if ($hash_base =~ m/^[0-9a-fA-F]{40}$/ &&
3925 $hash_parent_base =~ m/^[0-9a-fA-F]{40}$/) {
3930 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
3931 '-p', ($format eq 'html' ?
"--full-index" : ()),
3932 $hash_parent_base, $hash_base,
3933 "--", (defined $file_parent ?
$file_parent : ()), $file_name
3934 or die_error
(undef, "Open git-diff-tree failed");
3937 # old/legacy style URI
3938 if (!%diffinfo && # if new style URI failed
3939 defined $hash && defined $hash_parent) {
3940 # fake git-diff-tree raw output
3941 $diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
3942 $diffinfo{'from_id'} = $hash_parent;
3943 $diffinfo{'to_id'} = $hash;
3944 if (defined $file_name) {
3945 if (defined $file_parent) {
3946 $diffinfo{'status'} = '2';
3947 $diffinfo{'from_file'} = $file_parent;
3948 $diffinfo{'to_file'} = $file_name;
3949 } else { # assume not renamed
3950 $diffinfo{'status'} = '1';
3951 $diffinfo{'from_file'} = $file_name;
3952 $diffinfo{'to_file'} = $file_name;
3954 } else { # no filename given
3955 $diffinfo{'status'} = '2';
3956 $diffinfo{'from_file'} = $hash_parent;
3957 $diffinfo{'to_file'} = $hash;
3960 # non-textual hash id's can be cached
3961 if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
3962 $hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
3967 open $fd, "-|", git_cmd
(), "diff", @diff_opts,
3968 '-p', ($format eq 'html' ?
"--full-index" : ()),
3969 $hash_parent, $hash, "--"
3970 or die_error
(undef, "Open git-diff failed");
3972 die_error
('404 Not Found', "Missing one of the blob diff parameters")
3977 if ($format eq 'html') {
3979 $cgi->a({-href
=> href
(action
=>"blobdiff_plain",
3980 hash
=>$hash, hash_parent
=>$hash_parent,
3981 hash_base
=>$hash_base, hash_parent_base
=>$hash_parent_base,
3982 file_name
=>$file_name, file_parent
=>$file_parent)},
3984 git_header_html
(undef, $expires);
3985 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
3986 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3987 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3989 print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
3990 print "<div class=\"title\">$hash vs $hash_parent</div>\n";
3992 if (defined $file_name) {
3993 git_print_page_path
($file_name, "blob", $hash_base);
3995 print "<div class=\"page_path\"></div>\n";
3998 } elsif ($format eq 'plain') {
4000 -type
=> 'text/plain',
4001 -charset
=> 'utf-8',
4002 -expires
=> $expires,
4003 -content_disposition
=> 'inline; filename="' . "$file_name" . '.patch"');
4005 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
4008 die_error
(undef, "Unknown blobdiff format");
4012 if ($format eq 'html') {
4013 print "<div class=\"page_body\">\n";
4015 git_patchset_body
($fd, [ \
%diffinfo ], $hash_base, $hash_parent_base);
4018 print "</div>\n"; # class="page_body"
4022 while (my $line = <$fd>) {
4023 $line =~ s!a/($hash|$hash_parent)!'a/'.esc_path($diffinfo{'from_file'})!eg;
4024 $line =~ s!b/($hash|$hash_parent)!'b/'.esc_path($diffinfo{'to_file'})!eg;
4028 last if $line =~ m!^\+\+\+!;
4036 sub git_blobdiff_plain
{
4037 git_blobdiff
('plain');
4040 sub git_commitdiff
{
4041 my $format = shift || 'html';
4042 $hash ||= $hash_base || "HEAD";
4043 my %co = parse_commit
($hash);
4045 die_error
(undef, "Unknown commit object");
4048 # we need to prepare $formats_nav before any parameter munging
4050 if ($format eq 'html') {
4052 $cgi->a({-href
=> href
(action
=>"commitdiff_plain",
4053 hash
=>$hash, hash_parent
=>$hash_parent)},
4056 if (defined $hash_parent) {
4057 # commitdiff with two commits given
4058 my $hash_parent_short = $hash_parent;
4059 if ($hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
4060 $hash_parent_short = substr($hash_parent, 0, 7);
4064 $cgi->a({-href
=> href
(action
=>"commitdiff",
4065 hash
=>$hash_parent)},
4066 esc_html
($hash_parent_short)) .
4068 } elsif (!$co{'parent'}) {
4070 $formats_nav .= ' (initial)';
4071 } elsif (scalar @
{$co{'parents'}} == 1) {
4072 # single parent commit
4075 $cgi->a({-href
=> href
(action
=>"commitdiff",
4076 hash
=>$co{'parent'})},
4077 esc_html
(substr($co{'parent'}, 0, 7))) .
4084 $cgi->a({-href
=> href
(action
=>"commitdiff",
4086 esc_html
(substr($_, 0, 7)));
4087 } @
{$co{'parents'}} ) .
4092 if (!defined $hash_parent) {
4093 $hash_parent = $co{'parent'} || '--root';
4099 if ($format eq 'html') {
4100 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4101 "--no-commit-id", "--patch-with-raw", "--full-index",
4102 $hash_parent, $hash, "--"
4103 or die_error
(undef, "Open git-diff-tree failed");
4105 while (my $line = <$fd>) {
4107 # empty line ends raw part of diff-tree output
4109 push @difftree, $line;
4112 } elsif ($format eq 'plain') {
4113 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4114 '-p', $hash_parent, $hash, "--"
4115 or die_error
(undef, "Open git-diff-tree failed");
4118 die_error
(undef, "Unknown commitdiff format");
4121 # non-textual hash id's can be cached
4123 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
4127 # write commit message
4128 if ($format eq 'html') {
4129 my $refs = git_get_references
();
4130 my $ref = format_ref_marker
($refs, $co{'id'});
4132 git_header_html
(undef, $expires);
4133 git_print_page_nav
('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
4134 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash);
4135 git_print_authorship
(\
%co);
4136 print "<div class=\"page_body\">\n";
4137 if (@
{$co{'comment'}} > 1) {
4138 print "<div class=\"log\">\n";
4139 git_print_log
($co{'comment'}, -final_empty_line
=> 1, -remove_title
=> 1);
4140 print "</div>\n"; # class="log"
4143 } elsif ($format eq 'plain') {
4144 my $refs = git_get_references
("tags");
4145 my $tagname = git_get_rev_name_tags
($hash);
4146 my $filename = basename
($project) . "-$hash.patch";
4149 -type
=> 'text/plain',
4150 -charset
=> 'utf-8',
4151 -expires
=> $expires,
4152 -content_disposition
=> 'inline; filename="' . "$filename" . '"');
4153 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
4156 Date: $ad{'rfc2822'} ($ad{'tz_local'})
4157 Subject: $co{'title'}
4159 print "X-Git-Tag: $tagname\n" if $tagname;
4160 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
4162 foreach my $line (@
{$co{'comment'}}) {
4169 if ($format eq 'html') {
4170 git_difftree_body
(\
@difftree, $hash, $hash_parent);
4173 git_patchset_body
($fd, \
@difftree, $hash, $hash_parent);
4175 print "</div>\n"; # class="page_body"
4178 } elsif ($format eq 'plain') {
4182 or print "Reading git-diff-tree failed\n";
4186 sub git_commitdiff_plain
{
4187 git_commitdiff
('plain');
4191 if (!defined $hash_base) {
4192 $hash_base = git_get_head_hash
($project);
4194 if (!defined $page) {
4198 my %co = parse_commit
($hash_base);
4200 die_error
(undef, "Unknown commit object");
4203 my $refs = git_get_references
();
4204 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
4206 if (!defined $hash && defined $file_name) {
4207 $hash = git_get_hash_by_path
($hash_base, $file_name);
4209 if (defined $hash) {
4210 $ftype = git_get_type
($hash);
4213 my @commitlist = parse_commits
($hash_base, 101, (100 * $page), "--full-history", $file_name);
4215 my $paging_nav = '';
4218 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4219 file_name
=>$file_name)},
4221 $paging_nav .= " ⋅ " .
4222 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4223 file_name
=>$file_name, page
=>$page-1),
4224 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
4226 $paging_nav .= "first";
4227 $paging_nav .= " ⋅ prev";
4229 if ($#commitlist >= 100) {
4230 $paging_nav .= " ⋅ " .
4231 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4232 file_name
=>$file_name, page
=>$page+1),
4233 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4235 $paging_nav .= " ⋅ next";
4238 if ($#commitlist >= 100) {
4240 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4241 file_name
=>$file_name, page
=>$page+1),
4242 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4246 git_print_page_nav
('history','', $hash_base,$co{'tree'},$hash_base, $paging_nav);
4247 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
4248 git_print_page_path
($file_name, $ftype, $hash_base);
4250 git_history_body
(\
@commitlist, 0, 99,
4251 $refs, $hash_base, $ftype, $next_link);
4257 my ($have_search) = gitweb_check_feature
('search');
4258 if (!$have_search) {
4259 die_error
('403 Permission denied', "Permission denied");
4261 if (!defined $searchtext) {
4262 die_error
(undef, "Text field empty");
4264 if (!defined $hash) {
4265 $hash = git_get_head_hash
($project);
4267 my %co = parse_commit
($hash);
4269 die_error
(undef, "Unknown commit object");
4271 if (!defined $page) {
4275 $searchtype ||= 'commit';
4276 if ($searchtype eq 'pickaxe') {
4277 # pickaxe may take all resources of your box and run for several minutes
4278 # with every query - so decide by yourself how public you make this feature
4279 my ($have_pickaxe) = gitweb_check_feature
('pickaxe');
4280 if (!$have_pickaxe) {
4281 die_error
('403 Permission denied', "Permission denied");
4287 if ($searchtype eq 'commit' or $searchtype eq 'author' or $searchtype eq 'committer') {
4289 if ($searchtype eq 'commit') {
4290 $greptype = "--grep=";
4291 } elsif ($searchtype eq 'author') {
4292 $greptype = "--author=";
4293 } elsif ($searchtype eq 'committer') {
4294 $greptype = "--committer=";
4296 $greptype .= $searchtext;
4297 my @commitlist = parse_commits
($hash, 101, (100 * $page), $greptype);
4299 my $paging_nav = '';
4302 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4303 searchtext
=>$searchtext, searchtype
=>$searchtype)},
4305 $paging_nav .= " ⋅ " .
4306 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4307 searchtext
=>$searchtext, searchtype
=>$searchtype,
4309 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
4311 $paging_nav .= "first";
4312 $paging_nav .= " ⋅ prev";
4314 if ($#commitlist >= 100) {
4315 $paging_nav .= " ⋅ " .
4316 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4317 searchtext
=>$searchtext, searchtype
=>$searchtype,
4319 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4321 $paging_nav .= " ⋅ next";
4324 if ($#commitlist >= 100) {
4326 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4327 searchtext
=>$searchtext, searchtype
=>$searchtype,
4329 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4332 git_print_page_nav
('','', $hash,$co{'tree'},$hash, $paging_nav);
4333 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
4334 git_search_grep_body
(\
@commitlist, 0, 99, $next_link);
4337 if ($searchtype eq 'pickaxe') {
4338 git_print_page_nav
('','', $hash,$co{'tree'},$hash);
4339 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
4341 print "<table cellspacing=\"0\">\n";
4344 my $git_command = git_cmd_str
();
4345 open my $fd, "-|", "$git_command rev-list $hash | " .
4346 "$git_command diff-tree -r --stdin -S\'$searchtext\'";
4349 while (my $line = <$fd>) {
4350 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
4353 $set{'from_id'} = $3;
4355 $set{'id'} = $set{'to_id'};
4356 if ($set{'id'} =~ m/0{40}/) {
4357 $set{'id'} = $set{'from_id'};
4359 if ($set{'id'} =~ m/0{40}/) {
4363 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
4366 print "<tr class=\"dark\">\n";
4368 print "<tr class=\"light\">\n";
4371 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
4372 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
4374 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}),
4375 -class => "list subject"},
4376 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
4377 while (my $setref = shift @files) {
4379 print $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$co{'id'},
4380 hash
=>$set{'id'}, file_name
=>$set{'file'}),
4382 "<span class=\"match\">" . esc_path
($set{'file'}) . "</span>") .
4386 "<td class=\"link\">" .
4387 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
4389 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
4393 %co = parse_commit
($1);
4403 sub git_search_help
{
4405 git_print_page_nav
('','', $hash,$hash,$hash);
4408 <dt><b>commit</b></dt>
4409 <dd>The commit messages and authorship information will be scanned for the given string.</dd>
4410 <dt><b>author</b></dt>
4411 <dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given string.</dd>
4412 <dt><b>committer</b></dt>
4413 <dd>Name and e-mail of the committer and date of commit will be scanned for the given string.</dd>
4415 my ($have_pickaxe) = gitweb_check_feature
('pickaxe');
4416 if ($have_pickaxe) {
4418 <dt><b>pickaxe</b></dt>
4419 <dd>All commits that caused the string to appear or disappear from any file (changes that
4420 added, removed or "modified" the string) will be listed. This search can take a while and
4421 takes a lot of strain on the server, so please use it wisely.</dd>
4429 my $head = git_get_head_hash
($project);
4430 if (!defined $hash) {
4433 if (!defined $page) {
4436 my $refs = git_get_references
();
4438 my @commitlist = parse_commits
($hash, 101, (100 * $page));
4440 my $paging_nav = format_paging_nav
('shortlog', $hash, $head, $page, (100 * ($page+1)));
4442 if ($#commitlist >= 100) {
4444 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$hash, page
=>$page+1),
4445 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4449 git_print_page_nav
('shortlog','', $hash,$hash,$hash, $paging_nav);
4450 git_print_header_div
('summary', $project);
4452 git_shortlog_body
(\
@commitlist, 0, 99, $refs, $next_link);
4457 ## ......................................................................
4458 ## feeds (RSS, Atom; OPML)
4461 my $format = shift || 'atom';
4462 my ($have_blame) = gitweb_check_feature
('blame');
4464 # Atom: http://www.atomenabled.org/developers/syndication/
4465 # RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
4466 if ($format ne 'rss' && $format ne 'atom') {
4467 die_error
(undef, "Unknown web feed format");
4470 # log/feed of current (HEAD) branch, log of given branch, history of file/directory
4471 my $head = $hash || 'HEAD';
4472 my @commitlist = parse_commits
($head, 150);
4476 my $content_type = "application/$format+xml";
4477 if (defined $cgi->http('HTTP_ACCEPT') &&
4478 $cgi->Accept('text/xml') > $cgi->Accept($content_type)) {
4479 # browser (feed reader) prefers text/xml
4480 $content_type = 'text/xml';
4482 if (defined($commitlist[0])) {
4483 %latest_commit = %{$commitlist[0]};
4484 %latest_date = parse_date
($latest_commit{'author_epoch'});
4486 -type
=> $content_type,
4487 -charset
=> 'utf-8',
4488 -last_modified
=> $latest_date{'rfc2822'});
4491 -type
=> $content_type,
4492 -charset
=> 'utf-8');
4495 # Optimization: skip generating the body if client asks only
4496 # for Last-Modified date.
4497 return if ($cgi->request_method() eq 'HEAD');
4500 my $title = "$site_name - $project/$action";
4501 my $feed_type = 'log';
4502 if (defined $hash) {
4503 $title .= " - '$hash'";
4504 $feed_type = 'branch log';
4505 if (defined $file_name) {
4506 $title .= " :: $file_name";
4507 $feed_type = 'history';
4509 } elsif (defined $file_name) {
4510 $title .= " - $file_name";
4511 $feed_type = 'history';
4513 $title .= " $feed_type";
4514 my $descr = git_get_project_description
($project);
4515 if (defined $descr) {
4516 $descr = esc_html
($descr);
4518 $descr = "$project " .
4519 ($format eq 'rss' ?
'RSS' : 'Atom') .
4522 my $owner = git_get_project_owner
($project);
4523 $owner = esc_html
($owner);
4527 if (defined $file_name) {
4528 $alt_url = href
(-full
=>1, action
=>"history", hash
=>$hash, file_name
=>$file_name);
4529 } elsif (defined $hash) {
4530 $alt_url = href
(-full
=>1, action
=>"log", hash
=>$hash);
4532 $alt_url = href
(-full
=>1, action
=>"summary");
4534 print qq!<?xml version
="1.0" encoding
="utf-8"?
>\n!;
4535 if ($format eq 'rss') {
4537 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
4540 print "<title>$title</title>\n" .
4541 "<link>$alt_url</link>\n" .
4542 "<description>$descr</description>\n" .
4543 "<language>en</language>\n";
4544 } elsif ($format eq 'atom') {
4546 <feed xmlns="http://www.w3.org/2005/Atom">
4548 print "<title>$title</title>\n" .
4549 "<subtitle>$descr</subtitle>\n" .
4550 '<link rel="alternate" type="text/html" href="' .
4551 $alt_url . '" />' . "\n" .
4552 '<link rel="self" type="' . $content_type . '" href="' .
4553 $cgi->self_url() . '" />' . "\n" .
4554 "<id>" . href
(-full
=>1) . "</id>\n" .
4555 # use project owner for feed author
4556 "<author><name>$owner</name></author>\n";
4557 if (defined $favicon) {
4558 print "<icon>" . esc_url
($favicon) . "</icon>\n";
4560 if (defined $logo_url) {
4561 # not twice as wide as tall: 72 x 27 pixels
4562 print "<logo>" . esc_url
($logo) . "</logo>\n";
4564 if (! %latest_date) {
4565 # dummy date to keep the feed valid until commits trickle in:
4566 print "<updated>1970-01-01T00:00:00Z</updated>\n";
4568 print "<updated>$latest_date{'iso-8601'}</updated>\n";
4573 for (my $i = 0; $i <= $#commitlist; $i++) {
4574 my %co = %{$commitlist[$i]};
4575 my $commit = $co{'id'};
4576 # we read 150, we always show 30 and the ones more recent than 48 hours
4577 if (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) {
4580 my %cd = parse_date
($co{'author_epoch'});
4582 # get list of changed files
4583 open my $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4584 $co{'parent'}, $co{'id'}, "--", (defined $file_name ?
$file_name : ())
4586 my @difftree = map { chomp; $_ } <$fd>;
4590 # print element (entry, item)
4591 my $co_url = href
(-full
=>1, action
=>"commit", hash
=>$commit);
4592 if ($format eq 'rss') {
4594 "<title>" . esc_html
($co{'title'}) . "</title>\n" .
4595 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
4596 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
4597 "<guid isPermaLink=\"true\">$co_url</guid>\n" .
4598 "<link>$co_url</link>\n" .
4599 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
4600 "<content:encoded>" .
4602 } elsif ($format eq 'atom') {
4604 "<title type=\"html\">" . esc_html
($co{'title'}) . "</title>\n" .
4605 "<updated>$cd{'iso-8601'}</updated>\n" .
4607 " <name>" . esc_html
($co{'author_name'}) . "</name>\n";
4608 if ($co{'author_email'}) {
4609 print " <email>" . esc_html
($co{'author_email'}) . "</email>\n";
4611 print "</author>\n" .
4612 # use committer for contributor
4614 " <name>" . esc_html
($co{'committer_name'}) . "</name>\n";
4615 if ($co{'committer_email'}) {
4616 print " <email>" . esc_html
($co{'committer_email'}) . "</email>\n";
4618 print "</contributor>\n" .
4619 "<published>$cd{'iso-8601'}</published>\n" .
4620 "<link rel=\"alternate\" type=\"text/html\" href=\"$co_url\" />\n" .
4621 "<id>$co_url</id>\n" .
4622 "<content type=\"xhtml\" xml:base=\"" . esc_url
($my_url) . "\">\n" .
4623 "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
4625 my $comment = $co{'comment'};
4627 foreach my $line (@
$comment) {
4628 $line = esc_html
($line);
4631 print "</pre><ul>\n";
4632 foreach my $difftree_line (@difftree) {
4633 my %difftree = parse_difftree_raw_line
($difftree_line);
4634 next if !$difftree{'from_id'};
4636 my $file = $difftree{'file'} || $difftree{'to_file'};
4640 $cgi->a({-href
=> href
(-full
=>1, action
=>"blobdiff",
4641 hash
=>$difftree{'to_id'}, hash_parent
=>$difftree{'from_id'},
4642 hash_base
=>$co{'id'}, hash_parent_base
=>$co{'parent'},
4643 file_name
=>$file, file_parent
=>$difftree{'from_file'}),
4644 -title
=> "diff"}, 'D');
4646 print $cgi->a({-href
=> href
(-full
=>1, action
=>"blame",
4647 file_name
=>$file, hash_base
=>$commit),
4648 -title
=> "blame"}, 'B');
4650 # if this is not a feed of a file history
4651 if (!defined $file_name || $file_name ne $file) {
4652 print $cgi->a({-href
=> href
(-full
=>1, action
=>"history",
4653 file_name
=>$file, hash
=>$commit),
4654 -title
=> "history"}, 'H');
4656 $file = esc_path
($file);
4660 if ($format eq 'rss') {
4661 print "</ul>]]>\n" .
4662 "</content:encoded>\n" .
4664 } elsif ($format eq 'atom') {
4665 print "</ul>\n</div>\n" .
4672 if ($format eq 'rss') {
4673 print "</channel>\n</rss>\n";
4674 } elsif ($format eq 'atom') {
4688 my @list = git_get_projects_list
();
4690 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
4692 <?xml version="1.0" encoding="utf-8"?>
4693 <opml version="1.0">
4695 <title>$site_name OPML Export</title>
4698 <outline text="git RSS feeds">
4701 foreach my $pr (@list) {
4703 my $head = git_get_head_hash
($proj{'path'});
4704 if (!defined $head) {
4707 $git_dir = "$projectroot/$proj{'path'}";
4708 my %co = parse_commit
($head);
4713 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
4714 my $rss = "$my_url?p=$proj{'path'};a=rss";
4715 my $html = "$my_url?p=$proj{'path'};a=summary";
4716 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";