t / t9500-gitweb-standalone-no-errors.shon commit Merge branch 'maint-1.7.8' into maint (80a3f53)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Jakub Narebski
   4#
   5
   6test_description='gitweb as standalone script (basic tests).
   7
   8This test runs gitweb (git web interface) as CGI script from
   9commandline, and checks that it would not write any errors
  10or warnings to log.'
  11
  12
  13. ./gitweb-lib.sh
  14
  15# ----------------------------------------------------------------------
  16# no commits (empty, just initialized repository)
  17
  18test_expect_success \
  19        'no commits: projects_list (implicit)' \
  20        'gitweb_run'
  21
  22test_expect_success \
  23        'no commits: projects_index' \
  24        'gitweb_run "a=project_index"'
  25
  26test_expect_success \
  27        'no commits: .git summary (implicit)' \
  28        'gitweb_run "p=.git"'
  29
  30test_expect_success \
  31        'no commits: .git commit (implicit HEAD)' \
  32        'gitweb_run "p=.git;a=commit"'
  33
  34test_expect_success \
  35        'no commits: .git commitdiff (implicit HEAD)' \
  36        'gitweb_run "p=.git;a=commitdiff"'
  37
  38test_expect_success \
  39        'no commits: .git tree (implicit HEAD)' \
  40        'gitweb_run "p=.git;a=tree"'
  41
  42test_expect_success \
  43        'no commits: .git heads' \
  44        'gitweb_run "p=.git;a=heads"'
  45
  46test_expect_success \
  47        'no commits: .git tags' \
  48        'gitweb_run "p=.git;a=tags"'
  49
  50
  51# ----------------------------------------------------------------------
  52# initial commit
  53
  54test_expect_success \
  55        'Make initial commit' \
  56        'echo "Not an empty file." > file &&
  57         git add file &&
  58         git commit -a -m "Initial commit." &&
  59         git branch b'
  60
  61test_expect_success \
  62        'projects_list (implicit)' \
  63        'gitweb_run'
  64
  65test_expect_success \
  66        'projects_index' \
  67        'gitweb_run "a=project_index"'
  68
  69test_expect_success \
  70        '.git summary (implicit)' \
  71        'gitweb_run "p=.git"'
  72
  73test_expect_success \
  74        '.git commit (implicit HEAD)' \
  75        'gitweb_run "p=.git;a=commit"'
  76
  77test_expect_success \
  78        '.git commitdiff (implicit HEAD, root commit)' \
  79        'gitweb_run "p=.git;a=commitdiff"'
  80
  81test_expect_success \
  82        '.git commitdiff_plain (implicit HEAD, root commit)' \
  83        'gitweb_run "p=.git;a=commitdiff_plain"'
  84
  85test_expect_success \
  86        '.git commit (HEAD)' \
  87        'gitweb_run "p=.git;a=commit;h=HEAD"'
  88
  89test_expect_success \
  90        '.git tree (implicit HEAD)' \
  91        'gitweb_run "p=.git;a=tree"'
  92
  93test_expect_success \
  94        '.git blob (file)' \
  95        'gitweb_run "p=.git;a=blob;f=file"'
  96
  97test_expect_success \
  98        '.git blob_plain (file)' \
  99        'gitweb_run "p=.git;a=blob_plain;f=file"'
 100
 101# ----------------------------------------------------------------------
 102# nonexistent objects
 103
 104test_expect_success \
 105        '.git commit (non-existent)' \
 106        'gitweb_run "p=.git;a=commit;h=non-existent"'
 107
 108test_expect_success \
 109        '.git commitdiff (non-existent)' \
 110        'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
 111
 112test_expect_success \
 113        '.git commitdiff (non-existent vs HEAD)' \
 114        'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
 115
 116test_expect_success \
 117        '.git tree (0000000000000000000000000000000000000000)' \
 118        'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
 119
 120test_expect_success \
 121        '.git tag (0000000000000000000000000000000000000000)' \
 122        'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
 123
 124test_expect_success \
 125        '.git blob (non-existent)' \
 126        'gitweb_run "p=.git;a=blob;f=non-existent"'
 127
 128test_expect_success \
 129        '.git blob_plain (non-existent)' \
 130        'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
 131
 132
 133# ----------------------------------------------------------------------
 134# commitdiff testing (implicit, one implicit tree-ish)
 135
 136test_expect_success \
 137        'commitdiff(0): root' \
 138        'gitweb_run "p=.git;a=commitdiff"'
 139
 140test_expect_success \
 141        'commitdiff(0): file added' \
 142        'echo "New file" > new_file &&
 143         git add new_file &&
 144         git commit -a -m "File added." &&
 145         gitweb_run "p=.git;a=commitdiff"'
 146
 147test_expect_success \
 148        'commitdiff(0): mode change' \
 149        'test_chmod +x new_file &&
 150         git commit -a -m "Mode changed." &&
 151         gitweb_run "p=.git;a=commitdiff"'
 152
 153test_expect_success \
 154        'commitdiff(0): file renamed' \
 155        'git mv new_file renamed_file &&
 156         git commit -a -m "File renamed." &&
 157         gitweb_run "p=.git;a=commitdiff"'
 158
 159test_expect_success SYMLINKS \
 160        'commitdiff(0): file to symlink' \
 161        'rm renamed_file &&
 162         ln -s file renamed_file &&
 163         git commit -a -m "File to symlink." &&
 164         gitweb_run "p=.git;a=commitdiff"'
 165
 166test_expect_success \
 167        'commitdiff(0): file deleted' \
 168        'git rm renamed_file &&
 169         rm -f renamed_file &&
 170         git commit -a -m "File removed." &&
 171         gitweb_run "p=.git;a=commitdiff"'
 172
 173test_expect_success \
 174        'commitdiff(0): file copied / new file' \
 175        'cp file file2 &&
 176         git add file2 &&
 177         git commit -a -m "File copied." &&
 178         gitweb_run "p=.git;a=commitdiff"'
 179
 180test_expect_success \
 181        'commitdiff(0): mode change and modified' \
 182        'echo "New line" >> file2 &&
 183         test_chmod +x file2 &&
 184         git commit -a -m "Mode change and modification." &&
 185         gitweb_run "p=.git;a=commitdiff"'
 186
 187test_expect_success \
 188        'commitdiff(0): renamed and modified' \
 189        'cat >file2<<EOF &&
 190Dominus regit me,
 191et nihil mihi deerit.
 192In loco pascuae ibi me collocavit,
 193super aquam refectionis educavit me;
 194animam meam convertit,
 195deduxit me super semitas jusitiae,
 196propter nomen suum.
 197EOF
 198         git commit -a -m "File added." &&
 199         git mv file2 file3 &&
 200         echo "Propter nomen suum." >> file3 &&
 201         git commit -a -m "File rename and modification." &&
 202         gitweb_run "p=.git;a=commitdiff"'
 203
 204test_expect_success \
 205        'commitdiff(0): renamed, mode change and modified' \
 206        'git mv file3 file2 &&
 207         echo "Propter nomen suum." >> file2 &&
 208         test_chmod +x file2 &&
 209         git commit -a -m "File rename, mode change and modification." &&
 210         gitweb_run "p=.git;a=commitdiff"'
 211
 212# ----------------------------------------------------------------------
 213# commitdiff testing (taken from t4114-apply-typechange.sh)
 214
 215test_expect_success SYMLINKS 'setup typechange commits' '
 216        echo "hello world" > foo &&
 217        echo "hi planet" > bar &&
 218        git update-index --add foo bar &&
 219        git commit -m initial &&
 220        git branch initial &&
 221        rm -f foo &&
 222        ln -s bar foo &&
 223        git update-index foo &&
 224        git commit -m "foo symlinked to bar" &&
 225        git branch foo-symlinked-to-bar &&
 226        rm -f foo &&
 227        echo "how far is the sun?" > foo &&
 228        git update-index foo &&
 229        git commit -m "foo back to file" &&
 230        git branch foo-back-to-file &&
 231        rm -f foo &&
 232        git update-index --remove foo &&
 233        mkdir foo &&
 234        echo "if only I knew" > foo/baz &&
 235        git update-index --add foo/baz &&
 236        git commit -m "foo becomes a directory" &&
 237        git branch "foo-becomes-a-directory" &&
 238        echo "hello world" > foo/baz &&
 239        git update-index foo/baz &&
 240        git commit -m "foo/baz is the original foo" &&
 241        git branch foo-baz-renamed-from-foo
 242        '
 243
 244test_expect_success \
 245        'commitdiff(2): file renamed from foo to foo/baz' \
 246        'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
 247
 248test_expect_success \
 249        'commitdiff(2): file renamed from foo/baz to foo' \
 250        'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
 251
 252test_expect_success \
 253        'commitdiff(2): directory becomes file' \
 254        'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
 255
 256test_expect_success \
 257        'commitdiff(2): file becomes directory' \
 258        'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
 259
 260test_expect_success \
 261        'commitdiff(2): file becomes symlink' \
 262        'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
 263
 264test_expect_success \
 265        'commitdiff(2): symlink becomes file' \
 266        'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
 267
 268test_expect_success \
 269        'commitdiff(2): symlink becomes directory' \
 270        'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
 271
 272test_expect_success \
 273        'commitdiff(2): directory becomes symlink' \
 274        'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
 275
 276# ----------------------------------------------------------------------
 277# commitdiff testing (incomplete lines)
 278
 279test_expect_success 'setup incomplete lines' '
 280        cat >file<<-\EOF &&
 281        Dominus regit me,
 282        et nihil mihi deerit.
 283        In loco pascuae ibi me collocavit,
 284        super aquam refectionis educavit me;
 285        animam meam convertit,
 286        deduxit me super semitas jusitiae,
 287        propter nomen suum.
 288        CHANGE_ME
 289        EOF
 290        git commit -a -m "Preparing for incomplete lines" &&
 291        echo "incomplete" | tr -d "\\012" >>file &&
 292        git commit -a -m "Add incomplete line" &&
 293        git tag incomplete_lines_add &&
 294        sed -e s/CHANGE_ME/change_me/ <file >file+ &&
 295        mv -f file+ file &&
 296        git commit -a -m "Incomplete context line" &&
 297        git tag incomplete_lines_ctx &&
 298        echo "Dominus regit me," >file &&
 299        echo "incomplete line" | tr -d "\\012" >>file &&
 300        git commit -a -m "Change incomplete line" &&
 301        git tag incomplete_lines_chg
 302        echo "Dominus regit me," >file &&
 303        git commit -a -m "Remove incomplete line" &&
 304        git tag incomplete_lines_rem
 305'
 306
 307test_expect_success 'commitdiff(1): addition of incomplete line' '
 308        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_add"
 309'
 310
 311test_expect_success 'commitdiff(1): incomplete line as context line' '
 312        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_ctx"
 313'
 314
 315test_expect_success 'commitdiff(1): change incomplete line' '
 316        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_chg"
 317'
 318
 319test_expect_success 'commitdiff(1): removal of incomplete line' '
 320        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_rem"
 321'
 322
 323# ----------------------------------------------------------------------
 324# commit, commitdiff: merge, large
 325test_expect_success \
 326        'Create a merge' \
 327        'git checkout b &&
 328         echo "Branch" >> b &&
 329         git add b &&
 330         git commit -a -m "On branch" &&
 331         git checkout master &&
 332         git pull . b &&
 333         git tag merge_commit'
 334
 335test_expect_success \
 336        'commit(0): merge commit' \
 337        'gitweb_run "p=.git;a=commit"'
 338
 339test_expect_success \
 340        'commitdiff(0): merge commit' \
 341        'gitweb_run "p=.git;a=commitdiff"'
 342
 343test_expect_success \
 344        'Prepare large commit' \
 345        'git checkout b &&
 346         echo "To be changed" > 01-change &&
 347         echo "To be renamed" > 02-pure-rename-from &&
 348         echo "To be deleted" > 03-delete &&
 349         echo "To be renamed and changed" > 04-rename-from &&
 350         echo "To have mode changed" > 05-mode-change &&
 351         echo "File to symlink" > 06-file-or-symlink &&
 352         echo "To be changed and have mode changed" > 07-change-mode-change     &&
 353         git add 0* &&
 354         git commit -a -m "Prepare large commit" &&
 355         echo "Changed" > 01-change &&
 356         git mv 02-pure-rename-from 02-pure-rename-to &&
 357         git rm 03-delete && rm -f 03-delete &&
 358         echo "A new file" > 03-new &&
 359         git add 03-new &&
 360         git mv 04-rename-from 04-rename-to &&
 361         echo "Changed" >> 04-rename-to &&
 362         test_chmod +x 05-mode-change &&
 363         rm -f 06-file-or-symlink &&
 364         if test_have_prereq SYMLINKS; then
 365                ln -s 01-change 06-file-or-symlink
 366         else
 367                printf %s 01-change > 06-file-or-symlink
 368         fi &&
 369         echo "Changed and have mode changed" > 07-change-mode-change   &&
 370         test_chmod +x 07-change-mode-change &&
 371         git commit -a -m "Large commit" &&
 372         git checkout master'
 373
 374test_expect_success \
 375        'commit(1): large commit' \
 376        'gitweb_run "p=.git;a=commit;h=b"'
 377
 378test_expect_success \
 379        'commitdiff(1): large commit' \
 380        'gitweb_run "p=.git;a=commitdiff;h=b"'
 381
 382# ----------------------------------------------------------------------
 383# side-by-side diff
 384
 385test_expect_success 'side-by-side: addition of incomplete line' '
 386        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_add;ds=sidebyside"
 387'
 388
 389test_expect_success 'side-by-side: incomplete line as context line' '
 390        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_ctx;ds=sidebyside"
 391'
 392
 393test_expect_success 'side-by-side: changed incomplete line' '
 394        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_chg;ds=sidebyside"
 395'
 396
 397test_expect_success 'side-by-side: removal of incomplete line' '
 398        gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_rem;ds=sidebyside"
 399'
 400
 401test_expect_success 'side-by-side: merge commit' '
 402        gitweb_run "p=.git;a=commitdiff;h=merge_commit;ds=sidebyside"
 403'
 404
 405# ----------------------------------------------------------------------
 406# tags testing
 407
 408test_expect_success \
 409        'tags: list of different types of tags' \
 410        'git checkout master &&
 411         git tag -a -m "Tag commit object" tag-commit HEAD &&
 412         git tag -a -m "" tag-commit-nomessage HEAD &&
 413         git tag -a -m "Tag tag object" tag-tag tag-commit &&
 414         git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
 415         git tag -a -m "Tag blob object" tag-blob HEAD:file &&
 416         git tag lightweight/tag-commit HEAD &&
 417         git tag lightweight/tag-tag tag-commit &&
 418         git tag lightweight/tag-tree HEAD^{tree} &&
 419         git tag lightweight/tag-blob HEAD:file &&
 420         gitweb_run "p=.git;a=tags"'
 421
 422test_expect_success \
 423        'tag: Tag to commit object' \
 424        'gitweb_run "p=.git;a=tag;h=tag-commit"'
 425
 426test_expect_success \
 427        'tag: on lightweight tag (invalid)' \
 428        'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
 429
 430# ----------------------------------------------------------------------
 431# logs
 432
 433test_expect_success \
 434        'logs: log (implicit HEAD)' \
 435        'gitweb_run "p=.git;a=log"'
 436
 437test_expect_success \
 438        'logs: shortlog (implicit HEAD)' \
 439        'gitweb_run "p=.git;a=shortlog"'
 440
 441test_expect_success \
 442        'logs: history (implicit HEAD, file)' \
 443        'gitweb_run "p=.git;a=history;f=file"'
 444
 445test_expect_success \
 446        'logs: history (implicit HEAD, non-existent file)' \
 447        'gitweb_run "p=.git;a=history;f=non-existent"'
 448
 449test_expect_success \
 450        'logs: history (implicit HEAD, deleted file)' \
 451        'git checkout master &&
 452         echo "to be deleted" > deleted_file &&
 453         git add deleted_file &&
 454         git commit -m "Add file to be deleted" &&
 455         git rm deleted_file &&
 456         git commit -m "Delete file" &&
 457         gitweb_run "p=.git;a=history;f=deleted_file"'
 458
 459# ----------------------------------------------------------------------
 460# path_info links
 461test_expect_success \
 462        'path_info: project' \
 463        'gitweb_run "" "/.git"'
 464
 465test_expect_success \
 466        'path_info: project/branch' \
 467        'gitweb_run "" "/.git/b"'
 468
 469test_expect_success \
 470        'path_info: project/branch:file' \
 471        'gitweb_run "" "/.git/master:file"'
 472
 473test_expect_success \
 474        'path_info: project/branch:dir/' \
 475        'gitweb_run "" "/.git/master:foo/"'
 476
 477test_expect_success \
 478        'path_info: project/branch:file (non-existent)' \
 479        'gitweb_run "" "/.git/master:non-existent"'
 480
 481test_expect_success \
 482        'path_info: project/branch:dir/ (non-existent)' \
 483        'gitweb_run "" "/.git/master:non-existent/"'
 484
 485
 486test_expect_success \
 487        'path_info: project/branch:/file' \
 488        'gitweb_run "" "/.git/master:/file"'
 489
 490test_expect_success \
 491        'path_info: project/:/file (implicit HEAD)' \
 492        'gitweb_run "" "/.git/:/file"'
 493
 494test_expect_success \
 495        'path_info: project/:/ (implicit HEAD, top tree)' \
 496        'gitweb_run "" "/.git/:/"'
 497
 498
 499# ----------------------------------------------------------------------
 500# feed generation
 501
 502test_expect_success \
 503        'feeds: OPML' \
 504        'gitweb_run "a=opml"'
 505
 506test_expect_success \
 507        'feed: RSS' \
 508        'gitweb_run "p=.git;a=rss"'
 509
 510test_expect_success \
 511        'feed: Atom' \
 512        'gitweb_run "p=.git;a=atom"'
 513
 514# ----------------------------------------------------------------------
 515# encoding/decoding
 516
 517test_expect_success \
 518        'encode(commit): utf8' \
 519        '. "$TEST_DIRECTORY"/t3901-utf8.txt &&
 520         test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
 521         test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
 522         echo "UTF-8" >> file &&
 523         git add file &&
 524         git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
 525         gitweb_run "p=.git;a=commit"'
 526
 527test_expect_success \
 528        'encode(commit): iso-8859-1' \
 529        '. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
 530         test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
 531         test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
 532         echo "ISO-8859-1" >> file &&
 533         git add file &&
 534         git config i18n.commitencoding ISO-8859-1 &&
 535         test_when_finished "git config --unset i18n.commitencoding" &&
 536         git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
 537         gitweb_run "p=.git;a=commit"'
 538
 539test_expect_success \
 540        'encode(log): utf-8 and iso-8859-1' \
 541        'gitweb_run "p=.git;a=log"'
 542
 543# ----------------------------------------------------------------------
 544# extra options
 545
 546test_expect_success \
 547        'opt: log --no-merges' \
 548        'gitweb_run "p=.git;a=log;opt=--no-merges"'
 549
 550test_expect_success \
 551        'opt: atom --no-merges' \
 552        'gitweb_run "p=.git;a=log;opt=--no-merges"'
 553
 554test_expect_success \
 555        'opt: "file" history --no-merges' \
 556        'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
 557
 558test_expect_success \
 559        'opt: log --no-such-option (invalid option)' \
 560        'gitweb_run "p=.git;a=log;opt=--no-such-option"'
 561
 562test_expect_success \
 563        'opt: tree --no-merges (invalid option for action)' \
 564        'gitweb_run "p=.git;a=tree;opt=--no-merges"'
 565
 566# ----------------------------------------------------------------------
 567# testing config_to_multi / cloneurl
 568
 569test_expect_success \
 570       'URL: no project URLs, no base URL' \
 571       'gitweb_run "p=.git;a=summary"'
 572
 573test_expect_success \
 574       'URL: project URLs via gitweb.url' \
 575       'git config --add gitweb.url git://example.com/git/trash.git &&
 576        git config --add gitweb.url http://example.com/git/trash.git &&
 577        gitweb_run "p=.git;a=summary"'
 578
 579cat >.git/cloneurl <<\EOF
 580git://example.com/git/trash.git
 581http://example.com/git/trash.git
 582EOF
 583
 584test_expect_success \
 585       'URL: project URLs via cloneurl file' \
 586       'gitweb_run "p=.git;a=summary"'
 587
 588# ----------------------------------------------------------------------
 589# gitweb config and repo config
 590
 591cat >>gitweb_config.perl <<\EOF
 592
 593# turn on override for each overridable feature
 594foreach my $key (keys %feature) {
 595        if ($feature{$key}{'sub'}) {
 596                $feature{$key}{'override'} = 1;
 597        }
 598}
 599EOF
 600
 601test_expect_success \
 602        'config override: projects list (implicit)' \
 603        'gitweb_run'
 604
 605test_expect_success \
 606        'config override: tree view, features not overridden in repo config' \
 607        'gitweb_run "p=.git;a=tree"'
 608
 609test_expect_success \
 610        'config override: tree view, features disabled in repo config' \
 611        'git config gitweb.blame no &&
 612         git config gitweb.snapshot none &&
 613         git config gitweb.avatar gravatar &&
 614         gitweb_run "p=.git;a=tree"'
 615
 616test_expect_success \
 617        'config override: tree view, features enabled in repo config (1)' \
 618        'git config gitweb.blame yes &&
 619         git config gitweb.snapshot "zip,tgz, tbz2" &&
 620         gitweb_run "p=.git;a=tree"'
 621
 622cat >.git/config <<\EOF
 623# testing noval and alternate separator
 624[gitweb]
 625        blame
 626        snapshot = zip tgz
 627EOF
 628test_expect_success \
 629        'config override: tree view, features enabled in repo config (2)' \
 630        'gitweb_run "p=.git;a=tree"'
 631
 632# ----------------------------------------------------------------------
 633# searching
 634
 635cat >>gitweb_config.perl <<\EOF
 636
 637# enable search
 638$feature{'search'}{'default'} = [1];
 639$feature{'grep'}{'default'} = [1];
 640$feature{'pickaxe'}{'default'} = [1];
 641EOF
 642
 643test_expect_success \
 644        'search: preparation' \
 645        'echo "1st MATCH" >>file &&
 646         echo "2nd MATCH" >>file &&
 647         echo "MATCH" >>bar &&
 648         git add file bar &&
 649         git commit -m "Added MATCH word"'
 650
 651test_expect_success \
 652        'search: commit author' \
 653        'gitweb_run "p=.git;a=search;h=HEAD;st=author;s=A+U+Thor"'
 654
 655test_expect_success \
 656        'search: commit message' \
 657        'gitweb_run "p=.git;a=search;h=HEAD;st=commitr;s=MATCH"'
 658
 659test_expect_success \
 660        'search: grep' \
 661        'gitweb_run "p=.git;a=search;h=HEAD;st=grep;s=MATCH"'
 662
 663test_expect_success \
 664        'search: pickaxe' \
 665        'gitweb_run "p=.git;a=search;h=HEAD;st=pickaxe;s=MATCH"'
 666
 667test_expect_success \
 668        'search: projects' \
 669        'gitweb_run "a=project_list;s=.git"'
 670
 671# ----------------------------------------------------------------------
 672# non-ASCII in README.html
 673
 674test_expect_success \
 675        'README.html with non-ASCII characters (utf-8)' \
 676        'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
 677         cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
 678         gitweb_run "p=.git;a=summary"'
 679
 680# ----------------------------------------------------------------------
 681# syntax highlighting
 682
 683
 684highlight --version >/dev/null 2>&1
 685if [ $? -eq 127 ]; then
 686        say "Skipping syntax highlighting test, because 'highlight' was not found"
 687else
 688        test_set_prereq HIGHLIGHT
 689        cat >>gitweb_config.perl <<-\EOF
 690        our $highlight_bin = "highlight";
 691        $feature{'highlight'}{'override'} = 1;
 692        EOF
 693fi
 694
 695test_expect_success HIGHLIGHT \
 696        'syntax highlighting (no highlight, unknown syntax)' \
 697        'git config gitweb.highlight yes &&
 698         gitweb_run "p=.git;a=blob;f=file"'
 699
 700test_expect_success HIGHLIGHT \
 701        'syntax highlighting (highlighted, shell script)' \
 702        'git config gitweb.highlight yes &&
 703         echo "#!/usr/bin/sh" > test.sh &&
 704         git add test.sh &&
 705         git commit -m "Add test.sh" &&
 706         gitweb_run "p=.git;a=blob;f=test.sh"'
 707
 708# ----------------------------------------------------------------------
 709# forks of projects
 710
 711cat >>gitweb_config.perl <<\EOF &&
 712$feature{'forks'}{'default'} = [1];
 713EOF
 714
 715test_expect_success \
 716        'forks: prepare' \
 717        'git init --bare foo.git &&
 718         git --git-dir=foo.git --work-tree=. add file &&
 719         git --git-dir=foo.git --work-tree=. commit -m "Initial commit" &&
 720         echo "foo" > foo.git/description &&
 721         mkdir -p foo &&
 722         (cd foo &&
 723          git clone --shared --bare ../foo.git foo-forked.git &&
 724          echo "fork of foo" > foo-forked.git/description)'
 725
 726test_expect_success \
 727        'forks: projects list' \
 728        'gitweb_run'
 729
 730test_expect_success \
 731        'forks: forks action' \
 732        'gitweb_run "p=foo.git;a=forks"'
 733
 734# ----------------------------------------------------------------------
 735# content tags (tag cloud)
 736
 737cat >>gitweb_config.perl <<-\EOF &&
 738# we don't test _setting_ content tags, so any true value is good
 739$feature{'ctags'}{'default'} = ['ctags_script.cgi'];
 740EOF
 741
 742test_expect_success \
 743        'ctags: tag cloud in projects list' \
 744        'mkdir .git/ctags &&
 745         echo "2" > .git/ctags/foo &&
 746         echo "1" > .git/ctags/bar &&
 747        gitweb_run'
 748
 749test_expect_success \
 750        'ctags: search projects by existing tag' \
 751        'gitweb_run "by_tag=foo"'
 752
 753test_expect_success \
 754        'ctags: search projects by non existent tag' \
 755        'gitweb_run "by_tag=non-existent"'
 756
 757test_expect_success \
 758        'ctags: malformed tag weights' \
 759        'mkdir -p .git/ctags &&
 760         echo "not-a-number" > .git/ctags/nan &&
 761         echo "not-a-number-2" > .git/ctags/nan2 &&
 762         echo "0.1" >.git/ctags/floating-point &&
 763         gitweb_run'
 764
 765# ----------------------------------------------------------------------
 766# categories
 767
 768test_expect_success \
 769        'categories: projects list, only default category' \
 770        'echo "\$projects_list_group_categories = 1;" >>gitweb_config.perl &&
 771         gitweb_run'
 772
 773# ----------------------------------------------------------------------
 774# unborn branches
 775
 776test_expect_success \
 777        'unborn HEAD: "summary" page (with "heads" subview)' \
 778        'git checkout orphan_branch || git checkout --orphan orphan_branch &&
 779         test_when_finished "git checkout master" &&
 780         gitweb_run "p=.git;a=summary"'
 781
 782test_done