Code

Merge branch 'jn/gitweb-unspecified-action' into maint-1.7.8
authorJunio C Hamano <gitster@pobox.com>
Tue, 20 Mar 2012 22:24:23 +0000 (15:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Mar 2012 22:24:23 +0000 (15:24 -0700)
* jn/gitweb-unspecified-action:
  gitweb: Fix actionless dispatch for non-existent objects

gitweb/gitweb.perl
t/t9500-gitweb-standalone-no-errors.sh

index 874023a33e9162b99bfa5b0e4038b102c129f6f1..6cf38853b5a1577ae0c7df80c39a98f44b22915e 100755 (executable)
@@ -1122,8 +1122,10 @@ sub dispatch {
        if (!defined $action) {
                if (defined $hash) {
                        $action = git_get_type($hash);
+                       $action or die_error(404, "Object does not exist");
                } elsif (defined $hash_base && defined $file_name) {
                        $action = git_get_type("$hash_base:$file_name");
+                       $action or die_error(404, "File or directory does not exist");
                } elsif (defined $project) {
                        $action = 'summary';
                } else {
@@ -2364,7 +2366,7 @@ sub get_feed_info {
        return unless (defined $project);
        # some views should link to OPML, or to generic project feed,
        # or don't have specific feed yet (so they should use generic)
-       return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x);
+       return if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x);
 
        my $branch;
        # branches refs uses 'refs/heads/' prefix (fullname) to differentiate
index 53297156a314a5b5e03385a3ad887eff959359c4..94365bb0068661d0a964199f91878decb983b986 100755 (executable)
@@ -403,6 +403,14 @@ test_expect_success \
        'path_info: project/branch:dir/' \
        'gitweb_run "" "/.git/master:foo/"'
 
+test_expect_success \
+       'path_info: project/branch (non-existent)' \
+       'gitweb_run "" "/.git/non-existent"'
+
+test_expect_success \
+       'path_info: project/branch:filename (non-existent branch)' \
+       'gitweb_run "" "/.git/non-existent:non-existent"'
+
 test_expect_success \
        'path_info: project/branch:file (non-existent)' \
        'gitweb_run "" "/.git/master:non-existent"'