From: Junio C Hamano Date: Mon, 27 Feb 2012 23:33:26 +0000 (-0800) Subject: Merge branch 'jn/gitweb-unborn-head' into maint X-Git-Tag: v1.7.9.3~20 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e22c522730b0fc1dd2a1f12b6e508c5fb2e0fe6c?ds=inline;hp=-c Merge branch 'jn/gitweb-unborn-head' into maint * jn/gitweb-unborn-head: gitweb: Fix "heads" view when there is no current branch --- e22c522730b0fc1dd2a1f12b6e508c5fb2e0fe6c diff --combined gitweb/gitweb.perl index c876e0fb4e,a174c9d6c4..d5dbd6428b --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@@ -52,7 -52,7 +52,7 @@@ sub evaluate_uri # as base URL. # Therefore, if we needed to strip PATH_INFO, then we know that we have # to build the base URL ourselves: - our $path_info = $ENV{"PATH_INFO"}; + our $path_info = decode_utf8($ENV{"PATH_INFO"}); if ($path_info) { if ($my_url =~ s,\Q$path_info\E$,, && $my_uri =~ s,\Q$path_info\E$,, && @@@ -816,9 -816,9 +816,9 @@@ sub evaluate_query_params while (my ($name, $symbol) = each %cgi_param_mapping) { if ($symbol eq 'opt') { - $input_params{$name} = [ $cgi->param($symbol) ]; + $input_params{$name} = [ map { decode_utf8($_) } $cgi->param($symbol) ]; } else { - $input_params{$name} = $cgi->param($symbol); + $input_params{$name} = decode_utf8($cgi->param($symbol)); } } } @@@ -2765,7 -2765,7 +2765,7 @@@ sub git_populate_project_tagcloud } my $cloud; - my $matched = $cgi->param('by_tag'); + my $matched = $input_params{'ctag'}; if (eval { require HTML::TagCloud; 1; }) { $cloud = HTML::TagCloud->new; foreach my $ctag (sort keys %ctags_lc) { @@@ -3871,7 -3871,7 +3871,7 @@@ sub print_search_form -values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) . $cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) . " search:\n", - $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . + $cgi->textfield(-name => "s", -value => $searchtext, -override => 1) . "\n" . "" . $cgi->checkbox(-name => 'sr', -value => 1, -label => 're', -checked => $search_use_regexp) . @@@ -5280,7 -5280,7 +5280,7 @@@ sub git_project_list_body my $check_forks = gitweb_check_feature('forks'); my $show_ctags = gitweb_check_feature('ctags'); - my $tagfilter = $show_ctags ? $cgi->param('by_tag') : undef; + my $tagfilter = $show_ctags ? $input_params{'ctag'} : undef; $check_forks = undef if ($tagfilter || $searchtext); @@@ -5568,7 -5568,7 +5568,7 @@@ sub git_tags_body sub git_heads_body { # uses global variable $project - my ($headlist, $head, $from, $to, $extra) = @_; + my ($headlist, $head_at, $from, $to, $extra) = @_; $from = 0 unless defined $from; $to = $#{$headlist} if (!defined $to || $#{$headlist} < $to); @@@ -5577,7 -5577,7 +5577,7 @@@ for (my $i = $from; $i <= $to; $i++) { my $entry = $headlist->[$i]; my %ref = %$entry; - my $curr = $ref{'id'} eq $head; + my $curr = defined $head_at && $ref{'id'} eq $head_at; if ($alternate) { print "\n"; } else { @@@ -5850,10 -5850,9 +5850,10 @@@ sub git_search_files my $alternate = 1; my $matches = 0; my $lastfile = ''; + my $file_href; while (my $line = <$fd>) { chomp $line; - my ($file, $file_href, $lno, $ltext, $binary); + my ($file, $lno, $ltext, $binary); last if ($matches++ > 1000); if ($line =~ /^Binary file (.+) matches$/) { $file = $1; @@@ -5993,7 -5992,7 +5993,7 @@@ sub git_project_list } print $cgi->startform(-method => "get") . "

Search:\n" . - $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . + $cgi->textfield(-name => "s", -value => $searchtext, -override => 1) . "\n" . "

" . $cgi->end_form() . "\n"; git_project_list_body(\@list, $order); @@@ -6196,7 -6195,7 +6196,7 @@@ sub git_tag sub git_blame_common { my $format = shift || 'porcelain'; - if ($format eq 'porcelain' && $cgi->param('js')) { + if ($format eq 'porcelain' && $input_params{'javascript'}) { $format = 'incremental'; $action = 'blame_incremental'; # for page title etc } diff --combined t/t9500-gitweb-standalone-no-errors.sh index 3e4fdbe562,9d3ec16769..858a649cb6 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@@ -629,45 -629,6 +629,45 @@@ test_expect_success 'config override: tree view, features enabled in repo config (2)' \ 'gitweb_run "p=.git;a=tree"' +# ---------------------------------------------------------------------- +# searching + +cat >>gitweb_config.perl <<\EOF + +# enable search +$feature{'search'}{'default'} = [1]; +$feature{'grep'}{'default'} = [1]; +$feature{'pickaxe'}{'default'} = [1]; +EOF + +test_expect_success \ + 'search: preparation' \ + 'echo "1st MATCH" >>file && + echo "2nd MATCH" >>file && + echo "MATCH" >>bar && + git add file bar && + git commit -m "Added MATCH word"' + +test_expect_success \ + 'search: commit author' \ + 'gitweb_run "p=.git;a=search;h=HEAD;st=author;s=A+U+Thor"' + +test_expect_success \ + 'search: commit message' \ + 'gitweb_run "p=.git;a=search;h=HEAD;st=commitr;s=MATCH"' + +test_expect_success \ + 'search: grep' \ + 'gitweb_run "p=.git;a=search;h=HEAD;st=grep;s=MATCH"' + +test_expect_success \ + 'search: pickaxe' \ + 'gitweb_run "p=.git;a=search;h=HEAD;st=pickaxe;s=MATCH"' + +test_expect_success \ + 'search: projects' \ + 'gitweb_run "a=project_list;s=.git"' + # ---------------------------------------------------------------------- # non-ASCII in README.html @@@ -770,4 -731,13 +770,13 @@@ test_expect_success 'echo "\$projects_list_group_categories = 1;" >>gitweb_config.perl && gitweb_run' + # ---------------------------------------------------------------------- + # unborn branches + + test_expect_success \ + 'unborn HEAD: "summary" page (with "heads" subview)' \ + 'git checkout orphan_branch || git checkout --orphan orphan_branch && + test_when_finished "git checkout master" && + gitweb_run "p=.git;a=summary"' + test_done