Sync with 1.7.4.2
authorJunio C Hamano <gitster@pobox.com>
Sat, 26 Mar 2011 00:57:08 +0000 (17:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 26 Mar 2011 00:57:08 +0000 (17:57 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1  2 
gitweb/gitweb.perl

diff --combined gitweb/gitweb.perl
@@@ -1199,15 -1199,11 +1199,15 @@@ if (defined caller) 
  # -full => 0|1      - use absolute/full URL ($my_uri/$my_url as base)
  # -replay => 1      - start from a current view (replay with modifications)
  # -path_info => 0|1 - don't use/use path_info URL (if possible)
 +# -anchor => ANCHOR - add #ANCHOR to end of URL, implies -replay if used alone
  sub href {
        my %params = @_;
        # default is to use -absolute url() i.e. $my_uri
        my $href = $params{-full} ? $my_url : $my_uri;
  
 +      # implicit -replay, must be first of implicit params
 +      $params{-replay} = 1 if (keys %params == 1 && $params{-anchor});
 +
        $params{'project'} = $project unless exists $params{'project'};
  
        if ($params{-replay}) {
        # final transformation: trailing spaces must be escaped (URI-encoded)
        $href =~ s/(\s+)$/CGI::escape($1)/e;
  
 +      if ($params{-anchor}) {
 +              $href .= "#".esc_param($params{-anchor});
 +      }
 +
        return $href;
  }
  
@@@ -2921,8 -2913,10 +2921,10 @@@ sub parse_date 
        $date{'iso-8601'}  = sprintf "%04d-%02d-%02dT%02d:%02d:%02dZ",
                             1900+$year, 1+$mon, $mday, $hour ,$min, $sec;
  
-       $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
-       my $local = $epoch + ((int $1 + ($2/60)) * 3600);
+       my ($tz_sign, $tz_hour, $tz_min) =
+               ($tz =~ m/^([-+])(\d\d)(\d\d)$/);
+       $tz_sign = ($tz_sign eq '-' ? -1 : +1);
+       my $local = $epoch + $tz_sign*((($tz_hour*60) + $tz_min)*60);
        ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
        $date{'hour_local'} = $hour;
        $date{'minute_local'} = $min;
@@@ -4343,8 -4337,7 +4345,8 @@@ sub git_difftree_body 
                                # link to patch
                                $patchno++;
                                print "<td class=\"link\">" .
 -                                    $cgi->a({-href => "#patch$patchno"}, "patch") .
 +                                    $cgi->a({-href => href(-anchor=>"patch$patchno")},
 +                                            "patch") .
                                      " | " .
                                      "</td>\n";
                        }
                        if ($action eq 'commitdiff') {
                                # link to patch
                                $patchno++;
 -                              print $cgi->a({-href => "#patch$patchno"}, "patch");
 -                              print " | ";
 +                              print $cgi->a({-href => href(-anchor=>"patch$patchno")},
 +                                            "patch") .
 +                                    " | ";
                        }
                        print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
                                                     hash_base=>$hash, file_name=>$diff->{'file'})},
                        if ($action eq 'commitdiff') {
                                # link to patch
                                $patchno++;
 -                              print $cgi->a({-href => "#patch$patchno"}, "patch");
 -                              print " | ";
 +                              print $cgi->a({-href => href(-anchor=>"patch$patchno")},
 +                                            "patch") .
 +                                    " | ";
                        }
                        print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'from_id'},
                                                     hash_base=>$parent, file_name=>$diff->{'file'})},
                        if ($action eq 'commitdiff') {
                                # link to patch
                                $patchno++;
 -                              print $cgi->a({-href => "#patch$patchno"}, "patch") .
 +                              print $cgi->a({-href => href(-anchor=>"patch$patchno")},
 +                                            "patch") .
                                      " | ";
                        } elsif ($diff->{'to_id'} ne $diff->{'from_id'}) {
                                # "commit" view and modified file (not onlu mode changed)
                        if ($action eq 'commitdiff') {
                                # link to patch
                                $patchno++;
 -                              print $cgi->a({-href => "#patch$patchno"}, "patch") .
 +                              print $cgi->a({-href => href(-anchor=>"patch$patchno")},
 +                                            "patch") .
                                      " | ";
                        } elsif ($diff->{'to_id'} ne $diff->{'from_id'}) {
                                # "commit" view and modified file (not only pure rename or copy)