From: Junio C Hamano Date: Wed, 23 Mar 2011 21:55:55 +0000 (-0700) Subject: Merge branch 'kc/gitweb-pathinfo-w-anchor' X-Git-Tag: v1.7.5-rc0~28 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cd3065f9e3c27594a91540e971d147f1acba89de?hp=-c Merge branch 'kc/gitweb-pathinfo-w-anchor' * kc/gitweb-pathinfo-w-anchor: gitweb: fix #patchNN anchors when path_info is enabled --- cd3065f9e3c27594a91540e971d147f1acba89de diff --combined gitweb/gitweb.perl index 9dccfb01d6,f275adbcf1..0178633b26 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@@ -1199,11 -1199,15 +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}) { @@@ -1314,6 -1318,10 +1318,10 @@@ # 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; } @@@ -4335,7 -4343,8 +4343,8 @@@ sub git_difftree_body # link to patch $patchno++; print "" . - $cgi->a({-href => "#patch$patchno"}, "patch") . + $cgi->a({-href => href(-anchor=>"patch$patchno")}, + "patch") . " | " . "\n"; } @@@ -4432,8 -4441,9 +4441,9 @@@ 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'})}, @@@ -4452,8 -4462,9 +4462,9 @@@ 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'})}, @@@ -4494,7 -4505,8 +4505,8 @@@ 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) @@@ -4539,7 -4551,8 +4551,8 @@@ 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) @@@ -4906,6 -4919,7 +4919,6 @@@ sub git_log_body next if !%co; my $commit = $co{'id'}; my $ref = format_ref_marker($refs, $commit); - my %ad = parse_date($co{'author_epoch'}); git_print_header_div('commit', "$co{'age_string'}" . esc_html($co{'title'}) . $ref, @@@ -7063,7 -7077,7 +7076,7 @@@ sub git_feed if (defined($commitlist[0])) { %latest_commit = %{$commitlist[0]}; my $latest_epoch = $latest_commit{'committer_epoch'}; - %latest_date = parse_date($latest_epoch); + %latest_date = parse_date($latest_epoch, $latest_commit{'comitter_tz'}); my $if_modified = $cgi->http('IF_MODIFIED_SINCE'); if (defined $if_modified) { my $since; @@@ -7194,7 -7208,7 +7207,7 @@@ XM if (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) { last; } - my %cd = parse_date($co{'author_epoch'}); + my %cd = parse_date($co{'author_epoch'}, $co{'author_tz'}); # get list of changed files open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,