Merge branch 'jn/gitweb-unspecified-action'
authorJunio C Hamano <gitster@pobox.com>
Sun, 29 Jan 2012 21:18:50 +0000 (13:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 29 Jan 2012 21:18:50 +0000 (13:18 -0800)
* jn/gitweb-unspecified-action:
gitweb: Fix actionless dispatch for non-existent objects

gitweb/gitweb.perl
t/t9500-gitweb-standalone-no-errors.sh
index abb5a79afce445c73693593d32cced0ccdb90fe3..9cf7e714a9a00d0d7d153d4336614e70b565d3fa 100755 (executable)
@@ -1123,8 +1123,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 {
@@ -2391,7 +2393,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 ab249178123653943bb087ccc40f2b420cc1e67c..0f771c673d58009e2bcde45254d4b4e9fa68efb9 100755 (executable)
@@ -474,6 +474,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"'