Merge branch 'jn/gitweb-unborn-head' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2012 23:33:26 +0000 (15:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2012 23:33:26 +0000 (15:33 -0800)
* jn/gitweb-unborn-head:
gitweb: Fix "heads" view when there is no current branch

1  2 
gitweb/gitweb.perl
t/t9500-gitweb-standalone-no-errors.sh
diff --combined gitweb/gitweb.perl
index c876e0fb4e04cd339db0a6a4c15ae5f2570ac1c9,a174c9d6c49ff1895c8f4e10f99bfc8c40b6d007..d5dbd6428b599bc937c50cb87de85099fc1af04c
@@@ -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" .
              "<span title=\"Extended regular expression\">" .
              $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);
  
        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 "<tr class=\"dark\">\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") .
              "<p class=\"projsearch\">Search:\n" .
 -            $cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
 +            $cgi->textfield(-name => "s", -value => $searchtext, -override => 1) . "\n" .
              "</p>" .
              $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
        }
index 3e4fdbe5624f1d1a197b0a1a450524b6d1095b0b,9d3ec16769829af061e0798d7f3c92f3fca2511e..858a649cb64e40a083a60c16e7ad818fdecb0fa9
@@@ -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