Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Fri, 28 Aug 2009 05:01:01 +0000 (22:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Aug 2009 05:01:01 +0000 (22:01 -0700)
* maint:
Fix overridable written with an extra 'e'
Documentation: git-archive: mark --format as optional in summary
Round-down years in "years+months" relative date view

1  2 
gitweb/gitweb.perl
diff --combined gitweb/gitweb.perl
index d02b7a3c268045ac0a15855d0f0c06c28b7a88be,2cb832753a449aba64cc0e4b0f2c7878bb3871f5..ff2d42abb95252736879b1b59696b31922415c44
@@@ -160,8 -160,7 +160,8 @@@ our %known_snapshot_formats = 
        #       'suffix' => filename suffix,
        #       'format' => --format for git-archive,
        #       'compressor' => [compressor command and arguments]
 -      #                       (array reference, optional)}
 +      #                       (array reference, optional)
 +      #       'disabled' => boolean (optional)}
        #
        'tgz' => {
                'display' => 'tar.gz',
                'format' => 'tar',
                'compressor' => ['bzip2']},
  
 +      'txz' => {
 +              'display' => 'tar.xz',
 +              'type' => 'application/x-xz',
 +              'suffix' => '.tar.xz',
 +              'format' => 'tar',
 +              'compressor' => ['xz'],
 +              'disabled' => 1},
 +
        'zip' => {
                'display' => 'zip',
                'type' => 'application/x-zip',
  our %known_snapshot_format_aliases = (
        'gzip'  => 'tgz',
        'bzip2' => 'tbz2',
 +      'xz'    => 'txz',
  
        # backward compatibility: legacy gitweb config support
        'x-gzip' => undef, 'gz' => undef,
@@@ -415,7 -405,7 +415,7 @@@ sub gitweb_get_feature 
                @{$feature{$name}{'default'}});
        if (!$override) { return @defaults; }
        if (!defined $sub) {
-               warn "feature $name is not overrideable";
+               warn "feature $name is not overridable";
                return @defaults;
        }
        return $sub->(@defaults);
@@@ -504,8 -494,7 +504,8 @@@ sub filter_snapshot_fmts 
                exists $known_snapshot_format_aliases{$_} ?
                       $known_snapshot_format_aliases{$_} : $_} @fmts;
        @fmts = grep {
 -              exists $known_snapshot_formats{$_} } @fmts;
 +              exists $known_snapshot_formats{$_} &&
 +              !$known_snapshot_formats{$_}{'disabled'}} @fmts;
  }
  
  our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
@@@ -951,13 -940,10 +951,13 @@@ sub href 
                        if (defined $params{'hash_parent_base'}) {
                                $href .= esc_url($params{'hash_parent_base'});
                                # skip the file_parent if it's the same as the file_name
 -                              delete $params{'file_parent'} if $params{'file_parent'} eq $params{'file_name'};
 -                              if (defined $params{'file_parent'} && $params{'file_parent'} !~ /\.\./) {
 -                                      $href .= ":/".esc_url($params{'file_parent'});
 -                                      delete $params{'file_parent'};
 +                              if (defined $params{'file_parent'}) {
 +                                      if (defined $params{'file_name'} && $params{'file_parent'} eq $params{'file_name'}) {
 +                                              delete $params{'file_parent'};
 +                                      } elsif ($params{'file_parent'} !~ /\.\./) {
 +                                              $href .= ":/".esc_url($params{'file_parent'});
 +                                              delete $params{'file_parent'};
 +                                      }
                                }
                                $href .= "..";
                                delete $params{'hash_parent'};
@@@ -1524,10 -1510,10 +1524,10 @@@ sub format_subject_html 
                $long =~ s/[[:cntrl:]]/?/g;
                return $cgi->a({-href => $href, -class => "list subject",
                                -title => to_utf8($long)},
 -                     esc_html($short) . $extra);
 +                     esc_html($short)) . $extra;
        } else {
                return $cgi->a({-href => $href, -class => "list subject"},
 -                     esc_html($long)  . $extra);
 +                     esc_html($long)) . $extra;
        }
  }
  
@@@ -4814,7 -4800,7 +4814,7 @@@ sub git_blame 
        git_print_page_path($file_name, $ftype, $hash_base);
  
        # page body
 -      my @rev_color = qw(light2 dark2);
 +      my @rev_color = qw(light dark);
        my $num_colors = scalar(@rev_color);
        my $current_color = 0;
        my %metainfo = ();
                my ($full_rev, $orig_lineno, $lineno, $group_size) =
                   ($line =~ /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/);
                if (!exists $metainfo{$full_rev}) {
 -                      $metainfo{$full_rev} = {};
 +                      $metainfo{$full_rev} = { 'nprevious' => 0 };
                }
                my $meta = $metainfo{$full_rev};
                my $data;
                while ($data = <$fd>) {
                        chomp $data;
                        last if ($data =~ s/^\t//); # contents of line
 -                      if ($data =~ /^(\S+) (.*)$/) {
 -                              $meta->{$1} = $2;
 +                      if ($data =~ /^(\S+)(?: (.*))?$/) {
 +                              $meta->{$1} = $2 unless exists $meta->{$1};
 +                      }
 +                      if ($data =~ /^previous /) {
 +                              $meta->{'nprevious'}++;
                        }
                }
                my $short_rev = substr($full_rev, 0, 8);
                if ($group_size) {
                        $current_color = ($current_color + 1) % $num_colors;
                }
 -              print "<tr id=\"l$lineno\" class=\"$rev_color[$current_color]\">\n";
 +              my $tr_class = $rev_color[$current_color];
 +              $tr_class .= ' boundary' if (exists $meta->{'boundary'});
 +              $tr_class .= ' no-previous' if ($meta->{'nprevious'} == 0);
 +              $tr_class .= ' multiple-previous' if ($meta->{'nprevious'} > 1);
 +              print "<tr id=\"l$lineno\" class=\"$tr_class\">\n";
                if ($group_size) {
                        print "<td class=\"sha1\"";
                        print " title=\"". esc_html($author) . ", $date\"";
                                                     hash=>$full_rev,
                                                     file_name=>$file_name)},
                                      esc_html($short_rev));
 +                      if ($group_size >= 2) {
 +                              my @author_initials = ($author =~ /\b([[:upper:]])\B/g);
 +                              if (@author_initials) {
 +                                      print "<br />" .
 +                                            esc_html(join('', @author_initials));
 +                                      #           or join('.', ...)
 +                              }
 +                      }
                        print "</td>\n";
                }
 -              my $parent_commit;
 -              if (!exists $meta->{'parent'}) {
 -                      open (my $dd, "-|", git_cmd(), "rev-parse", "$full_rev^")
 -                              or die_error(500, "Open git-rev-parse failed");
 -                      $parent_commit = <$dd>;
 -                      close $dd;
 -                      chomp($parent_commit);
 -                      $meta->{'parent'} = $parent_commit;
 -              } else {
 -                      $parent_commit = $meta->{'parent'};
 -              }
 +              # 'previous' <sha1 of parent commit> <filename at commit>
 +              if (exists $meta->{'previous'} &&
 +                  $meta->{'previous'} =~ /^([a-fA-F0-9]{40}) (.*)$/) {
 +                      $meta->{'parent'} = $1;
 +                      $meta->{'file_parent'} = unquote($2);
 +              }
 +              my $linenr_commit =
 +                      exists($meta->{'parent'}) ?
 +                      $meta->{'parent'} : $full_rev;
 +              my $linenr_filename =
 +                      exists($meta->{'file_parent'}) ?
 +                      $meta->{'file_parent'} : unquote($meta->{'filename'});
                my $blamed = href(action => 'blame',
 -                                file_name => $meta->{'filename'},
 -                                hash_base => $parent_commit);
 +                                file_name => $linenr_filename,
 +                                hash_base => $linenr_commit);
                print "<td class=\"linenr\">";
                print $cgi->a({ -href => "$blamed#l$orig_lineno",
                                -class => "linenr" },
@@@ -5192,8 -5162,6 +5192,8 @@@ sub git_snapshot 
                die_error(400, "Unknown snapshot format");
        } elsif (!grep($_ eq $format, @snapshot_fmts)) {
                die_error(403, "Unsupported snapshot format");
 +      } elsif ($known_snapshot_formats{$format}{'disabled'}) {
 +              die_error(403, "Snapshot format not allowed");
        }
  
        if (!defined $hash) {