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 # very thin wrapper for decode("utf8", $str, Encode::FB_DEFAULT);
566 return decode
("utf8", $str, Encode
::FB_DEFAULT
);
569 # quote unsafe chars, but keep the slash, even when it's not
570 # correct, but quoted slashes look too horrible in bookmarks
573 $str =~ s/([^A-Za-z0-9\-_.~()\/:@])/sprintf
("%%%02X", ord($1))/eg
;
579 # quote unsafe chars in whole URL, so some charactrs cannot be quoted
582 $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf
("%%%02X", ord($1))/eg
;
588 # replace invalid utf8 character with SUBSTITUTION sequence
593 $str = to_utf8
($str);
594 $str = escapeHTML
($str);
595 if ($opts{'-nbsp'}) {
596 $str =~ s/ / /g;
598 $str =~ s
|([[:cntrl
:]])|(($1 ne "\t") ? quot_cec
($1) : $1)|eg
;
602 # quote control characters and escape filename to HTML
607 $str = to_utf8
($str);
608 $str = escapeHTML
($str);
609 if ($opts{'-nbsp'}) {
610 $str =~ s/ / /g;
612 $str =~ s
|([[:cntrl
:]])|quot_cec
($1)|eg
;
616 # Make control characters "printable", using character escape codes (CEC)
619 my %es = ( # character escape codes, aka escape sequences
620 "\t" => '\t', # tab (HT)
621 "\n" => '\n', # line feed (LF)
622 "\r" => '\r', # carrige return (CR)
623 "\f" => '\f', # form feed (FF)
624 "\b" => '\b', # backspace (BS)
625 "\a" => '\a', # alarm (bell) (BEL)
626 "\e" => '\e', # escape (ESC)
627 "\013" => '\v', # vertical tab (VT)
628 "\000" => '\0', # nul character (NUL)
630 my $chr = ( (exists $es{$cntrl})
632 : sprintf('\%03o', ord($cntrl)) );
633 return "<span class=\"cntrl\">$chr</span>";
636 # Alternatively use unicode control pictures codepoints,
637 # Unicode "printable representation" (PR)
640 my $chr = sprintf('&#%04d;', 0x2400+ord($cntrl));
641 return "<span class=\"cntrl\">$chr</span>";
644 # git may return quoted and escaped filenames
650 my %es = ( # character escape codes, aka escape sequences
651 't' => "\t", # tab (HT, TAB)
652 'n' => "\n", # newline (NL)
653 'r' => "\r", # return (CR)
654 'f' => "\f", # form feed (FF)
655 'b' => "\b", # backspace (BS)
656 'a' => "\a", # alarm (bell) (BEL)
657 'e' => "\e", # escape (ESC)
658 'v' => "\013", # vertical tab (VT)
661 if ($seq =~ m/^[0-7]{1,3}$/) {
662 # octal char sequence
663 return chr(oct($seq));
664 } elsif (exists $es{$seq}) {
665 # C escape sequence, aka character escape code
668 # quoted ordinary character
672 if ($str =~ m/^"(.*)"$/) {
675 $str =~ s/\\([^0-7]|[0-7]{1,3})/unq($1)/eg;
680 # escape tabs (convert tabs to spaces)
684 while ((my $pos = index($line, "\t")) != -1) {
685 if (my $count = (8 - ($pos % 8))) {
686 my $spaces = ' ' x
$count;
687 $line =~ s/\t/$spaces/;
694 sub project_in_list
{
696 my @list = git_get_projects_list
();
697 return @list && scalar(grep { $_->{'path'} eq $project } @list);
700 ## ----------------------------------------------------------------------
701 ## HTML aware string manipulation
706 my $add_len = shift || 10;
708 # allow only $len chars, but don't cut a word if it would fit in $add_len
709 # if it doesn't fit, cut it if it's still longer than the dots we would add
710 $str =~ m/^(.{0,$len}[^ \/\
-_
:\
.@
]{0,$add_len})(.*)/;
713 if (length($tail) > 4) {
715 $body =~ s/&[^;]*$//; # remove chopped character entities
720 ## ----------------------------------------------------------------------
721 ## functions returning short strings
723 # CSS class for given age value (in seconds)
727 if ($age < 60*60*2) {
729 } elsif ($age < 60*60*24*2) {
736 # convert age in seconds to "nn units ago" string
741 if ($age > 60*60*24*365*2) {
742 $age_str = (int $age/60/60/24/365);
743 $age_str .= " years ago";
744 } elsif ($age > 60*60*24*(365/12)*2) {
745 $age_str = int $age/60/60/24/(365/12);
746 $age_str .= " months ago";
747 } elsif ($age > 60*60*24*7*2) {
748 $age_str = int $age/60/60/24/7;
749 $age_str .= " weeks ago";
750 } elsif ($age > 60*60*24*2) {
751 $age_str = int $age/60/60/24;
752 $age_str .= " days ago";
753 } elsif ($age > 60*60*2) {
754 $age_str = int $age/60/60;
755 $age_str .= " hours ago";
756 } elsif ($age > 60*2) {
757 $age_str = int $age/60;
758 $age_str .= " min ago";
761 $age_str .= " sec ago";
763 $age_str .= " right now";
768 # convert file mode in octal to symbolic file mode string
770 my $mode = oct shift;
772 if (S_ISDIR
($mode & S_IFMT
)) {
774 } elsif (S_ISLNK
($mode)) {
776 } elsif (S_ISREG
($mode)) {
777 # git cares only about the executable bit
778 if ($mode & S_IXUSR
) {
788 # convert file mode in octal to file type string
792 if ($mode !~ m/^[0-7]+$/) {
798 if (S_ISDIR
($mode & S_IFMT
)) {
800 } elsif (S_ISLNK
($mode)) {
802 } elsif (S_ISREG
($mode)) {
809 # convert file mode in octal to file type description string
813 if ($mode !~ m/^[0-7]+$/) {
819 if (S_ISDIR
($mode & S_IFMT
)) {
821 } elsif (S_ISLNK
($mode)) {
823 } elsif (S_ISREG
($mode)) {
824 if ($mode & S_IXUSR
) {
835 ## ----------------------------------------------------------------------
836 ## functions returning short HTML fragments, or transforming HTML fragments
837 ## which don't beling to other sections
839 # format line of commit message.
840 sub format_log_line_html
{
843 $line = esc_html
($line, -nbsp
=>1);
844 if ($line =~ m/([0-9a-fA-F]{8,40})/) {
847 $cgi->a({-href
=> href
(action
=>"object", hash
=>$hash_text),
848 -class => "text"}, $hash_text);
849 $line =~ s/$hash_text/$link/;
854 # format marker of refs pointing to given object
855 sub format_ref_marker
{
856 my ($refs, $id) = @_;
859 if (defined $refs->{$id}) {
860 foreach my $ref (@
{$refs->{$id}}) {
861 my ($type, $name) = qw();
862 # e.g. tags/v2.6.11 or heads/next
863 if ($ref =~ m!^(.*?)s?/(.*)$!) {
871 $markers .= " <span class=\"$type\" title=\"$ref\">" .
872 esc_html
($name) . "</span>";
877 return ' <span class="refs">'. $markers . '</span>';
883 # format, perhaps shortened and with markers, title line
884 sub format_subject_html
{
885 my ($long, $short, $href, $extra) = @_;
886 $extra = '' unless defined($extra);
888 if (length($short) < length($long)) {
889 return $cgi->a({-href
=> $href, -class => "list subject",
890 -title
=> to_utf8
($long)},
891 esc_html
($short) . $extra);
893 return $cgi->a({-href
=> $href, -class => "list subject"},
894 esc_html
($long) . $extra);
898 # format patch (diff) line (rather not to be used for diff headers)
899 sub format_diff_line
{
901 my ($from, $to) = @_;
902 my $char = substr($line, 0, 1);
908 $diff_class = " add";
909 } elsif ($char eq "-") {
910 $diff_class = " rem";
911 } elsif ($char eq "@") {
912 $diff_class = " chunk_header";
913 } elsif ($char eq "\\") {
914 $diff_class = " incomplete";
916 $line = untabify
($line);
917 if ($from && $to && $line =~ m/^\@{2} /) {
918 my ($from_text, $from_start, $from_lines, $to_text, $to_start, $to_lines, $section) =
919 $line =~ m/^\@{2} (-(\d+)(?:,(\d+))?) (\+(\d+)(?:,(\d+))?) \@{2}(.*)$/;
921 $from_lines = 0 unless defined $from_lines;
922 $to_lines = 0 unless defined $to_lines;
924 if ($from->{'href'}) {
925 $from_text = $cgi->a({-href
=>"$from->{'href'}#l$from_start",
926 -class=>"list"}, $from_text);
929 $to_text = $cgi->a({-href
=>"$to->{'href'}#l$to_start",
930 -class=>"list"}, $to_text);
932 $line = "<span class=\"chunk_info\">@@ $from_text $to_text @@</span>" .
933 "<span class=\"section\">" . esc_html
($section, -nbsp
=>1) . "</span>";
934 return "<div class=\"diff$diff_class\">$line</div>\n";
936 return "<div class=\"diff$diff_class\">" . esc_html
($line, -nbsp
=>1) . "</div>\n";
939 ## ----------------------------------------------------------------------
940 ## git utility subroutines, invoking git commands
942 # returns path to the core git executable and the --git-dir parameter as list
944 return $GIT, '--git-dir='.$git_dir;
947 # returns path to the core git executable and the --git-dir parameter as string
949 return join(' ', git_cmd
());
952 # get HEAD ref of given project as hash
953 sub git_get_head_hash
{
955 my $o_git_dir = $git_dir;
957 $git_dir = "$projectroot/$project";
958 if (open my $fd, "-|", git_cmd
(), "rev-parse", "--verify", "HEAD") {
961 if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
965 if (defined $o_git_dir) {
966 $git_dir = $o_git_dir;
971 # get type of given object
975 open my $fd, "-|", git_cmd
(), "cat-file", '-t', $hash or return;
982 sub git_get_project_config
{
983 my ($key, $type) = @_;
985 return unless ($key);
986 $key =~ s/^gitweb\.//;
987 return if ($key =~ m/\W/);
989 my @x = (git_cmd
(), 'repo-config');
990 if (defined $type) { push @x, $type; }
992 push @x, "gitweb.$key";
998 # get hash of given path at given ref
999 sub git_get_hash_by_path
{
1001 my $path = shift || return undef;
1006 open my $fd, "-|", git_cmd
(), "ls-tree", $base, "--", $path
1007 or die_error
(undef, "Open git-ls-tree failed");
1009 close $fd or return undef;
1011 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1012 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/;
1013 if (defined $type && $type ne $2) {
1014 # type doesn't match
1020 ## ......................................................................
1021 ## git utility functions, directly accessing git repository
1023 sub git_get_project_description
{
1026 open my $fd, "$projectroot/$path/description" or return undef;
1033 sub git_get_project_url_list
{
1036 open my $fd, "$projectroot/$path/cloneurl" or return;
1037 my @git_project_url_list = map { chomp; $_ } <$fd>;
1040 return wantarray ?
@git_project_url_list : \
@git_project_url_list;
1043 sub git_get_projects_list
{
1048 $filter =~ s/\.git$//;
1050 if (-d
$projects_list) {
1051 # search in directory
1052 my $dir = $projects_list . ($filter ?
"/$filter" : '');
1053 # remove the trailing "/"
1055 my $pfxlen = length("$dir");
1057 my ($check_forks) = gitweb_check_feature
('forks');
1060 follow_fast
=> 1, # follow symbolic links
1061 dangling_symlinks
=> 0, # ignore dangling symlinks, silently
1063 # skip project-list toplevel, if we get it.
1064 return if (m!^[/.]$!);
1065 # only directories can be git repositories
1066 return unless (-d
$_);
1068 my $subdir = substr($File::Find
::name
, $pfxlen + 1);
1069 # we check related file in $projectroot
1070 if ($check_forks and $subdir =~ m
#/.#) {
1071 $File::Find
::prune
= 1;
1072 } elsif (check_export_ok
("$projectroot/$filter/$subdir")) {
1073 push @list, { path
=> ($filter ?
"$filter/" : '') . $subdir };
1074 $File::Find
::prune
= 1;
1079 } elsif (-f
$projects_list) {
1080 # read from file(url-encoded):
1081 # 'git%2Fgit.git Linus+Torvalds'
1082 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
1083 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
1084 open my ($fd), $projects_list or return;
1085 while (my $line = <$fd>) {
1087 my ($path, $owner) = split ' ', $line;
1088 $path = unescape
($path);
1089 $owner = unescape
($owner);
1090 if (!defined $path) {
1093 if ($filter ne '') {
1094 # looking for forks;
1095 my $pfx = substr($path, 0, length($filter));
1096 if ($pfx ne $filter) {
1099 my $sfx = substr($path, length($filter));
1100 if ($sfx !~ /^\/.*\
.git
$/) {
1104 if (check_export_ok
("$projectroot/$path")) {
1107 owner
=> to_utf8
($owner),
1114 @list = sort {$a->{'path'} cmp $b->{'path'}} @list;
1118 sub git_get_project_owner
{
1119 my $project = shift;
1122 return undef unless $project;
1124 # read from file (url-encoded):
1125 # 'git%2Fgit.git Linus+Torvalds'
1126 # 'libs%2Fklibc%2Fklibc.git H.+Peter+Anvin'
1127 # 'linux%2Fhotplug%2Fudev.git Greg+Kroah-Hartman'
1128 if (-f
$projects_list) {
1129 open (my $fd , $projects_list);
1130 while (my $line = <$fd>) {
1132 my ($pr, $ow) = split ' ', $line;
1133 $pr = unescape
($pr);
1134 $ow = unescape
($ow);
1135 if ($pr eq $project) {
1136 $owner = to_utf8
($ow);
1142 if (!defined $owner) {
1143 $owner = get_file_owner
("$projectroot/$project");
1149 sub git_get_last_activity
{
1153 $git_dir = "$projectroot/$path";
1154 open($fd, "-|", git_cmd
(), 'for-each-ref',
1155 '--format=%(committer)',
1156 '--sort=-committerdate',
1158 'refs/heads') or return;
1159 my $most_recent = <$fd>;
1160 close $fd or return;
1161 if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
1163 my $age = time - $timestamp;
1164 return ($age, age_string
($age));
1168 sub git_get_references
{
1169 my $type = shift || "";
1171 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
1172 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
1173 open my $fd, "-|", git_cmd
(), "show-ref", "--dereference",
1174 ($type ?
("--", "refs/$type") : ()) # use -- <pattern> if $type
1177 while (my $line = <$fd>) {
1179 if ($line =~ m!^([0-9a-fA-F]{40})\srefs/($type/?[^^]+)!) {
1180 if (defined $refs{$1}) {
1181 push @
{$refs{$1}}, $2;
1187 close $fd or return;
1191 sub git_get_rev_name_tags
{
1192 my $hash = shift || return undef;
1194 open my $fd, "-|", git_cmd
(), "name-rev", "--tags", $hash
1196 my $name_rev = <$fd>;
1199 if ($name_rev =~ m
|^$hash tags
/(.*)$|) {
1202 # catches also '$hash undefined' output
1207 ## ----------------------------------------------------------------------
1208 ## parse to hash functions
1212 my $tz = shift || "-0000";
1215 my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
1216 my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
1217 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch);
1218 $date{'hour'} = $hour;
1219 $date{'minute'} = $min;
1220 $date{'mday'} = $mday;
1221 $date{'day'} = $days[$wday];
1222 $date{'month'} = $months[$mon];
1223 $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000",
1224 $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;
1225 $date{'mday-time'} = sprintf "%d %s %02d:%02d",
1226 $mday, $months[$mon], $hour ,$min;
1227 $date{'iso-8601'} = sprintf "%04d-%02d-%02dT%02d:%02d:%02dZ",
1228 1900+$year, $mon, $mday, $hour ,$min, $sec;
1230 $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
1231 my $local = $epoch + ((int $1 + ($2/60)) * 3600);
1232 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
1233 $date{'hour_local'} = $hour;
1234 $date{'minute_local'} = $min;
1235 $date{'tz_local'} = $tz;
1236 $date{'iso-tz'} = sprintf("%04d-%02d-%02d %02d:%02d:%02d %s",
1237 1900+$year, $mon+1, $mday,
1238 $hour, $min, $sec, $tz);
1247 open my $fd, "-|", git_cmd
(), "cat-file", "tag", $tag_id or return;
1248 $tag{'id'} = $tag_id;
1249 while (my $line = <$fd>) {
1251 if ($line =~ m/^object ([0-9a-fA-F]{40})$/) {
1252 $tag{'object'} = $1;
1253 } elsif ($line =~ m/^type (.+)$/) {
1255 } elsif ($line =~ m/^tag (.+)$/) {
1257 } elsif ($line =~ m/^tagger (.*) ([0-9]+) (.*)$/) {
1258 $tag{'author'} = $1;
1261 } elsif ($line =~ m/--BEGIN/) {
1262 push @comment, $line;
1264 } elsif ($line eq "") {
1268 push @comment, <$fd>;
1269 $tag{'comment'} = \
@comment;
1270 close $fd or return;
1271 if (!defined $tag{'name'}) {
1277 sub parse_commit_text
{
1278 my ($commit_text, $withparents) = @_;
1279 my @commit_lines = split '\n', $commit_text;
1282 pop @commit_lines; # Remove '\0'
1284 my $header = shift @commit_lines;
1285 if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
1288 ($co{'id'}, my @parents) = split ' ', $header;
1289 while (my $line = shift @commit_lines) {
1290 last if $line eq "\n";
1291 if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
1293 } elsif ((!defined $withparents) && ($line =~ m/^parent ([0-9a-fA-F]{40})$/)) {
1295 } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
1297 $co{'author_epoch'} = $2;
1298 $co{'author_tz'} = $3;
1299 if ($co{'author'} =~ m/^([^<]+) <([^>]*)>/) {
1300 $co{'author_name'} = $1;
1301 $co{'author_email'} = $2;
1303 $co{'author_name'} = $co{'author'};
1305 } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) {
1306 $co{'committer'} = $1;
1307 $co{'committer_epoch'} = $2;
1308 $co{'committer_tz'} = $3;
1309 $co{'committer_name'} = $co{'committer'};
1310 if ($co{'committer'} =~ m/^([^<]+) <([^>]*)>/) {
1311 $co{'committer_name'} = $1;
1312 $co{'committer_email'} = $2;
1314 $co{'committer_name'} = $co{'committer'};
1318 if (!defined $co{'tree'}) {
1321 $co{'parents'} = \
@parents;
1322 $co{'parent'} = $parents[0];
1324 foreach my $title (@commit_lines) {
1327 $co{'title'} = chop_str
($title, 80, 5);
1328 # remove leading stuff of merges to make the interesting part visible
1329 if (length($title) > 50) {
1330 $title =~ s/^Automatic //;
1331 $title =~ s/^merge (of|with) /Merge ... /i;
1332 if (length($title) > 50) {
1333 $title =~ s/(http|rsync):\/\///;
1335 if (length($title) > 50) {
1336 $title =~ s/(master|www|rsync)\.//;
1338 if (length($title) > 50) {
1339 $title =~ s/kernel.org:?//;
1341 if (length($title) > 50) {
1342 $title =~ s/\/pub\/scm//;
1345 $co{'title_short'} = chop_str
($title, 50, 5);
1349 if ($co{'title'} eq "") {
1350 $co{'title'} = $co{'title_short'} = '(no commit message)';
1352 # remove added spaces
1353 foreach my $line (@commit_lines) {
1356 $co{'comment'} = \
@commit_lines;
1358 my $age = time - $co{'committer_epoch'};
1360 $co{'age_string'} = age_string
($age);
1361 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($co{'committer_epoch'});
1362 if ($age > 60*60*24*7*2) {
1363 $co{'age_string_date'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
1364 $co{'age_string_age'} = $co{'age_string'};
1366 $co{'age_string_date'} = $co{'age_string'};
1367 $co{'age_string_age'} = sprintf "%4i-%02u-%02i", 1900 + $year, $mon+1, $mday;
1373 my ($commit_id) = @_;
1378 open my $fd, "-|", git_cmd
(), "rev-list",
1384 or die_error
(undef, "Open git-rev-list failed");
1385 %co = parse_commit_text
(<$fd>, 1);
1392 my ($commit_id, $maxcount, $skip, $arg, $filename) = @_;
1400 open my $fd, "-|", git_cmd
(), "rev-list",
1402 ($arg ?
($arg) : ()),
1403 ("--max-count=" . $maxcount),
1404 ("--skip=" . $skip),
1407 ($filename ?
($filename) : ())
1408 or die_error
(undef, "Open git-rev-list failed");
1409 while (my $line = <$fd>) {
1410 my %co = parse_commit_text
($line);
1415 return wantarray ?
@cos : \
@cos;
1418 # parse ref from ref_file, given by ref_id, with given type
1420 my $ref_file = shift;
1422 my $type = shift || git_get_type
($ref_id);
1425 $ref_item{'type'} = $type;
1426 $ref_item{'id'} = $ref_id;
1427 $ref_item{'epoch'} = 0;
1428 $ref_item{'age'} = "unknown";
1429 if ($type eq "tag") {
1430 my %tag = parse_tag
($ref_id);
1431 $ref_item{'comment'} = $tag{'comment'};
1432 if ($tag{'type'} eq "commit") {
1433 my %co = parse_commit
($tag{'object'});
1434 $ref_item{'epoch'} = $co{'committer_epoch'};
1435 $ref_item{'age'} = $co{'age_string'};
1436 } elsif (defined($tag{'epoch'})) {
1437 my $age = time - $tag{'epoch'};
1438 $ref_item{'epoch'} = $tag{'epoch'};
1439 $ref_item{'age'} = age_string
($age);
1441 $ref_item{'reftype'} = $tag{'type'};
1442 $ref_item{'name'} = $tag{'name'};
1443 $ref_item{'refid'} = $tag{'object'};
1444 } elsif ($type eq "commit"){
1445 my %co = parse_commit
($ref_id);
1446 $ref_item{'reftype'} = "commit";
1447 $ref_item{'name'} = $ref_file;
1448 $ref_item{'title'} = $co{'title'};
1449 $ref_item{'refid'} = $ref_id;
1450 $ref_item{'epoch'} = $co{'committer_epoch'};
1451 $ref_item{'age'} = $co{'age_string'};
1453 $ref_item{'reftype'} = $type;
1454 $ref_item{'name'} = $ref_file;
1455 $ref_item{'refid'} = $ref_id;
1461 # parse line of git-diff-tree "raw" output
1462 sub parse_difftree_raw_line
{
1466 # ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M ls-files.c'
1467 # ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M rev-tree.c'
1468 if ($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
1469 $res{'from_mode'} = $1;
1470 $res{'to_mode'} = $2;
1471 $res{'from_id'} = $3;
1473 $res{'status'} = $5;
1474 $res{'similarity'} = $6;
1475 if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
1476 ($res{'from_file'}, $res{'to_file'}) = map { unquote
($_) } split("\t", $7);
1478 $res{'file'} = unquote
($7);
1481 # 'c512b523472485aef4fff9e57b229d9d243c967f'
1482 elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
1483 $res{'commit'} = $1;
1486 return wantarray ?
%res : \
%res;
1489 # parse line of git-ls-tree output
1490 sub parse_ls_tree_line
($;%) {
1495 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1496 $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/s;
1504 $res{'name'} = unquote
($4);
1507 return wantarray ?
%res : \
%res;
1510 ## ......................................................................
1511 ## parse to array of hashes functions
1513 sub git_get_heads_list
{
1517 open my $fd, '-|', git_cmd
(), 'for-each-ref',
1518 ($limit ?
'--count='.($limit+1) : ()), '--sort=-committerdate',
1519 '--format=%(objectname) %(refname) %(subject)%00%(committer)',
1522 while (my $line = <$fd>) {
1526 my ($refinfo, $committerinfo) = split(/\0/, $line);
1527 my ($hash, $name, $title) = split(' ', $refinfo, 3);
1528 my ($committer, $epoch, $tz) =
1529 ($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
1530 $name =~ s!^refs/heads/!!;
1532 $ref_item{'name'} = $name;
1533 $ref_item{'id'} = $hash;
1534 $ref_item{'title'} = $title || '(no commit message)';
1535 $ref_item{'epoch'} = $epoch;
1537 $ref_item{'age'} = age_string
(time - $ref_item{'epoch'});
1539 $ref_item{'age'} = "unknown";
1542 push @headslist, \
%ref_item;
1546 return wantarray ?
@headslist : \
@headslist;
1549 sub git_get_tags_list
{
1553 open my $fd, '-|', git_cmd
(), 'for-each-ref',
1554 ($limit ?
'--count='.($limit+1) : ()), '--sort=-creatordate',
1555 '--format=%(objectname) %(objecttype) %(refname) '.
1556 '%(*objectname) %(*objecttype) %(subject)%00%(creator)',
1559 while (my $line = <$fd>) {
1563 my ($refinfo, $creatorinfo) = split(/\0/, $line);
1564 my ($id, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);
1565 my ($creator, $epoch, $tz) =
1566 ($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);
1567 $name =~ s!^refs/tags/!!;
1569 $ref_item{'type'} = $type;
1570 $ref_item{'id'} = $id;
1571 $ref_item{'name'} = $name;
1572 if ($type eq "tag") {
1573 $ref_item{'subject'} = $title;
1574 $ref_item{'reftype'} = $reftype;
1575 $ref_item{'refid'} = $refid;
1577 $ref_item{'reftype'} = $type;
1578 $ref_item{'refid'} = $id;
1581 if ($type eq "tag" || $type eq "commit") {
1582 $ref_item{'epoch'} = $epoch;
1584 $ref_item{'age'} = age_string
(time - $ref_item{'epoch'});
1586 $ref_item{'age'} = "unknown";
1590 push @tagslist, \
%ref_item;
1594 return wantarray ?
@tagslist : \
@tagslist;
1597 ## ----------------------------------------------------------------------
1598 ## filesystem-related functions
1600 sub get_file_owner
{
1603 my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat($path);
1604 my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid);
1605 if (!defined $gcos) {
1609 $owner =~ s/[,;].*$//;
1610 return to_utf8
($owner);
1613 ## ......................................................................
1614 ## mimetype related functions
1616 sub mimetype_guess_file
{
1617 my $filename = shift;
1618 my $mimemap = shift;
1619 -r
$mimemap or return undef;
1622 open(MIME
, $mimemap) or return undef;
1624 next if m/^#/; # skip comments
1625 my ($mime, $exts) = split(/\t+/);
1626 if (defined $exts) {
1627 my @exts = split(/\s+/, $exts);
1628 foreach my $ext (@exts) {
1629 $mimemap{$ext} = $mime;
1635 $filename =~ /\.([^.]*)$/;
1636 return $mimemap{$1};
1639 sub mimetype_guess
{
1640 my $filename = shift;
1642 $filename =~ /\./ or return undef;
1644 if ($mimetypes_file) {
1645 my $file = $mimetypes_file;
1646 if ($file !~ m!^/!) { # if it is relative path
1647 # it is relative to project
1648 $file = "$projectroot/$project/$file";
1650 $mime = mimetype_guess_file
($filename, $file);
1652 $mime ||= mimetype_guess_file
($filename, '/etc/mime.types');
1658 my $filename = shift;
1661 my $mime = mimetype_guess
($filename);
1662 $mime and return $mime;
1666 return $default_blob_plain_mimetype unless $fd;
1669 return 'text/plain' .
1670 ($default_text_plain_charset ?
'; charset='.$default_text_plain_charset : '');
1671 } elsif (! $filename) {
1672 return 'application/octet-stream';
1673 } elsif ($filename =~ m/\.png$/i) {
1675 } elsif ($filename =~ m/\.gif$/i) {
1677 } elsif ($filename =~ m/\.jpe?g$/i) {
1678 return 'image/jpeg';
1680 return 'application/octet-stream';
1684 ## ======================================================================
1685 ## functions printing HTML: header, footer, error page
1687 sub git_header_html
{
1688 my $status = shift || "200 OK";
1689 my $expires = shift;
1691 my $title = "$site_name";
1692 if (defined $project) {
1693 $title .= " - $project";
1694 if (defined $action) {
1695 $title .= "/$action";
1696 if (defined $file_name) {
1697 $title .= " - " . esc_path
($file_name);
1698 if ($action eq "tree" && $file_name !~ m
|/$|) {
1705 # require explicit support from the UA if we are to send the page as
1706 # 'application/xhtml+xml', otherwise send it as plain old 'text/html'.
1707 # we have to do this because MSIE sometimes globs '*/*', pretending to
1708 # support xhtml+xml but choking when it gets what it asked for.
1709 if (defined $cgi->http('HTTP_ACCEPT') &&
1710 $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\
+xml
(,|;|\s
|$)/ &&
1711 $cgi->Accept('application/xhtml+xml') != 0) {
1712 $content_type = 'application/xhtml+xml';
1714 $content_type = 'text/html';
1716 print $cgi->header(-type
=>$content_type, -charset
=> 'utf-8',
1717 -status
=> $status, -expires
=> $expires);
1718 my $mod_perl_version = $ENV{'MOD_PERL'} ?
" $ENV{'MOD_PERL'}" : '';
1720 <?xml version="1.0" encoding="utf-8"?>
1721 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1722 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
1723 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
1724 <!-- git core binaries version $git_version -->
1726 <meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
1727 <meta name="generator" content="gitweb/$version git/$git_version$mod_perl_version"/>
1728 <meta name="robots" content="index, nofollow"/>
1729 <title>$title</title>
1731 # print out each stylesheet that exist
1732 if (defined $stylesheet) {
1733 #provides backwards capability for those people who define style sheet in a config file
1734 print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
1736 foreach my $stylesheet (@stylesheets) {
1737 next unless $stylesheet;
1738 print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
1741 if (defined $project) {
1742 printf('<link rel="alternate" title="%s log RSS feed" '.
1743 'href="%s" type="application/rss+xml" />'."\n",
1744 esc_param
($project), href
(action
=>"rss"));
1745 printf('<link rel="alternate" title="%s log Atom feed" '.
1746 'href="%s" type="application/atom+xml" />'."\n",
1747 esc_param
($project), href
(action
=>"atom"));
1749 printf('<link rel="alternate" title="%s projects list" '.
1750 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
1751 $site_name, href
(project
=>undef, action
=>"project_index"));
1752 printf('<link rel="alternate" title="%s projects feeds" '.
1753 'href="%s" type="text/x-opml"/>'."\n",
1754 $site_name, href
(project
=>undef, action
=>"opml"));
1756 if (defined $favicon) {
1757 print qq(<link rel
="shortcut icon" href
="$favicon" type
="image/png"/>\n);
1763 if (-f
$site_header) {
1764 open (my $fd, $site_header);
1769 print "<div class=\"page_header\">\n" .
1770 $cgi->a({-href
=> esc_url
($logo_url),
1771 -title
=> $logo_label},
1772 qq(<img src
="$logo" width
="72" height
="27" alt
="git" class="logo"/>));
1773 print $cgi->a({-href
=> esc_url
($home_link)}, $home_link_str) . " / ";
1774 if (defined $project) {
1775 print $cgi->a({-href
=> href
(action
=>"summary")}, esc_html
($project));
1776 if (defined $action) {
1781 my ($have_search) = gitweb_check_feature
('search');
1782 if ((defined $project) && ($have_search)) {
1783 if (!defined $searchtext) {
1787 if (defined $hash_base) {
1788 $search_hash = $hash_base;
1789 } elsif (defined $hash) {
1790 $search_hash = $hash;
1792 $search_hash = "HEAD";
1794 $cgi->param("a", "search");
1795 $cgi->param("h", $search_hash);
1796 $cgi->param("p", $project);
1797 print $cgi->startform(-method
=> "get", -action
=> $my_uri) .
1798 "<div class=\"search\">\n" .
1799 $cgi->hidden(-name
=> "p") . "\n" .
1800 $cgi->hidden(-name
=> "a") . "\n" .
1801 $cgi->hidden(-name
=> "h") . "\n" .
1802 $cgi->popup_menu(-name
=> 'st', -default => 'commit',
1803 -values => ['commit', 'author', 'committer', 'pickaxe']) .
1804 $cgi->sup($cgi->a({-href
=> href
(action
=>"search_help")}, "?")) .
1806 $cgi->textfield(-name
=> "s", -value
=> $searchtext) . "\n" .
1808 $cgi->end_form() . "\n";
1813 sub git_footer_html
{
1814 print "<div class=\"page_footer\">\n";
1815 if (defined $project) {
1816 my $descr = git_get_project_description
($project);
1817 if (defined $descr) {
1818 print "<div class=\"page_footer_text\">" . esc_html
($descr) . "</div>\n";
1820 print $cgi->a({-href
=> href
(action
=>"rss"),
1821 -class => "rss_logo"}, "RSS") . " ";
1822 print $cgi->a({-href
=> href
(action
=>"atom"),
1823 -class => "rss_logo"}, "Atom") . "\n";
1825 print $cgi->a({-href
=> href
(project
=>undef, action
=>"opml"),
1826 -class => "rss_logo"}, "OPML") . " ";
1827 print $cgi->a({-href
=> href
(project
=>undef, action
=>"project_index"),
1828 -class => "rss_logo"}, "TXT") . "\n";
1832 if (-f
$site_footer) {
1833 open (my $fd, $site_footer);
1843 my $status = shift || "403 Forbidden";
1844 my $error = shift || "Malformed query, file missing or permission denied";
1846 git_header_html
($status);
1848 <div class="page_body">
1858 ## ----------------------------------------------------------------------
1859 ## functions printing or outputting HTML: navigation
1861 sub git_print_page_nav
{
1862 my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
1863 $extra = '' if !defined $extra; # pager or formats
1865 my @navs = qw(summary shortlog log commit commitdiff tree);
1867 @navs = grep { $_ ne $suppress } @navs;
1870 my %arg = map { $_ => {action
=>$_} } @navs;
1871 if (defined $head) {
1872 for (qw(commit commitdiff)) {
1873 $arg{$_}{hash
} = $head;
1875 if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
1876 for (qw(shortlog log)) {
1877 $arg{$_}{hash
} = $head;
1881 $arg{tree
}{hash
} = $treehead if defined $treehead;
1882 $arg{tree
}{hash_base
} = $treebase if defined $treebase;
1884 print "<div class=\"page_nav\">\n" .
1886 map { $_ eq $current ?
1887 $_ : $cgi->a({-href
=> href
(%{$arg{$_}})}, "$_")
1889 print "<br/>\n$extra<br/>\n" .
1893 sub format_paging_nav
{
1894 my ($action, $hash, $head, $page, $nrevs) = @_;
1898 if ($hash ne $head || $page) {
1899 $paging_nav .= $cgi->a({-href
=> href
(action
=>$action)}, "HEAD");
1901 $paging_nav .= "HEAD";
1905 $paging_nav .= " ⋅ " .
1906 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page-1),
1907 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
1909 $paging_nav .= " ⋅ prev";
1912 if ($nrevs >= (100 * ($page+1)-1)) {
1913 $paging_nav .= " ⋅ " .
1914 $cgi->a({-href
=> href
(action
=>$action, hash
=>$hash, page
=>$page+1),
1915 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
1917 $paging_nav .= " ⋅ next";
1923 ## ......................................................................
1924 ## functions printing or outputting HTML: div
1926 sub git_print_header_div
{
1927 my ($action, $title, $hash, $hash_base) = @_;
1930 $args{action
} = $action;
1931 $args{hash
} = $hash if $hash;
1932 $args{hash_base
} = $hash_base if $hash_base;
1934 print "<div class=\"header\">\n" .
1935 $cgi->a({-href
=> href
(%args), -class => "title"},
1936 $title ?
$title : $action) .
1940 #sub git_print_authorship (\%) {
1941 sub git_print_authorship
{
1944 my %ad = parse_date
($co->{'author_epoch'}, $co->{'author_tz'});
1945 print "<div class=\"author_date\">" .
1946 esc_html
($co->{'author_name'}) .
1948 if ($ad{'hour_local'} < 6) {
1949 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
1950 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1952 printf(" (%02d:%02d %s)",
1953 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
1958 sub git_print_page_path
{
1964 print "<div class=\"page_path\">";
1965 print $cgi->a({-href
=> href
(action
=>"tree", hash_base
=>$hb),
1966 -title
=> 'tree root'}, "[$project]");
1968 if (defined $name) {
1969 my @dirname = split '/', $name;
1970 my $basename = pop @dirname;
1973 foreach my $dir (@dirname) {
1974 $fullname .= ($fullname ?
'/' : '') . $dir;
1975 print $cgi->a({-href
=> href
(action
=>"tree", file_name
=>$fullname,
1977 -title
=> esc_html
($fullname)}, esc_path
($dir));
1980 if (defined $type && $type eq 'blob') {
1981 print $cgi->a({-href
=> href
(action
=>"blob_plain", file_name
=>$file_name,
1983 -title
=> esc_html
($name)}, esc_path
($basename));
1984 } elsif (defined $type && $type eq 'tree') {
1985 print $cgi->a({-href
=> href
(action
=>"tree", file_name
=>$file_name,
1987 -title
=> esc_html
($name)}, esc_path
($basename));
1990 print esc_path
($basename);
1993 print "<br/></div>\n";
1996 # sub git_print_log (\@;%) {
1997 sub git_print_log
($;%) {
2001 if ($opts{'-remove_title'}) {
2002 # remove title, i.e. first line of log
2005 # remove leading empty lines
2006 while (defined $log->[0] && $log->[0] eq "") {
2013 foreach my $line (@
$log) {
2014 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
2017 if (! $opts{'-remove_signoff'}) {
2018 print "<span class=\"signoff\">" . esc_html
($line) . "</span><br/>\n";
2021 # remove signoff lines
2028 # print only one empty line
2029 # do not print empty line after signoff
2031 next if ($empty || $signoff);
2037 print format_log_line_html
($line) . "<br/>\n";
2040 if ($opts{'-final_empty_line'}) {
2041 # end with single empty line
2042 print "<br/>\n" unless $empty;
2046 # return link target (what link points to)
2047 sub git_get_link_target
{
2052 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
2056 $link_target = <$fd>;
2061 return $link_target;
2064 # given link target, and the directory (basedir) the link is in,
2065 # return target of link relative to top directory (top tree);
2066 # return undef if it is not possible (including absolute links).
2067 sub normalize_link_target
{
2068 my ($link_target, $basedir, $hash_base) = @_;
2070 # we can normalize symlink target only if $hash_base is provided
2071 return unless $hash_base;
2073 # absolute symlinks (beginning with '/') cannot be normalized
2074 return if (substr($link_target, 0, 1) eq '/');
2076 # normalize link target to path from top (root) tree (dir)
2079 $path = $basedir . '/' . $link_target;
2081 # we are in top (root) tree (dir)
2082 $path = $link_target;
2085 # remove //, /./, and /../
2087 foreach my $part (split('/', $path)) {
2088 # discard '.' and ''
2089 next if (!$part || $part eq '.');
2091 if ($part eq '..') {
2095 # link leads outside repository (outside top dir)
2099 push @path_parts, $part;
2102 $path = join('/', @path_parts);
2107 # print tree entry (row of git_tree), but without encompassing <tr> element
2108 sub git_print_tree_entry
{
2109 my ($t, $basedir, $hash_base, $have_blame) = @_;
2112 $base_key{'hash_base'} = $hash_base if defined $hash_base;
2114 # The format of a table row is: mode list link. Where mode is
2115 # the mode of the entry, list is the name of the entry, an href,
2116 # and link is the action links of the entry.
2118 print "<td class=\"mode\">" . mode_str
($t->{'mode'}) . "</td>\n";
2119 if ($t->{'type'} eq "blob") {
2120 print "<td class=\"list\">" .
2121 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t->{'hash'},
2122 file_name
=>"$basedir$t->{'name'}", %base_key),
2123 -class => "list"}, esc_path
($t->{'name'}));
2124 if (S_ISLNK
(oct $t->{'mode'})) {
2125 my $link_target = git_get_link_target
($t->{'hash'});
2127 my $norm_target = normalize_link_target
($link_target, $basedir, $hash_base);
2128 if (defined $norm_target) {
2130 $cgi->a({-href
=> href
(action
=>"object", hash_base
=>$hash_base,
2131 file_name
=>$norm_target),
2132 -title
=> $norm_target}, esc_path
($link_target));
2134 print " -> " . esc_path
($link_target);
2139 print "<td class=\"link\">";
2140 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$t->{'hash'},
2141 file_name
=>"$basedir$t->{'name'}", %base_key)},
2145 $cgi->a({-href
=> href
(action
=>"blame", hash
=>$t->{'hash'},
2146 file_name
=>"$basedir$t->{'name'}", %base_key)},
2149 if (defined $hash_base) {
2151 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2152 hash
=>$t->{'hash'}, file_name
=>"$basedir$t->{'name'}")},
2156 $cgi->a({-href
=> href
(action
=>"blob_plain", hash_base
=>$hash_base,
2157 file_name
=>"$basedir$t->{'name'}")},
2161 } elsif ($t->{'type'} eq "tree") {
2162 print "<td class=\"list\">";
2163 print $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t->{'hash'},
2164 file_name
=>"$basedir$t->{'name'}", %base_key)},
2165 esc_path
($t->{'name'}));
2167 print "<td class=\"link\">";
2168 print $cgi->a({-href
=> href
(action
=>"tree", hash
=>$t->{'hash'},
2169 file_name
=>"$basedir$t->{'name'}", %base_key)},
2171 if (defined $hash_base) {
2173 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
2174 file_name
=>"$basedir$t->{'name'}")},
2181 ## ......................................................................
2182 ## functions printing large fragments of HTML
2184 sub git_difftree_body
{
2185 my ($difftree, $hash, $parent) = @_;
2186 my ($have_blame) = gitweb_check_feature
('blame');
2187 print "<div class=\"list_head\">\n";
2188 if ($#{$difftree} > 10) {
2189 print(($#{$difftree} + 1) . " files changed:\n");
2193 print "<table class=\"diff_tree\">\n";
2196 foreach my $line (@
{$difftree}) {
2197 my %diff = parse_difftree_raw_line
($line);
2200 print "<tr class=\"dark\">\n";
2202 print "<tr class=\"light\">\n";
2206 my ($to_mode_oct, $to_mode_str, $to_file_type);
2207 my ($from_mode_oct, $from_mode_str, $from_file_type);
2208 if ($diff{'to_mode'} ne ('0' x
6)) {
2209 $to_mode_oct = oct $diff{'to_mode'};
2210 if (S_ISREG
($to_mode_oct)) { # only for regular file
2211 $to_mode_str = sprintf("%04o", $to_mode_oct & 0777); # permission bits
2213 $to_file_type = file_type
($diff{'to_mode'});
2215 if ($diff{'from_mode'} ne ('0' x
6)) {
2216 $from_mode_oct = oct $diff{'from_mode'};
2217 if (S_ISREG
($to_mode_oct)) { # only for regular file
2218 $from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
2220 $from_file_type = file_type
($diff{'from_mode'});
2223 if ($diff{'status'} eq "A") { # created
2224 my $mode_chng = "<span class=\"file_status new\">[new $to_file_type";
2225 $mode_chng .= " with mode: $to_mode_str" if $to_mode_str;
2226 $mode_chng .= "]</span>";
2228 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2229 hash_base
=>$hash, file_name
=>$diff{'file'}),
2230 -class => "list"}, esc_path
($diff{'file'}));
2232 print "<td>$mode_chng</td>\n";
2233 print "<td class=\"link\">";
2234 if ($action eq 'commitdiff') {
2237 print $cgi->a({-href
=> "#patch$patchno"}, "patch");
2240 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2241 hash_base
=>$hash, file_name
=>$diff{'file'})},
2245 } elsif ($diff{'status'} eq "D") { # deleted
2246 my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
2248 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
2249 hash_base
=>$parent, file_name
=>$diff{'file'}),
2250 -class => "list"}, esc_path
($diff{'file'}));
2252 print "<td>$mode_chng</td>\n";
2253 print "<td class=\"link\">";
2254 if ($action eq 'commitdiff') {
2257 print $cgi->a({-href
=> "#patch$patchno"}, "patch");
2260 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'from_id'},
2261 hash_base
=>$parent, file_name
=>$diff{'file'})},
2264 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$parent,
2265 file_name
=>$diff{'file'})},
2268 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$parent,
2269 file_name
=>$diff{'file'})},
2273 } elsif ($diff{'status'} eq "M" || $diff{'status'} eq "T") { # modified, or type changed
2274 my $mode_chnge = "";
2275 if ($diff{'from_mode'} != $diff{'to_mode'}) {
2276 $mode_chnge = "<span class=\"file_status mode_chnge\">[changed";
2277 if ($from_file_type ne $to_file_type) {
2278 $mode_chnge .= " from $from_file_type to $to_file_type";
2280 if (($from_mode_oct & 0777) != ($to_mode_oct & 0777)) {
2281 if ($from_mode_str && $to_mode_str) {
2282 $mode_chnge .= " mode: $from_mode_str->$to_mode_str";
2283 } elsif ($to_mode_str) {
2284 $mode_chnge .= " mode: $to_mode_str";
2287 $mode_chnge .= "]</span>\n";
2290 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2291 hash_base
=>$hash, file_name
=>$diff{'file'}),
2292 -class => "list"}, esc_path
($diff{'file'}));
2294 print "<td>$mode_chnge</td>\n";
2295 print "<td class=\"link\">";
2296 if ($action eq 'commitdiff') {
2299 print $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2301 } elsif ($diff{'to_id'} ne $diff{'from_id'}) {
2302 # "commit" view and modified file (not onlu mode changed)
2303 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2304 hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
2305 hash_base
=>$hash, hash_parent_base
=>$parent,
2306 file_name
=>$diff{'file'})},
2310 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2311 hash_base
=>$hash, file_name
=>$diff{'file'})},
2314 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash,
2315 file_name
=>$diff{'file'})},
2318 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash,
2319 file_name
=>$diff{'file'})},
2323 } elsif ($diff{'status'} eq "R" || $diff{'status'} eq "C") { # renamed or copied
2324 my %status_name = ('R' => 'moved', 'C' => 'copied');
2325 my $nstatus = $status_name{$diff{'status'}};
2327 if ($diff{'from_mode'} != $diff{'to_mode'}) {
2328 # mode also for directories, so we cannot use $to_mode_str
2329 $mode_chng = sprintf(", mode: %04o", $to_mode_oct & 0777);
2332 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$hash,
2333 hash
=>$diff{'to_id'}, file_name
=>$diff{'to_file'}),
2334 -class => "list"}, esc_path
($diff{'to_file'})) . "</td>\n" .
2335 "<td><span class=\"file_status $nstatus\">[$nstatus from " .
2336 $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$parent,
2337 hash
=>$diff{'from_id'}, file_name
=>$diff{'from_file'}),
2338 -class => "list"}, esc_path
($diff{'from_file'})) .
2339 " with " . (int $diff{'similarity'}) . "% similarity$mode_chng]</span></td>\n" .
2340 "<td class=\"link\">";
2341 if ($action eq 'commitdiff') {
2344 print $cgi->a({-href
=> "#patch$patchno"}, "patch") .
2346 } elsif ($diff{'to_id'} ne $diff{'from_id'}) {
2347 # "commit" view and modified file (not only pure rename or copy)
2348 print $cgi->a({-href
=> href
(action
=>"blobdiff",
2349 hash
=>$diff{'to_id'}, hash_parent
=>$diff{'from_id'},
2350 hash_base
=>$hash, hash_parent_base
=>$parent,
2351 file_name
=>$diff{'to_file'}, file_parent
=>$diff{'from_file'})},
2355 print $cgi->a({-href
=> href
(action
=>"blob", hash
=>$diff{'to_id'},
2356 hash_base
=>$parent, file_name
=>$diff{'to_file'})},
2359 print $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash,
2360 file_name
=>$diff{'to_file'})},
2363 print $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash,
2364 file_name
=>$diff{'to_file'})},
2368 } # we should not encounter Unmerged (U) or Unknown (X) status
2374 sub git_patchset_body
{
2375 my ($fd, $difftree, $hash, $hash_parent) = @_;
2382 print "<div class=\"patchset\">\n";
2384 # skip to first patch
2385 while ($patch_line = <$fd>) {
2388 last if ($patch_line =~ m/^diff /);
2392 while ($patch_line) {
2394 my ($from_id, $to_id);
2397 #assert($patch_line =~ m/^diff /) if DEBUG;
2398 #assert($patch_line !~ m!$/$!) if DEBUG; # is chomp-ed
2399 push @diff_header, $patch_line;
2401 # extended diff header
2403 while ($patch_line = <$fd>) {
2406 last EXTENDED_HEADER
if ($patch_line =~ m/^--- |^diff /);
2408 if ($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/) {
2413 push @diff_header, $patch_line;
2415 #last PATCH unless $patch_line;
2416 my $last_patch_line = $patch_line;
2418 # check if current patch belong to current raw line
2419 # and parse raw git-diff line if needed
2420 if (defined $diffinfo &&
2421 $diffinfo->{'from_id'} eq $from_id &&
2422 $diffinfo->{'to_id'} eq $to_id) {
2423 # this is split patch
2424 print "<div class=\"patch cont\">\n";
2426 # advance raw git-diff output if needed
2427 $patch_idx++ if defined $diffinfo;
2429 # read and prepare patch information
2430 if (ref($difftree->[$patch_idx]) eq "HASH") {
2431 # pre-parsed (or generated by hand)
2432 $diffinfo = $difftree->[$patch_idx];
2434 $diffinfo = parse_difftree_raw_line
($difftree->[$patch_idx]);
2436 $from{'file'} = $diffinfo->{'from_file'} || $diffinfo->{'file'};
2437 $to{'file'} = $diffinfo->{'to_file'} || $diffinfo->{'file'};
2438 if ($diffinfo->{'status'} ne "A") { # not new (added) file
2439 $from{'href'} = href
(action
=>"blob", hash_base
=>$hash_parent,
2440 hash
=>$diffinfo->{'from_id'},
2441 file_name
=>$from{'file'});
2443 delete $from{'href'};
2445 if ($diffinfo->{'status'} ne "D") { # not deleted file
2446 $to{'href'} = href
(action
=>"blob", hash_base
=>$hash,
2447 hash
=>$diffinfo->{'to_id'},
2448 file_name
=>$to{'file'});
2452 # this is first patch for raw difftree line with $patch_idx index
2453 # we index @$difftree array from 0, but number patches from 1
2454 print "<div class=\"patch\" id=\"patch". ($patch_idx+1) ."\">\n";
2457 # print "git diff" header
2458 $patch_line = shift @diff_header;
2459 $patch_line =~ s!^(diff (.*?) )"?a/.*$!$1!;
2460 if ($from{'href'}) {
2461 $patch_line .= $cgi->a({-href
=> $from{'href'}, -class => "path"},
2462 'a/' . esc_path
($from{'file'}));
2463 } else { # file was added
2464 $patch_line .= 'a/' . esc_path
($from{'file'});
2468 $patch_line .= $cgi->a({-href
=> $to{'href'}, -class => "path"},
2469 'b/' . esc_path
($to{'file'}));
2470 } else { # file was deleted
2471 $patch_line .= 'b/' . esc_path
($to{'file'});
2473 print "<div class=\"diff header\">$patch_line</div>\n";
2475 # print extended diff header
2476 print "<div class=\"diff extended_header\">\n" if (@diff_header > 0);
2478 foreach $patch_line (@diff_header) {
2480 if ($patch_line =~ s!^((copy|rename) from ).*$!$1! && $from{'href'}) {
2481 $patch_line .= $cgi->a({-href
=>$from{'href'}, -class=>"path"},
2482 esc_path
($from{'file'}));
2484 if ($patch_line =~ s!^((copy|rename) to ).*$!$1! && $to{'href'}) {
2485 $patch_line .= $cgi->a({-href
=>$to{'href'}, -class=>"path"},
2486 esc_path
($to{'file'}));
2489 if ($patch_line =~ m/\s(\d{6})$/) {
2490 $patch_line .= '<span class="info"> (' .
2491 file_type_long
($1) .
2495 if ($patch_line =~ m/^index/) {
2496 my ($from_link, $to_link);
2497 if ($from{'href'}) {
2498 $from_link = $cgi->a({-href
=>$from{'href'}, -class=>"hash"},
2499 substr($diffinfo->{'from_id'},0,7));
2501 $from_link = '0' x
7;
2504 $to_link = $cgi->a({-href
=>$to{'href'}, -class=>"hash"},
2505 substr($diffinfo->{'to_id'},0,7));
2510 # my ($from_hash, $to_hash) =
2511 # ($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/);
2512 # my ($from_id, $to_id) =
2513 # ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});
2514 # ($from_hash eq $from_id) && ($to_hash eq $to_id);
2516 my ($from_id, $to_id) = ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});
2517 $patch_line =~ s!$from_id\.\.$to_id!$from_link..$to_link!;
2519 print $patch_line . "<br/>\n";
2521 print "</div>\n" if (@diff_header > 0); # class="diff extended_header"
2523 # from-file/to-file diff header
2524 $patch_line = $last_patch_line;
2525 last PATCH
unless $patch_line;
2526 next PATCH
if ($patch_line =~ m/^diff /);
2527 #assert($patch_line =~ m/^---/) if DEBUG;
2528 if ($from{'href'} && $patch_line =~ m!^--- "?a/!) {
2529 $patch_line = '--- a/' .
2530 $cgi->a({-href
=>$from{'href'}, -class=>"path"},
2531 esc_path
($from{'file'}));
2533 print "<div class=\"diff from_file\">$patch_line</div>\n";
2535 $patch_line = <$fd>;
2536 #last PATCH unless $patch_line;
2539 #assert($patch_line =~ m/^+++/) if DEBUG;
2540 if ($to{'href'} && $patch_line =~ m!^\+\+\+ "?b/!) {
2541 $patch_line = '+++ b/' .
2542 $cgi->a({-href
=>$to{'href'}, -class=>"path"},
2543 esc_path
($to{'file'}));
2545 print "<div class=\"diff to_file\">$patch_line</div>\n";
2549 while ($patch_line = <$fd>) {
2552 next PATCH
if ($patch_line =~ m/^diff /);
2554 print format_diff_line
($patch_line, \
%from, \
%to);
2558 print "</div>\n"; # class="patch"
2561 print "</div>\n"; # class="patchset"
2564 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2566 sub git_project_list_body
{
2567 my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
2569 my ($check_forks) = gitweb_check_feature
('forks');
2572 foreach my $pr (@
$projlist) {
2573 my (@aa) = git_get_last_activity
($pr->{'path'});
2577 ($pr->{'age'}, $pr->{'age_string'}) = @aa;
2578 if (!defined $pr->{'descr'}) {
2579 my $descr = git_get_project_description
($pr->{'path'}) || "";
2580 $pr->{'descr_long'} = to_utf8
($descr);
2581 $pr->{'descr'} = chop_str
($descr, 25, 5);
2583 if (!defined $pr->{'owner'}) {
2584 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}") || "";
2587 my $pname = $pr->{'path'};
2588 if (($pname =~ s/\.git$//) &&
2589 ($pname !~ /\/$/) &&
2590 (-d
"$projectroot/$pname")) {
2591 $pr->{'forks'} = "-d $projectroot/$pname";
2597 push @projects, $pr;
2600 $order ||= "project";
2601 $from = 0 unless defined $from;
2602 $to = $#projects if (!defined $to || $#projects < $to);
2604 print "<table class=\"project_list\">\n";
2605 unless ($no_header) {
2608 print "<th></th>\n";
2610 if ($order eq "project") {
2611 @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
2612 print "<th>Project</th>\n";
2615 $cgi->a({-href
=> href
(project
=>undef, order
=>'project'),
2616 -class => "header"}, "Project") .
2619 if ($order eq "descr") {
2620 @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
2621 print "<th>Description</th>\n";
2624 $cgi->a({-href
=> href
(project
=>undef, order
=>'descr'),
2625 -class => "header"}, "Description") .
2628 if ($order eq "owner") {
2629 @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
2630 print "<th>Owner</th>\n";
2633 $cgi->a({-href
=> href
(project
=>undef, order
=>'owner'),
2634 -class => "header"}, "Owner") .
2637 if ($order eq "age") {
2638 @projects = sort {$a->{'age'} <=> $b->{'age'}} @projects;
2639 print "<th>Last Change</th>\n";
2642 $cgi->a({-href
=> href
(project
=>undef, order
=>'age'),
2643 -class => "header"}, "Last Change") .
2646 print "<th></th>\n" .
2650 for (my $i = $from; $i <= $to; $i++) {
2651 my $pr = $projects[$i];
2653 print "<tr class=\"dark\">\n";
2655 print "<tr class=\"light\">\n";
2660 if ($pr->{'forks'}) {
2661 print "<!-- $pr->{'forks'} -->\n";
2662 print $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"forks")}, "+");
2666 print "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
2667 -class => "list"}, esc_html
($pr->{'path'})) . "</td>\n" .
2668 "<td>" . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary"),
2669 -class => "list", -title
=> $pr->{'descr_long'}},
2670 esc_html
($pr->{'descr'})) . "</td>\n" .
2671 "<td><i>" . chop_str
($pr->{'owner'}, 15) . "</i></td>\n";
2672 print "<td class=\"". age_class
($pr->{'age'}) . "\">" .
2673 $pr->{'age_string'} . "</td>\n" .
2674 "<td class=\"link\">" .
2675 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"summary")}, "summary") . " | " .
2676 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"shortlog")}, "shortlog") . " | " .
2677 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"log")}, "log") . " | " .
2678 $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"tree")}, "tree") .
2679 ($pr->{'forks'} ?
" | " . $cgi->a({-href
=> href
(project
=>$pr->{'path'}, action
=>"forks")}, "forks") : '') .
2683 if (defined $extra) {
2686 print "<td></td>\n";
2688 print "<td colspan=\"5\">$extra</td>\n" .
2694 sub git_shortlog_body
{
2695 # uses global variable $project
2696 my ($commitlist, $from, $to, $refs, $extra) = @_;
2698 my $have_snapshot = gitweb_have_snapshot
();
2700 $from = 0 unless defined $from;
2701 $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
2703 print "<table class=\"shortlog\" cellspacing=\"0\">\n";
2705 for (my $i = $from; $i <= $to; $i++) {
2706 my %co = %{$commitlist->[$i]};
2707 my $commit = $co{'id'};
2708 my $ref = format_ref_marker
($refs, $commit);
2710 print "<tr class=\"dark\">\n";
2712 print "<tr class=\"light\">\n";
2715 # git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
2716 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2717 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 10)) . "</i></td>\n" .
2719 print format_subject_html
($co{'title'}, $co{'title_short'},
2720 href
(action
=>"commit", hash
=>$commit), $ref);
2722 "<td class=\"link\">" .
2723 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") . " | " .
2724 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") . " | " .
2725 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$commit, hash_base
=>$commit)}, "tree");
2726 if ($have_snapshot) {
2727 print " | " . $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$commit)}, "snapshot");
2732 if (defined $extra) {
2734 "<td colspan=\"4\">$extra</td>\n" .
2740 sub git_history_body
{
2741 # Warning: assumes constant type (blob or tree) during history
2742 my ($commitlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;
2744 $from = 0 unless defined $from;
2745 $to = $#{$commitlist} unless (defined $to && $to <= $#{$commitlist});
2747 print "<table class=\"history\" cellspacing=\"0\">\n";
2749 for (my $i = $from; $i <= $to; $i++) {
2750 my %co = %{$commitlist->[$i]};
2754 my $commit = $co{'id'};
2756 my $ref = format_ref_marker
($refs, $commit);
2759 print "<tr class=\"dark\">\n";
2761 print "<tr class=\"light\">\n";
2764 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2765 # shortlog uses chop_str($co{'author_name'}, 10)
2766 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2768 # originally git_history used chop_str($co{'title'}, 50)
2769 print format_subject_html
($co{'title'}, $co{'title_short'},
2770 href
(action
=>"commit", hash
=>$commit), $ref);
2772 "<td class=\"link\">" .
2773 $cgi->a({-href
=> href
(action
=>$ftype, hash_base
=>$commit, file_name
=>$file_name)}, $ftype) . " | " .
2774 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff");
2776 if ($ftype eq 'blob') {
2777 my $blob_current = git_get_hash_by_path
($hash_base, $file_name);
2778 my $blob_parent = git_get_hash_by_path
($commit, $file_name);
2779 if (defined $blob_current && defined $blob_parent &&
2780 $blob_current ne $blob_parent) {
2782 $cgi->a({-href
=> href
(action
=>"blobdiff",
2783 hash
=>$blob_current, hash_parent
=>$blob_parent,
2784 hash_base
=>$hash_base, hash_parent_base
=>$commit,
2785 file_name
=>$file_name)},
2792 if (defined $extra) {
2794 "<td colspan=\"4\">$extra</td>\n" .
2801 # uses global variable $project
2802 my ($taglist, $from, $to, $extra) = @_;
2803 $from = 0 unless defined $from;
2804 $to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
2806 print "<table class=\"tags\" cellspacing=\"0\">\n";
2808 for (my $i = $from; $i <= $to; $i++) {
2809 my $entry = $taglist->[$i];
2811 my $comment = $tag{'subject'};
2813 if (defined $comment) {
2814 $comment_short = chop_str
($comment, 30, 5);
2817 print "<tr class=\"dark\">\n";
2819 print "<tr class=\"light\">\n";
2822 if (defined $tag{'age'}) {
2823 print "<td><i>$tag{'age'}</i></td>\n";
2825 print "<td></td>\n";
2828 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'}),
2829 -class => "list name"}, esc_html
($tag{'name'})) .
2832 if (defined $comment) {
2833 print format_subject_html
($comment, $comment_short,
2834 href
(action
=>"tag", hash
=>$tag{'id'}));
2837 "<td class=\"selflink\">";
2838 if ($tag{'type'} eq "tag") {
2839 print $cgi->a({-href
=> href
(action
=>"tag", hash
=>$tag{'id'})}, "tag");
2844 "<td class=\"link\">" . " | " .
2845 $cgi->a({-href
=> href
(action
=>$tag{'reftype'}, hash
=>$tag{'refid'})}, $tag{'reftype'});
2846 if ($tag{'reftype'} eq "commit") {
2847 print " | " . $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$tag{'name'})}, "shortlog") .
2848 " | " . $cgi->a({-href
=> href
(action
=>"log", hash
=>$tag{'name'})}, "log");
2849 } elsif ($tag{'reftype'} eq "blob") {
2850 print " | " . $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$tag{'refid'})}, "raw");
2855 if (defined $extra) {
2857 "<td colspan=\"5\">$extra</td>\n" .
2863 sub git_heads_body
{
2864 # uses global variable $project
2865 my ($headlist, $head, $from, $to, $extra) = @_;
2866 $from = 0 unless defined $from;
2867 $to = $#{$headlist} if (!defined $to || $#{$headlist} < $to);
2869 print "<table class=\"heads\" cellspacing=\"0\">\n";
2871 for (my $i = $from; $i <= $to; $i++) {
2872 my $entry = $headlist->[$i];
2874 my $curr = $ref{'id'} eq $head;
2876 print "<tr class=\"dark\">\n";
2878 print "<tr class=\"light\">\n";
2881 print "<td><i>$ref{'age'}</i></td>\n" .
2882 ($curr ?
"<td class=\"current_head\">" : "<td>") .
2883 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$ref{'name'}),
2884 -class => "list name"},esc_html
($ref{'name'})) .
2886 "<td class=\"link\">" .
2887 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$ref{'name'})}, "shortlog") . " | " .
2888 $cgi->a({-href
=> href
(action
=>"log", hash
=>$ref{'name'})}, "log") . " | " .
2889 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$ref{'name'}, hash_base
=>$ref{'name'})}, "tree") .
2893 if (defined $extra) {
2895 "<td colspan=\"3\">$extra</td>\n" .
2901 sub git_search_grep_body
{
2902 my ($commitlist, $from, $to, $extra) = @_;
2903 $from = 0 unless defined $from;
2904 $to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
2906 print "<table class=\"grep\" cellspacing=\"0\">\n";
2908 for (my $i = $from; $i <= $to; $i++) {
2909 my %co = %{$commitlist->[$i]};
2913 my $commit = $co{'id'};
2915 print "<tr class=\"dark\">\n";
2917 print "<tr class=\"light\">\n";
2920 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2921 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2923 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}), -class => "list subject"},
2924 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
2925 my $comment = $co{'comment'};
2926 foreach my $line (@
$comment) {
2927 if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
2928 my $lead = esc_html
($1) || "";
2929 $lead = chop_str
($lead, 30, 10);
2930 my $match = esc_html
($2) || "";
2931 my $trail = esc_html
($3) || "";
2932 $trail = chop_str
($trail, 30, 10);
2933 my $text = "$lead<span class=\"match\">$match</span>$trail";
2934 print chop_str
($text, 80, 5) . "<br/>\n";
2938 "<td class=\"link\">" .
2939 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
2941 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
2945 if (defined $extra) {
2947 "<td colspan=\"3\">$extra</td>\n" .
2953 ## ======================================================================
2954 ## ======================================================================
2957 sub git_project_list
{
2958 my $order = $cgi->param('o');
2959 if (defined $order && $order !~ m/project|descr|owner|age/) {
2960 die_error
(undef, "Unknown order parameter");
2963 my @list = git_get_projects_list
();
2965 die_error
(undef, "No projects found");
2969 if (-f
$home_text) {
2970 print "<div class=\"index_include\">\n";
2971 open (my $fd, $home_text);
2976 git_project_list_body
(\
@list, $order);
2981 my $order = $cgi->param('o');
2982 if (defined $order && $order !~ m/project|descr|owner|age/) {
2983 die_error
(undef, "Unknown order parameter");
2986 my @list = git_get_projects_list
($project);
2988 die_error
(undef, "No forks found");
2992 git_print_page_nav
('','');
2993 git_print_header_div
('summary', "$project forks");
2994 git_project_list_body
(\
@list, $order);
2998 sub git_project_index
{
2999 my @projects = git_get_projects_list
($project);
3002 -type
=> 'text/plain',
3003 -charset
=> 'utf-8',
3004 -content_disposition
=> 'inline; filename="index.aux"');
3006 foreach my $pr (@projects) {
3007 if (!exists $pr->{'owner'}) {
3008 $pr->{'owner'} = get_file_owner
("$projectroot/$pr->{'path'}");
3011 my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});
3012 # quote as in CGI::Util::encode, but keep the slash, and use '+' for ' '
3013 $path =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf
("%%%02X", ord($1))/eg
;
3014 $owner =~ s/([^a-zA-Z0-9_.\-\/ ])/sprintf
("%%%02X", ord($1))/eg
;
3018 print "$path $owner\n";
3023 my $descr = git_get_project_description
($project) || "none";
3024 my %co = parse_commit
("HEAD");
3025 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
3026 my $head = $co{'id'};
3028 my $owner = git_get_project_owner
($project);
3030 my $refs = git_get_references
();
3031 # These get_*_list functions return one more to allow us to see if
3032 # there are more ...
3033 my @taglist = git_get_tags_list
(16);
3034 my @headlist = git_get_heads_list
(16);
3036 my ($check_forks) = gitweb_check_feature
('forks');
3039 @forklist = git_get_projects_list
($project);
3043 git_print_page_nav
('summary','', $head);
3045 print "<div class=\"title\"> </div>\n";
3046 print "<table cellspacing=\"0\">\n" .
3047 "<tr><td>description</td><td>" . esc_html
($descr) . "</td></tr>\n" .
3048 "<tr><td>owner</td><td>$owner</td></tr>\n" .
3049 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
3050 # use per project git URL list in $projectroot/$project/cloneurl
3051 # or make project git URL from git base URL and project name
3052 my $url_tag = "URL";
3053 my @url_list = git_get_project_url_list
($project);
3054 @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
3055 foreach my $git_url (@url_list) {
3056 next unless $git_url;
3057 print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
3062 if (-s
"$projectroot/$project/README.html") {
3063 if (open my $fd, "$projectroot/$project/README.html") {
3064 print "<div class=\"title\">readme</div>\n";
3065 print $_ while (<$fd>);
3070 # we need to request one more than 16 (0..15) to check if
3072 my @commitlist = parse_commits
($head, 17);
3073 git_print_header_div
('shortlog');
3074 git_shortlog_body
(\
@commitlist, 0, 15, $refs,
3075 $#commitlist <= 15 ?
undef :
3076 $cgi->a({-href
=> href
(action
=>"shortlog")}, "..."));
3079 git_print_header_div
('tags');
3080 git_tags_body
(\
@taglist, 0, 15,
3081 $#taglist <= 15 ?
undef :
3082 $cgi->a({-href
=> href
(action
=>"tags")}, "..."));
3086 git_print_header_div
('heads');
3087 git_heads_body
(\
@headlist, $head, 0, 15,
3088 $#headlist <= 15 ?
undef :
3089 $cgi->a({-href
=> href
(action
=>"heads")}, "..."));
3093 git_print_header_div
('forks');
3094 git_project_list_body
(\
@forklist, undef, 0, 15,
3095 $#forklist <= 15 ?
undef :
3096 $cgi->a({-href
=> href
(action
=>"forks")}, "..."),
3104 my $head = git_get_head_hash
($project);
3106 git_print_page_nav
('','', $head,undef,$head);
3107 my %tag = parse_tag
($hash);
3108 git_print_header_div
('commit', esc_html
($tag{'name'}), $hash);
3109 print "<div class=\"title_text\">\n" .
3110 "<table cellspacing=\"0\">\n" .
3112 "<td>object</td>\n" .
3113 "<td>" . $cgi->a({-class => "list", -href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
3114 $tag{'object'}) . "</td>\n" .
3115 "<td class=\"link\">" . $cgi->a({-href
=> href
(action
=>$tag{'type'}, hash
=>$tag{'object'})},
3116 $tag{'type'}) . "</td>\n" .
3118 if (defined($tag{'author'})) {
3119 my %ad = parse_date
($tag{'epoch'}, $tag{'tz'});
3120 print "<tr><td>author</td><td>" . esc_html
($tag{'author'}) . "</td></tr>\n";
3121 print "<tr><td></td><td>" . $ad{'rfc2822'} .
3122 sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) .
3125 print "</table>\n\n" .
3127 print "<div class=\"page_body\">";
3128 my $comment = $tag{'comment'};
3129 foreach my $line (@
$comment) {
3131 print esc_html
($line, -nbsp
=>1) . "<br/>\n";
3141 my ($have_blame) = gitweb_check_feature
('blame');
3143 die_error
('403 Permission denied', "Permission denied");
3145 die_error
('404 Not Found', "File name not defined") if (!$file_name);
3146 $hash_base ||= git_get_head_hash
($project);
3147 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
3148 my %co = parse_commit
($hash_base)
3149 or die_error
(undef, "Reading commit failed");
3150 if (!defined $hash) {
3151 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
3152 or die_error
(undef, "Error looking up file");
3154 $ftype = git_get_type
($hash);
3155 if ($ftype !~ "blob") {
3156 die_error
("400 Bad Request", "Object is not a blob");
3158 open ($fd, "-|", git_cmd
(), "blame", '-p', '--',
3159 $file_name, $hash_base)
3160 or die_error
(undef, "Open git-blame failed");
3163 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3166 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3169 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
3171 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3172 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3173 git_print_page_path
($file_name, $ftype, $hash_base);
3174 my @rev_color = (qw(light2 dark2));
3175 my $num_colors = scalar(@rev_color);
3176 my $current_color = 0;
3179 <div class="page_body">
3180 <table class="blame">
3181 <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
3186 last unless defined $_;
3187 my ($full_rev, $orig_lineno, $lineno, $group_size) =
3188 /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/;
3189 if (!exists $metainfo{$full_rev}) {
3190 $metainfo{$full_rev} = {};
3192 my $meta = $metainfo{$full_rev};
3195 if (/^(\S+) (.*)$/) {
3201 my $rev = substr($full_rev, 0, 8);
3202 my $author = $meta->{'author'};
3203 my %date = parse_date
($meta->{'author-time'},
3204 $meta->{'author-tz'});
3205 my $date = $date{'iso-tz'};
3207 $current_color = ++$current_color % $num_colors;
3209 print "<tr class=\"$rev_color[$current_color]\">\n";
3211 print "<td class=\"sha1\"";
3212 print " title=\"". esc_html
($author) . ", $date\"";
3213 print " rowspan=\"$group_size\"" if ($group_size > 1);
3215 print $cgi->a({-href
=> href
(action
=>"commit",
3217 file_name
=>$file_name)},
3221 open (my $dd, "-|", git_cmd
(), "rev-parse", "$full_rev^")
3222 or die_error
("could not open git-rev-parse");
3223 my $parent_commit = <$dd>;
3225 chomp($parent_commit);
3226 my $blamed = href
(action
=> 'blame',
3227 file_name
=> $meta->{'filename'},
3228 hash_base
=> $parent_commit);
3229 print "<td class=\"linenr\">";
3230 print $cgi->a({ -href
=> "$blamed#l$orig_lineno",
3232 -class => "linenr" },
3235 print "<td class=\"pre\">" . esc_html
($data) . "</td>\n";
3241 or print "Reading blob failed\n";
3248 my ($have_blame) = gitweb_check_feature
('blame');
3250 die_error
('403 Permission denied', "Permission denied");
3252 die_error
('404 Not Found', "File name not defined") if (!$file_name);
3253 $hash_base ||= git_get_head_hash
($project);
3254 die_error
(undef, "Couldn't find base commit") unless ($hash_base);
3255 my %co = parse_commit
($hash_base)
3256 or die_error
(undef, "Reading commit failed");
3257 if (!defined $hash) {
3258 $hash = git_get_hash_by_path
($hash_base, $file_name, "blob")
3259 or die_error
(undef, "Error lookup file");
3261 open ($fd, "-|", git_cmd
(), "annotate", '-l', '-t', '-r', $file_name, $hash_base)
3262 or die_error
(undef, "Open git-annotate failed");
3265 $cgi->a({-href
=> href
(action
=>"blob", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3268 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base, file_name
=>$file_name)},
3271 $cgi->a({-href
=> href
(action
=>"blame", file_name
=>$file_name)},
3273 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3274 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3275 git_print_page_path
($file_name, 'blob', $hash_base);
3276 print "<div class=\"page_body\">\n";
3278 <table class="blame">
3287 my @line_class = (qw(light dark));
3288 my $line_class_len = scalar (@line_class);
3289 my $line_class_num = $#line_class;
3290 while (my $line = <$fd>) {
3302 $line_class_num = ($line_class_num + 1) % $line_class_len;
3304 if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
3311 print qq( <tr
><td colspan
="5" class="error">Unable to parse
: $line</td></tr
>\n);
3314 $short_rev = substr ($long_rev, 0, 8);
3315 $age = time () - $time;
3316 $age_str = age_string
($age);
3317 $age_str =~ s/ / /g;
3318 $age_class = age_class
($age);
3319 $author = esc_html
($author);
3320 $author =~ s/ / /g;
3322 $data = untabify
($data);
3323 $data = esc_html
($data);
3326 <tr class="$line_class[$line_class_num]">
3327 <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
3328 <td class="$age_class">$age_str</td>
3330 <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
3331 <td class="pre">$data</td>
3334 } # while (my $line = <$fd>)
3335 print "</table>\n\n";
3337 or print "Reading blob failed.\n";
3343 my $head = git_get_head_hash
($project);
3345 git_print_page_nav
('','', $head,undef,$head);
3346 git_print_header_div
('summary', $project);
3348 my @tagslist = git_get_tags_list
();
3350 git_tags_body
(\
@tagslist);
3356 my $head = git_get_head_hash
($project);
3358 git_print_page_nav
('','', $head,undef,$head);
3359 git_print_header_div
('summary', $project);
3361 my @headslist = git_get_heads_list
();
3363 git_heads_body
(\
@headslist, $head);
3368 sub git_blob_plain
{
3371 if (!defined $hash) {
3372 if (defined $file_name) {
3373 my $base = $hash_base || git_get_head_hash
($project);
3374 $hash = git_get_hash_by_path
($base, $file_name, "blob")
3375 or die_error
(undef, "Error lookup file");
3377 die_error
(undef, "No file name defined");
3379 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3380 # blobs defined by non-textual hash id's can be cached
3385 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
3386 or die_error
(undef, "Couldn't cat $file_name, $hash");
3388 $type ||= blob_mimetype
($fd, $file_name);
3390 # save as filename, even when no $file_name is given
3391 my $save_as = "$hash";
3392 if (defined $file_name) {
3393 $save_as = $file_name;
3394 } elsif ($type =~ m/^text\//) {
3401 -content_disposition
=> 'inline; filename="' . "$save_as" . '"');
3403 binmode STDOUT
, ':raw';
3405 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
3413 if (!defined $hash) {
3414 if (defined $file_name) {
3415 my $base = $hash_base || git_get_head_hash
($project);
3416 $hash = git_get_hash_by_path
($base, $file_name, "blob")
3417 or die_error
(undef, "Error lookup file");
3419 die_error
(undef, "No file name defined");
3421 } elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3422 # blobs defined by non-textual hash id's can be cached
3426 my ($have_blame) = gitweb_check_feature
('blame');
3427 open my $fd, "-|", git_cmd
(), "cat-file", "blob", $hash
3428 or die_error
(undef, "Couldn't cat $file_name, $hash");
3429 my $mimetype = blob_mimetype
($fd, $file_name);
3430 if ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)!) {
3432 return git_blob_plain
($mimetype);
3434 # we can have blame only for text/* mimetype
3435 $have_blame &&= ($mimetype =~ m!^text/!);
3437 git_header_html
(undef, $expires);
3438 my $formats_nav = '';
3439 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
3440 if (defined $file_name) {
3443 $cgi->a({-href
=> href
(action
=>"blame", hash_base
=>$hash_base,
3444 hash
=>$hash, file_name
=>$file_name)},
3449 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
3450 hash
=>$hash, file_name
=>$file_name)},
3453 $cgi->a({-href
=> href
(action
=>"blob_plain",
3454 hash
=>$hash, file_name
=>$file_name)},
3457 $cgi->a({-href
=> href
(action
=>"blob",
3458 hash_base
=>"HEAD", file_name
=>$file_name)},
3462 $cgi->a({-href
=> href
(action
=>"blob_plain", hash
=>$hash)}, "raw");
3464 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3465 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3467 print "<div class=\"page_nav\">\n" .
3468 "<br/><br/></div>\n" .
3469 "<div class=\"title\">$hash</div>\n";
3471 git_print_page_path
($file_name, "blob", $hash_base);
3472 print "<div class=\"page_body\">\n";
3473 if ($mimetype =~ m!^text/!) {
3475 while (my $line = <$fd>) {
3478 $line = untabify
($line);
3479 printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
3480 $nr, $nr, $nr, esc_html
($line, -nbsp
=>1);
3482 } elsif ($mimetype =~ m!^image/!) {
3483 print qq!<img type
="$mimetype"!;
3485 print qq! alt
="$file_name" title
="$file_name"!;
3488 href(action=>"blob_plain
", hash=>$hash,
3489 hash_base=>$hash_base, file_name=>$file_name) .
3493 or print "Reading blob failed.\n";
3499 my $have_snapshot = gitweb_have_snapshot
();
3501 if (!defined $hash_base) {
3502 $hash_base = "HEAD";
3504 if (!defined $hash) {
3505 if (defined $file_name) {
3506 $hash = git_get_hash_by_path
($hash_base, $file_name, "tree");
3512 open my $fd, "-|", git_cmd
(), "ls-tree", '-z', $hash
3513 or die_error
(undef, "Open git-ls-tree failed");
3514 my @entries = map { chomp; $_ } <$fd>;
3515 close $fd or die_error
(undef, "Reading tree failed");
3518 my $refs = git_get_references
();
3519 my $ref = format_ref_marker
($refs, $hash_base);
3522 my ($have_blame) = gitweb_check_feature
('blame');
3523 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
3525 if (defined $file_name) {
3527 $cgi->a({-href
=> href
(action
=>"history", hash_base
=>$hash_base,
3528 hash
=>$hash, file_name
=>$file_name)},
3530 $cgi->a({-href
=> href
(action
=>"tree",
3531 hash_base
=>"HEAD", file_name
=>$file_name)},
3534 if ($have_snapshot) {
3535 # FIXME: Should be available when we have no hash base as well.
3537 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)},
3540 git_print_page_nav
('tree','', $hash_base, undef, undef, join(' | ', @views_nav));
3541 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash_base);
3544 print "<div class=\"page_nav\">\n";
3545 print "<br/><br/></div>\n";
3546 print "<div class=\"title\">$hash</div>\n";
3548 if (defined $file_name) {
3549 $basedir = $file_name;
3550 if ($basedir ne '' && substr($basedir, -1) ne '/') {
3554 git_print_page_path
($file_name, 'tree', $hash_base);
3555 print "<div class=\"page_body\">\n";
3556 print "<table cellspacing=\"0\">\n";
3558 # '..' (top directory) link if possible
3559 if (defined $hash_base &&
3560 defined $file_name && $file_name =~ m![^/]+$!) {
3562 print "<tr class=\"dark\">\n";
3564 print "<tr class=\"light\">\n";
3568 my $up = $file_name;
3569 $up =~ s!/?[^/]+$!!;
3570 undef $up unless $up;
3571 # based on git_print_tree_entry
3572 print '<td class="mode">' . mode_str
('040000') . "</td>\n";
3573 print '<td class="list">';
3574 print $cgi->a({-href
=> href
(action
=>"tree", hash_base
=>$hash_base,
3578 print "<td class=\"link\"></td>\n";
3582 foreach my $line (@entries) {
3583 my %t = parse_ls_tree_line
($line, -z
=> 1);
3586 print "<tr class=\"dark\">\n";
3588 print "<tr class=\"light\">\n";
3592 git_print_tree_entry
(\
%t, $basedir, $hash_base, $have_blame);
3596 print "</table>\n" .
3602 my ($ctype, $suffix, $command) = gitweb_check_feature
('snapshot');
3603 my $have_snapshot = (defined $ctype && defined $suffix);
3604 if (!$have_snapshot) {
3605 die_error
('403 Permission denied', "Permission denied");
3608 if (!defined $hash) {
3609 $hash = git_get_head_hash
($project);
3612 my $filename = basename
($project) . "-$hash.tar.$suffix";
3615 -type
=> "application/$ctype",
3616 -content_disposition
=> 'inline; filename="' . "$filename" . '"',
3617 -status
=> '200 OK');
3619 my $git = git_cmd_str
();
3620 my $name = $project;
3621 $name =~ s/\047/\047\\\047\047/g;
3623 "$git archive --format=tar --prefix=\'$name\'/ $hash | $command"
3624 or die_error
(undef, "Execute git-tar-tree failed.");
3625 binmode STDOUT
, ':raw';
3627 binmode STDOUT
, ':utf8'; # as set at the beginning of gitweb.cgi
3633 my $head = git_get_head_hash
($project);
3634 if (!defined $hash) {
3637 if (!defined $page) {
3640 my $refs = git_get_references
();
3642 my @commitlist = parse_commits
($hash, 101, (100 * $page));
3644 my $paging_nav = format_paging_nav
('log', $hash, $head, $page, (100 * ($page+1)));
3647 git_print_page_nav
('log','', $hash,undef,undef, $paging_nav);
3650 my %co = parse_commit
($hash);
3652 git_print_header_div
('summary', $project);
3653 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
3655 my $to = ($#commitlist >= 99) ?
(99) : ($#commitlist);
3656 for (my $i = 0; $i <= $to; $i++) {
3657 my %co = %{$commitlist[$i]};
3659 my $commit = $co{'id'};
3660 my $ref = format_ref_marker
($refs, $commit);
3661 my %ad = parse_date
($co{'author_epoch'});
3662 git_print_header_div
('commit',
3663 "<span class=\"age\">$co{'age_string'}</span>" .
3664 esc_html
($co{'title'}) . $ref,
3666 print "<div class=\"title_text\">\n" .
3667 "<div class=\"log_link\">\n" .
3668 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$commit)}, "commit") .
3670 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$commit)}, "commitdiff") .
3672 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$commit, hash_base
=>$commit)}, "tree") .
3675 "<i>" . esc_html
($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
3678 print "<div class=\"log_body\">\n";
3679 git_print_log
($co{'comment'}, -final_empty_line
=> 1);
3682 if ($#commitlist >= 100) {
3683 print "<div class=\"page_nav\">\n";
3684 print $cgi->a({-href
=> href
(action
=>"log", hash
=>$hash, page
=>$page+1),
3685 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
3692 $hash ||= $hash_base || "HEAD";
3693 my %co = parse_commit
($hash);
3695 die_error
(undef, "Unknown commit object");
3697 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
3698 my %cd = parse_date
($co{'committer_epoch'}, $co{'committer_tz'});
3700 my $parent = $co{'parent'};
3701 my $parents = $co{'parents'}; # listref
3703 # we need to prepare $formats_nav before any parameter munging
3705 if (!defined $parent) {
3707 $formats_nav .= '(initial)';
3708 } elsif (@
$parents == 1) {
3709 # single parent commit
3712 $cgi->a({-href
=> href
(action
=>"commit",
3714 esc_html
(substr($parent, 0, 7))) .
3721 $cgi->a({-href
=> href
(action
=>"commitdiff",
3723 esc_html
(substr($_, 0, 7)));
3728 if (!defined $parent) {
3732 if (@
$parents <= 1) {
3733 # difftree output is not printed for merges
3734 open my $fd, "-|", git_cmd
(), "diff-tree", '-r', "--no-commit-id",
3735 @diff_opts, $parent, $hash, "--"
3736 or die_error
(undef, "Open git-diff-tree failed");
3737 @difftree = map { chomp; $_ } <$fd>;
3738 close $fd or die_error
(undef, "Reading git-diff-tree failed");
3741 # non-textual hash id's can be cached
3743 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
3746 my $refs = git_get_references
();
3747 my $ref = format_ref_marker
($refs, $co{'id'});
3749 my $have_snapshot = gitweb_have_snapshot
();
3751 git_header_html
(undef, $expires);
3752 git_print_page_nav
('commit', '',
3753 $hash, $co{'tree'}, $hash,
3756 if (defined $co{'parent'}) {
3757 git_print_header_div
('commitdiff', esc_html
($co{'title'}) . $ref, $hash);
3759 git_print_header_div
('tree', esc_html
($co{'title'}) . $ref, $co{'tree'}, $hash);
3761 print "<div class=\"title_text\">\n" .
3762 "<table cellspacing=\"0\">\n";
3763 print "<tr><td>author</td><td>" . esc_html
($co{'author'}) . "</td></tr>\n".
3765 "<td></td><td> $ad{'rfc2822'}";
3766 if ($ad{'hour_local'} < 6) {
3767 printf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
3768 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
3770 printf(" (%02d:%02d %s)",
3771 $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});
3775 print "<tr><td>committer</td><td>" . esc_html
($co{'committer'}) . "</td></tr>\n";
3776 print "<tr><td></td><td> $cd{'rfc2822'}" .
3777 sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .
3779 print "<tr><td>commit</td><td class=\"sha1\">$co{'id'}</td></tr>\n";
3782 "<td class=\"sha1\">" .
3783 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash),
3784 class => "list"}, $co{'tree'}) .
3786 "<td class=\"link\">" .
3787 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$hash)},
3789 if ($have_snapshot) {
3791 $cgi->a({-href
=> href
(action
=>"snapshot", hash
=>$hash)}, "snapshot");
3796 foreach my $par (@
$parents) {
3799 "<td class=\"sha1\">" .
3800 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par),
3801 class => "list"}, $par) .
3803 "<td class=\"link\">" .
3804 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$par)}, "commit") .
3806 $cgi->a({-href
=> href
(action
=>"commitdiff", hash
=>$hash, hash_parent
=>$par)}, "diff") .
3813 print "<div class=\"page_body\">\n";
3814 git_print_log
($co{'comment'});
3817 if (@
$parents <= 1) {
3818 # do not output difftree/whatchanged for merges
3819 git_difftree_body
(\
@difftree, $hash, $parent);
3826 # object is defined by:
3827 # - hash or hash_base alone
3828 # - hash_base and file_name
3831 # - hash or hash_base alone
3832 if ($hash || ($hash_base && !defined $file_name)) {
3833 my $object_id = $hash || $hash_base;
3835 my $git_command = git_cmd_str
();
3836 open my $fd, "-|", "$git_command cat-file -t $object_id 2>/dev/null"
3837 or die_error
('404 Not Found', "Object does not exist");
3841 or die_error
('404 Not Found', "Object does not exist");
3843 # - hash_base and file_name
3844 } elsif ($hash_base && defined $file_name) {
3845 $file_name =~ s
,/+$,,;
3847 system(git_cmd
(), "cat-file", '-e', $hash_base) == 0
3848 or die_error
('404 Not Found', "Base object does not exist");
3850 # here errors should not hapen
3851 open my $fd, "-|", git_cmd
(), "ls-tree", $hash_base, "--", $file_name
3852 or die_error
(undef, "Open git-ls-tree failed");
3856 #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
3857 unless ($line && $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/) {
3858 die_error
('404 Not Found', "File or directory for given base does not exist");
3863 die_error
('404 Not Found', "Not enough information to find object");
3866 print $cgi->redirect(-uri
=> href
(action
=>$type, -full
=>1,
3867 hash
=>$hash, hash_base
=>$hash_base,
3868 file_name
=>$file_name),
3869 -status
=> '302 Found');
3873 my $format = shift || 'html';
3880 # preparing $fd and %diffinfo for git_patchset_body
3882 if (defined $hash_base && defined $hash_parent_base) {
3883 if (defined $file_name) {
3885 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
3886 $hash_parent_base, $hash_base,
3888 or die_error
(undef, "Open git-diff-tree failed");
3889 @difftree = map { chomp; $_ } <$fd>;
3891 or die_error
(undef, "Reading git-diff-tree failed");
3893 or die_error
('404 Not Found', "Blob diff not found");
3895 } elsif (defined $hash &&
3896 $hash =~ /[0-9a-fA-F]{40}/) {
3897 # try to find filename from $hash
3899 # read filtered raw output
3900 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
3901 $hash_parent_base, $hash_base, "--"
3902 or die_error
(undef, "Open git-diff-tree failed");
3904 # ':100644 100644 03b21826... 3b93d5e7... M ls-files.c'
3906 grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
3907 map { chomp; $_ } <$fd>;
3909 or die_error
(undef, "Reading git-diff-tree failed");
3911 or die_error
('404 Not Found', "Blob diff not found");
3914 die_error
('404 Not Found', "Missing one of the blob diff parameters");
3917 if (@difftree > 1) {
3918 die_error
('404 Not Found', "Ambiguous blob diff specification");
3921 %diffinfo = parse_difftree_raw_line
($difftree[0]);
3922 $file_parent ||= $diffinfo{'from_file'} || $file_name || $diffinfo{'file'};
3923 $file_name ||= $diffinfo{'to_file'} || $diffinfo{'file'};
3925 $hash_parent ||= $diffinfo{'from_id'};
3926 $hash ||= $diffinfo{'to_id'};
3928 # non-textual hash id's can be cached
3929 if ($hash_base =~ m/^[0-9a-fA-F]{40}$/ &&
3930 $hash_parent_base =~ m/^[0-9a-fA-F]{40}$/) {
3935 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
3936 '-p', $hash_parent_base, $hash_base,
3938 or die_error
(undef, "Open git-diff-tree failed");
3941 # old/legacy style URI
3942 if (!%diffinfo && # if new style URI failed
3943 defined $hash && defined $hash_parent) {
3944 # fake git-diff-tree raw output
3945 $diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
3946 $diffinfo{'from_id'} = $hash_parent;
3947 $diffinfo{'to_id'} = $hash;
3948 if (defined $file_name) {
3949 if (defined $file_parent) {
3950 $diffinfo{'status'} = '2';
3951 $diffinfo{'from_file'} = $file_parent;
3952 $diffinfo{'to_file'} = $file_name;
3953 } else { # assume not renamed
3954 $diffinfo{'status'} = '1';
3955 $diffinfo{'from_file'} = $file_name;
3956 $diffinfo{'to_file'} = $file_name;
3958 } else { # no filename given
3959 $diffinfo{'status'} = '2';
3960 $diffinfo{'from_file'} = $hash_parent;
3961 $diffinfo{'to_file'} = $hash;
3964 # non-textual hash id's can be cached
3965 if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
3966 $hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
3971 open $fd, "-|", git_cmd
(), "diff", '-p', @diff_opts,
3972 $hash_parent, $hash, "--"
3973 or die_error
(undef, "Open git-diff failed");
3975 die_error
('404 Not Found', "Missing one of the blob diff parameters")
3980 if ($format eq 'html') {
3982 $cgi->a({-href
=> href
(action
=>"blobdiff_plain",
3983 hash
=>$hash, hash_parent
=>$hash_parent,
3984 hash_base
=>$hash_base, hash_parent_base
=>$hash_parent_base,
3985 file_name
=>$file_name, file_parent
=>$file_parent)},
3987 git_header_html
(undef, $expires);
3988 if (defined $hash_base && (my %co = parse_commit
($hash_base))) {
3989 git_print_page_nav
('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
3990 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
3992 print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
3993 print "<div class=\"title\">$hash vs $hash_parent</div>\n";
3995 if (defined $file_name) {
3996 git_print_page_path
($file_name, "blob", $hash_base);
3998 print "<div class=\"page_path\"></div>\n";
4001 } elsif ($format eq 'plain') {
4003 -type
=> 'text/plain',
4004 -charset
=> 'utf-8',
4005 -expires
=> $expires,
4006 -content_disposition
=> 'inline; filename="' . "$file_name" . '.patch"');
4008 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
4011 die_error
(undef, "Unknown blobdiff format");
4015 if ($format eq 'html') {
4016 print "<div class=\"page_body\">\n";
4018 git_patchset_body
($fd, [ \
%diffinfo ], $hash_base, $hash_parent_base);
4021 print "</div>\n"; # class="page_body"
4025 while (my $line = <$fd>) {
4026 $line =~ s!a/($hash|$hash_parent)!'a/'.esc_path($diffinfo{'from_file'})!eg;
4027 $line =~ s!b/($hash|$hash_parent)!'b/'.esc_path($diffinfo{'to_file'})!eg;
4031 last if $line =~ m!^\+\+\+!;
4039 sub git_blobdiff_plain
{
4040 git_blobdiff
('plain');
4043 sub git_commitdiff
{
4044 my $format = shift || 'html';
4045 $hash ||= $hash_base || "HEAD";
4046 my %co = parse_commit
($hash);
4048 die_error
(undef, "Unknown commit object");
4051 # we need to prepare $formats_nav before any parameter munging
4053 if ($format eq 'html') {
4055 $cgi->a({-href
=> href
(action
=>"commitdiff_plain",
4056 hash
=>$hash, hash_parent
=>$hash_parent)},
4059 if (defined $hash_parent) {
4060 # commitdiff with two commits given
4061 my $hash_parent_short = $hash_parent;
4062 if ($hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
4063 $hash_parent_short = substr($hash_parent, 0, 7);
4067 $cgi->a({-href
=> href
(action
=>"commitdiff",
4068 hash
=>$hash_parent)},
4069 esc_html
($hash_parent_short)) .
4071 } elsif (!$co{'parent'}) {
4073 $formats_nav .= ' (initial)';
4074 } elsif (scalar @
{$co{'parents'}} == 1) {
4075 # single parent commit
4078 $cgi->a({-href
=> href
(action
=>"commitdiff",
4079 hash
=>$co{'parent'})},
4080 esc_html
(substr($co{'parent'}, 0, 7))) .
4087 $cgi->a({-href
=> href
(action
=>"commitdiff",
4089 esc_html
(substr($_, 0, 7)));
4090 } @
{$co{'parents'}} ) .
4095 if (!defined $hash_parent) {
4096 $hash_parent = $co{'parent'} || '--root';
4102 if ($format eq 'html') {
4103 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4104 "--no-commit-id", "--patch-with-raw", "--full-index",
4105 $hash_parent, $hash, "--"
4106 or die_error
(undef, "Open git-diff-tree failed");
4108 while (my $line = <$fd>) {
4110 # empty line ends raw part of diff-tree output
4112 push @difftree, $line;
4115 } elsif ($format eq 'plain') {
4116 open $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4117 '-p', $hash_parent, $hash, "--"
4118 or die_error
(undef, "Open git-diff-tree failed");
4121 die_error
(undef, "Unknown commitdiff format");
4124 # non-textual hash id's can be cached
4126 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
4130 # write commit message
4131 if ($format eq 'html') {
4132 my $refs = git_get_references
();
4133 my $ref = format_ref_marker
($refs, $co{'id'});
4135 git_header_html
(undef, $expires);
4136 git_print_page_nav
('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
4137 git_print_header_div
('commit', esc_html
($co{'title'}) . $ref, $hash);
4138 git_print_authorship
(\
%co);
4139 print "<div class=\"page_body\">\n";
4140 if (@
{$co{'comment'}} > 1) {
4141 print "<div class=\"log\">\n";
4142 git_print_log
($co{'comment'}, -final_empty_line
=> 1, -remove_title
=> 1);
4143 print "</div>\n"; # class="log"
4146 } elsif ($format eq 'plain') {
4147 my $refs = git_get_references
("tags");
4148 my $tagname = git_get_rev_name_tags
($hash);
4149 my $filename = basename
($project) . "-$hash.patch";
4152 -type
=> 'text/plain',
4153 -charset
=> 'utf-8',
4154 -expires
=> $expires,
4155 -content_disposition
=> 'inline; filename="' . "$filename" . '"');
4156 my %ad = parse_date
($co{'author_epoch'}, $co{'author_tz'});
4159 Date: $ad{'rfc2822'} ($ad{'tz_local'})
4160 Subject: $co{'title'}
4162 print "X-Git-Tag: $tagname\n" if $tagname;
4163 print "X-Git-Url: " . $cgi->self_url() . "\n\n";
4165 foreach my $line (@
{$co{'comment'}}) {
4172 if ($format eq 'html') {
4173 git_difftree_body
(\
@difftree, $hash, $hash_parent);
4176 git_patchset_body
($fd, \
@difftree, $hash, $hash_parent);
4178 print "</div>\n"; # class="page_body"
4181 } elsif ($format eq 'plain') {
4185 or print "Reading git-diff-tree failed\n";
4189 sub git_commitdiff_plain
{
4190 git_commitdiff
('plain');
4194 if (!defined $hash_base) {
4195 $hash_base = git_get_head_hash
($project);
4197 if (!defined $page) {
4201 my %co = parse_commit
($hash_base);
4203 die_error
(undef, "Unknown commit object");
4206 my $refs = git_get_references
();
4207 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
4209 if (!defined $hash && defined $file_name) {
4210 $hash = git_get_hash_by_path
($hash_base, $file_name);
4212 if (defined $hash) {
4213 $ftype = git_get_type
($hash);
4216 my @commitlist = parse_commits
($hash_base, 101, (100 * $page), "--full-history", $file_name);
4218 my $paging_nav = '';
4221 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4222 file_name
=>$file_name)},
4224 $paging_nav .= " ⋅ " .
4225 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4226 file_name
=>$file_name, page
=>$page-1),
4227 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
4229 $paging_nav .= "first";
4230 $paging_nav .= " ⋅ prev";
4232 if ($#commitlist >= 100) {
4233 $paging_nav .= " ⋅ " .
4234 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4235 file_name
=>$file_name, page
=>$page+1),
4236 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4238 $paging_nav .= " ⋅ next";
4241 if ($#commitlist >= 100) {
4243 $cgi->a({-href
=> href
(action
=>"history", hash
=>$hash, hash_base
=>$hash_base,
4244 file_name
=>$file_name, page
=>$page+1),
4245 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4249 git_print_page_nav
('history','', $hash_base,$co{'tree'},$hash_base, $paging_nav);
4250 git_print_header_div
('commit', esc_html
($co{'title'}), $hash_base);
4251 git_print_page_path
($file_name, $ftype, $hash_base);
4253 git_history_body
(\
@commitlist, 0, 99,
4254 $refs, $hash_base, $ftype, $next_link);
4260 my ($have_search) = gitweb_check_feature
('search');
4261 if (!$have_search) {
4262 die_error
('403 Permission denied', "Permission denied");
4264 if (!defined $searchtext) {
4265 die_error
(undef, "Text field empty");
4267 if (!defined $hash) {
4268 $hash = git_get_head_hash
($project);
4270 my %co = parse_commit
($hash);
4272 die_error
(undef, "Unknown commit object");
4274 if (!defined $page) {
4278 $searchtype ||= 'commit';
4279 if ($searchtype eq 'pickaxe') {
4280 # pickaxe may take all resources of your box and run for several minutes
4281 # with every query - so decide by yourself how public you make this feature
4282 my ($have_pickaxe) = gitweb_check_feature
('pickaxe');
4283 if (!$have_pickaxe) {
4284 die_error
('403 Permission denied', "Permission denied");
4290 if ($searchtype eq 'commit' or $searchtype eq 'author' or $searchtype eq 'committer') {
4292 if ($searchtype eq 'commit') {
4293 $greptype = "--grep=";
4294 } elsif ($searchtype eq 'author') {
4295 $greptype = "--author=";
4296 } elsif ($searchtype eq 'committer') {
4297 $greptype = "--committer=";
4299 $greptype .= $searchtext;
4300 my @commitlist = parse_commits
($hash, 101, (100 * $page), $greptype);
4302 my $paging_nav = '';
4305 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4306 searchtext
=>$searchtext, searchtype
=>$searchtype)},
4308 $paging_nav .= " ⋅ " .
4309 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4310 searchtext
=>$searchtext, searchtype
=>$searchtype,
4312 -accesskey
=> "p", -title
=> "Alt-p"}, "prev");
4314 $paging_nav .= "first";
4315 $paging_nav .= " ⋅ prev";
4317 if ($#commitlist >= 100) {
4318 $paging_nav .= " ⋅ " .
4319 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4320 searchtext
=>$searchtext, searchtype
=>$searchtype,
4322 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4324 $paging_nav .= " ⋅ next";
4327 if ($#commitlist >= 100) {
4329 $cgi->a({-href
=> href
(action
=>"search", hash
=>$hash,
4330 searchtext
=>$searchtext, searchtype
=>$searchtype,
4332 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4335 git_print_page_nav
('','', $hash,$co{'tree'},$hash, $paging_nav);
4336 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
4337 git_search_grep_body
(\
@commitlist, 0, 99, $next_link);
4340 if ($searchtype eq 'pickaxe') {
4341 git_print_page_nav
('','', $hash,$co{'tree'},$hash);
4342 git_print_header_div
('commit', esc_html
($co{'title'}), $hash);
4344 print "<table cellspacing=\"0\">\n";
4347 my $git_command = git_cmd_str
();
4348 open my $fd, "-|", "$git_command rev-list $hash | " .
4349 "$git_command diff-tree -r --stdin -S\'$searchtext\'";
4352 while (my $line = <$fd>) {
4353 if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
4356 $set{'from_id'} = $3;
4358 $set{'id'} = $set{'to_id'};
4359 if ($set{'id'} =~ m/0{40}/) {
4360 $set{'id'} = $set{'from_id'};
4362 if ($set{'id'} =~ m/0{40}/) {
4366 } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
4369 print "<tr class=\"dark\">\n";
4371 print "<tr class=\"light\">\n";
4374 print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
4375 "<td><i>" . esc_html
(chop_str
($co{'author_name'}, 15, 5)) . "</i></td>\n" .
4377 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'}),
4378 -class => "list subject"},
4379 esc_html
(chop_str
($co{'title'}, 50)) . "<br/>");
4380 while (my $setref = shift @files) {
4382 print $cgi->a({-href
=> href
(action
=>"blob", hash_base
=>$co{'id'},
4383 hash
=>$set{'id'}, file_name
=>$set{'file'}),
4385 "<span class=\"match\">" . esc_path
($set{'file'}) . "</span>") .
4389 "<td class=\"link\">" .
4390 $cgi->a({-href
=> href
(action
=>"commit", hash
=>$co{'id'})}, "commit") .
4392 $cgi->a({-href
=> href
(action
=>"tree", hash
=>$co{'tree'}, hash_base
=>$co{'id'})}, "tree");
4396 %co = parse_commit
($1);
4406 sub git_search_help
{
4408 git_print_page_nav
('','', $hash,$hash,$hash);
4411 <dt><b>commit</b></dt>
4412 <dd>The commit messages and authorship information will be scanned for the given string.</dd>
4413 <dt><b>author</b></dt>
4414 <dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given string.</dd>
4415 <dt><b>committer</b></dt>
4416 <dd>Name and e-mail of the committer and date of commit will be scanned for the given string.</dd>
4418 my ($have_pickaxe) = gitweb_check_feature
('pickaxe');
4419 if ($have_pickaxe) {
4421 <dt><b>pickaxe</b></dt>
4422 <dd>All commits that caused the string to appear or disappear from any file (changes that
4423 added, removed or "modified" the string) will be listed. This search can take a while and
4424 takes a lot of strain on the server, so please use it wisely.</dd>
4432 my $head = git_get_head_hash
($project);
4433 if (!defined $hash) {
4436 if (!defined $page) {
4439 my $refs = git_get_references
();
4441 my @commitlist = parse_commits
($hash, 101, (100 * $page));
4443 my $paging_nav = format_paging_nav
('shortlog', $hash, $head, $page, (100 * ($page+1)));
4445 if ($#commitlist >= 100) {
4447 $cgi->a({-href
=> href
(action
=>"shortlog", hash
=>$hash, page
=>$page+1),
4448 -accesskey
=> "n", -title
=> "Alt-n"}, "next");
4452 git_print_page_nav
('shortlog','', $hash,$hash,$hash, $paging_nav);
4453 git_print_header_div
('summary', $project);
4455 git_shortlog_body
(\
@commitlist, 0, 99, $refs, $next_link);
4460 ## ......................................................................
4461 ## feeds (RSS, Atom; OPML)
4464 my $format = shift || 'atom';
4465 my ($have_blame) = gitweb_check_feature
('blame');
4467 # Atom: http://www.atomenabled.org/developers/syndication/
4468 # RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
4469 if ($format ne 'rss' && $format ne 'atom') {
4470 die_error
(undef, "Unknown web feed format");
4473 # log/feed of current (HEAD) branch, log of given branch, history of file/directory
4474 my $head = $hash || 'HEAD';
4475 my @commitlist = parse_commits
($head, 150);
4479 my $content_type = "application/$format+xml";
4480 if (defined $cgi->http('HTTP_ACCEPT') &&
4481 $cgi->Accept('text/xml') > $cgi->Accept($content_type)) {
4482 # browser (feed reader) prefers text/xml
4483 $content_type = 'text/xml';
4485 if (defined($commitlist[0])) {
4486 %latest_commit = %{$commitlist[0]};
4487 %latest_date = parse_date
($latest_commit{'author_epoch'});
4489 -type
=> $content_type,
4490 -charset
=> 'utf-8',
4491 -last_modified
=> $latest_date{'rfc2822'});
4494 -type
=> $content_type,
4495 -charset
=> 'utf-8');
4498 # Optimization: skip generating the body if client asks only
4499 # for Last-Modified date.
4500 return if ($cgi->request_method() eq 'HEAD');
4503 my $title = "$site_name - $project/$action";
4504 my $feed_type = 'log';
4505 if (defined $hash) {
4506 $title .= " - '$hash'";
4507 $feed_type = 'branch log';
4508 if (defined $file_name) {
4509 $title .= " :: $file_name";
4510 $feed_type = 'history';
4512 } elsif (defined $file_name) {
4513 $title .= " - $file_name";
4514 $feed_type = 'history';
4516 $title .= " $feed_type";
4517 my $descr = git_get_project_description
($project);
4518 if (defined $descr) {
4519 $descr = esc_html
($descr);
4521 $descr = "$project " .
4522 ($format eq 'rss' ?
'RSS' : 'Atom') .
4525 my $owner = git_get_project_owner
($project);
4526 $owner = esc_html
($owner);
4530 if (defined $file_name) {
4531 $alt_url = href
(-full
=>1, action
=>"history", hash
=>$hash, file_name
=>$file_name);
4532 } elsif (defined $hash) {
4533 $alt_url = href
(-full
=>1, action
=>"log", hash
=>$hash);
4535 $alt_url = href
(-full
=>1, action
=>"summary");
4537 print qq!<?xml version
="1.0" encoding
="utf-8"?
>\n!;
4538 if ($format eq 'rss') {
4540 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
4543 print "<title>$title</title>\n" .
4544 "<link>$alt_url</link>\n" .
4545 "<description>$descr</description>\n" .
4546 "<language>en</language>\n";
4547 } elsif ($format eq 'atom') {
4549 <feed xmlns="http://www.w3.org/2005/Atom">
4551 print "<title>$title</title>\n" .
4552 "<subtitle>$descr</subtitle>\n" .
4553 '<link rel="alternate" type="text/html" href="' .
4554 $alt_url . '" />' . "\n" .
4555 '<link rel="self" type="' . $content_type . '" href="' .
4556 $cgi->self_url() . '" />' . "\n" .
4557 "<id>" . href
(-full
=>1) . "</id>\n" .
4558 # use project owner for feed author
4559 "<author><name>$owner</name></author>\n";
4560 if (defined $favicon) {
4561 print "<icon>" . esc_url
($favicon) . "</icon>\n";
4563 if (defined $logo_url) {
4564 # not twice as wide as tall: 72 x 27 pixels
4565 print "<logo>" . esc_url
($logo) . "</logo>\n";
4567 if (! %latest_date) {
4568 # dummy date to keep the feed valid until commits trickle in:
4569 print "<updated>1970-01-01T00:00:00Z</updated>\n";
4571 print "<updated>$latest_date{'iso-8601'}</updated>\n";
4576 for (my $i = 0; $i <= $#commitlist; $i++) {
4577 my %co = %{$commitlist[$i]};
4578 my $commit = $co{'id'};
4579 # we read 150, we always show 30 and the ones more recent than 48 hours
4580 if (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) {
4583 my %cd = parse_date
($co{'author_epoch'});
4585 # get list of changed files
4586 open my $fd, "-|", git_cmd
(), "diff-tree", '-r', @diff_opts,
4587 $co{'parent'}, $co{'id'}, "--", (defined $file_name ?
$file_name : ())
4589 my @difftree = map { chomp; $_ } <$fd>;
4593 # print element (entry, item)
4594 my $co_url = href
(-full
=>1, action
=>"commit", hash
=>$commit);
4595 if ($format eq 'rss') {
4597 "<title>" . esc_html
($co{'title'}) . "</title>\n" .
4598 "<author>" . esc_html
($co{'author'}) . "</author>\n" .
4599 "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
4600 "<guid isPermaLink=\"true\">$co_url</guid>\n" .
4601 "<link>$co_url</link>\n" .
4602 "<description>" . esc_html
($co{'title'}) . "</description>\n" .
4603 "<content:encoded>" .
4605 } elsif ($format eq 'atom') {
4607 "<title type=\"html\">" . esc_html
($co{'title'}) . "</title>\n" .
4608 "<updated>$cd{'iso-8601'}</updated>\n" .
4610 " <name>" . esc_html
($co{'author_name'}) . "</name>\n";
4611 if ($co{'author_email'}) {
4612 print " <email>" . esc_html
($co{'author_email'}) . "</email>\n";
4614 print "</author>\n" .
4615 # use committer for contributor
4617 " <name>" . esc_html
($co{'committer_name'}) . "</name>\n";
4618 if ($co{'committer_email'}) {
4619 print " <email>" . esc_html
($co{'committer_email'}) . "</email>\n";
4621 print "</contributor>\n" .
4622 "<published>$cd{'iso-8601'}</published>\n" .
4623 "<link rel=\"alternate\" type=\"text/html\" href=\"$co_url\" />\n" .
4624 "<id>$co_url</id>\n" .
4625 "<content type=\"xhtml\" xml:base=\"" . esc_url
($my_url) . "\">\n" .
4626 "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
4628 my $comment = $co{'comment'};
4630 foreach my $line (@
$comment) {
4631 $line = esc_html
($line);
4634 print "</pre><ul>\n";
4635 foreach my $difftree_line (@difftree) {
4636 my %difftree = parse_difftree_raw_line
($difftree_line);
4637 next if !$difftree{'from_id'};
4639 my $file = $difftree{'file'} || $difftree{'to_file'};
4643 $cgi->a({-href
=> href
(-full
=>1, action
=>"blobdiff",
4644 hash
=>$difftree{'to_id'}, hash_parent
=>$difftree{'from_id'},
4645 hash_base
=>$co{'id'}, hash_parent_base
=>$co{'parent'},
4646 file_name
=>$file, file_parent
=>$difftree{'from_file'}),
4647 -title
=> "diff"}, 'D');
4649 print $cgi->a({-href
=> href
(-full
=>1, action
=>"blame",
4650 file_name
=>$file, hash_base
=>$commit),
4651 -title
=> "blame"}, 'B');
4653 # if this is not a feed of a file history
4654 if (!defined $file_name || $file_name ne $file) {
4655 print $cgi->a({-href
=> href
(-full
=>1, action
=>"history",
4656 file_name
=>$file, hash
=>$commit),
4657 -title
=> "history"}, 'H');
4659 $file = esc_path
($file);
4663 if ($format eq 'rss') {
4664 print "</ul>]]>\n" .
4665 "</content:encoded>\n" .
4667 } elsif ($format eq 'atom') {
4668 print "</ul>\n</div>\n" .
4675 if ($format eq 'rss') {
4676 print "</channel>\n</rss>\n";
4677 } elsif ($format eq 'atom') {
4691 my @list = git_get_projects_list
();
4693 print $cgi->header(-type
=> 'text/xml', -charset
=> 'utf-8');
4695 <?xml version="1.0" encoding="utf-8"?>
4696 <opml version="1.0">
4698 <title>$site_name OPML Export</title>
4701 <outline text="git RSS feeds">
4704 foreach my $pr (@list) {
4706 my $head = git_get_head_hash
($proj{'path'});
4707 if (!defined $head) {
4710 $git_dir = "$projectroot/$proj{'path'}";
4711 my %co = parse_commit
($head);
4716 my $path = esc_html
(chop_str
($proj{'path'}, 25, 5));
4717 my $rss = "$my_url?p=$proj{'path'};a=rss";
4718 my $html = "$my_url?p=$proj{'path'};a=summary";
4719 print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";