Code

Merge commit 'sg/merge-options^' into jk/renamelimit
[git.git] / t / t9500-gitweb-standalone-no-errors.sh
index 44ae503b992ee26023a19830039062e01be9aa57..061a2596d3b63e7d737d735c4a6cb097bfcf387f 100755 (executable)
@@ -18,6 +18,7 @@ gitweb_init () {
 our \$version = "current";
 our \$GIT = "git";
 our \$projectroot = "$(pwd)";
+our \$project_maxdepth = 8;
 our \$home_link_str = "projects";
 our \$site_name = "[localhost]";
 our \$site_header = "";
@@ -30,7 +31,6 @@ our \$projects_list = "";
 our \$export_ok = "";
 our \$strict_export = "";
 
-CGI::Carp::set_programname("gitweb/gitweb.cgi");
 EOF
 
        cat >.git/description <<EOF
@@ -58,8 +58,22 @@ gitweb_run () {
        # gitweb.log is left for debugging
 }
 
+safe_chmod () {
+       chmod "$1" "$2" &&
+       if [ "$(git config --get core.filemode)" = false ]
+       then
+               git update-index --chmod="$1" "$2"
+       fi
+}
+
 . ./test-lib.sh
 
+perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
+    test_expect_success 'skipping gitweb tests, perl version is too old' :
+    test_done
+    exit
+}
+
 gitweb_init
 
 # ----------------------------------------------------------------------
@@ -223,7 +237,7 @@ test_debug 'cat gitweb.log'
 
 test_expect_success \
        'commitdiff(0): mode change' \
-       'chmod a+x new_file &&
+       'safe_chmod +x new_file &&
         git commit -a -m "Mode changed." &&
         gitweb_run "p=.git;a=commitdiff"'
 test_debug 'cat gitweb.log'
@@ -262,7 +276,7 @@ test_debug 'cat gitweb.log'
 test_expect_success \
        'commitdiff(0): mode change and modified' \
        'echo "New line" >> file2 &&
-        chmod a+x file2 &&
+        safe_chmod +x file2 &&
         git commit -a -m "Mode change and modification." &&
         gitweb_run "p=.git;a=commitdiff"'
 test_debug 'cat gitweb.log'
@@ -289,7 +303,7 @@ test_expect_success \
        'commitdiff(0): renamed, mode change and modified' \
        'git mv file3 file2 &&
         echo "Propter nomen suum." >> file2 &&
-        chmod a+x file2 &&
+        safe_chmod +x file2 &&
         git commit -a -m "File rename, mode change and modification." &&
         gitweb_run "p=.git;a=commitdiff"'
 test_debug 'cat gitweb.log'
@@ -406,10 +420,10 @@ test_expect_success \
         git add 03-new &&
         git mv 04-rename-from 04-rename-to &&
         echo "Changed" >> 04-rename-to &&
-        chmod a+x 05-mode-change &&
+        safe_chmod +x 05-mode-change &&
         rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
         echo "Changed and have mode changed" > 07-change-mode-change   &&
-        chmod a+x 07-change-mode-change &&
+        safe_chmod +x 07-change-mode-change &&
         git commit -a -m "Large commit" &&
         git checkout master'
 
@@ -469,6 +483,22 @@ test_expect_success \
        'gitweb_run "p=.git;a=history;f=file"'
 test_debug 'cat gitweb.log'
 
+test_expect_success \
+       'logs: history (implicit HEAD, non-existent file)' \
+       'gitweb_run "p=.git;a=history;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'logs: history (implicit HEAD, deleted file)' \
+       'git checkout master &&
+        echo "to be deleted" > deleted_file &&
+        git add deleted_file &&
+        git commit -m "Add file to be deleted" &&
+        git rm deleted_file &&
+        git commit -m "Delete file" &&
+        gitweb_run "p=.git;a=history;f=deleted_file"'
+test_debug 'cat gitweb.log'
+
 # ----------------------------------------------------------------------
 # feed generation
 
@@ -515,4 +545,80 @@ test_expect_success \
        'gitweb_run "p=.git;a=log"'
 test_debug 'cat gitweb.log'
 
+# ----------------------------------------------------------------------
+# extra options
+
+test_expect_success \
+       'opt: log --no-merges' \
+       'gitweb_run "p=.git;a=log;opt=--no-merges"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'opt: atom --no-merges' \
+       'gitweb_run "p=.git;a=log;opt=--no-merges"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'opt: "file" history --no-merges' \
+       'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'opt: log --no-such-option (invalid option)' \
+       'gitweb_run "p=.git;a=log;opt=--no-such-option"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'opt: tree --no-merges (invalid option for action)' \
+       'gitweb_run "p=.git;a=tree;opt=--no-merges"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# testing config_to_multi / cloneurl
+
+test_expect_success \
+       'URL: no project URLs, no base URL' \
+       'gitweb_run "p=.git;a=summary"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'URL: project URLs via gitweb.url' \
+       'git config --add gitweb.url git://example.com/git/trash.git &&
+        git config --add gitweb.url http://example.com/git/trash.git &&
+        gitweb_run "p=.git;a=summary"'
+test_debug 'cat gitweb.log'
+
+cat >.git/cloneurl <<\EOF
+git://example.com/git/trash.git
+http://example.com/git/trash.git
+EOF
+
+test_expect_success \
+       'URL: project URLs via cloneurl file' \
+       'gitweb_run "p=.git;a=summary"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
+# gitweb config and repo config
+
+cat >>gitweb_config.perl <<EOF
+
+\$feature{'blame'}{'override'} = 1;
+\$feature{'snapshot'}{'override'} = 1;
+EOF
+
+test_expect_success \
+       'config override: tree view, features disabled in repo config' \
+       'git config gitweb.blame no &&
+        git config gitweb.snapshot none &&
+        gitweb_run "p=.git;a=tree"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'config override: tree view, features enabled in repo config' \
+       'git config gitweb.blame yes &&
+        git config gitweb.snapshot "zip,tgz, tbz2" &&
+        gitweb_run "p=.git;a=tree"'
+test_debug 'cat gitweb.log'
+
 test_done