t / t9500-gitweb-standalone-no-errors.shon commit rebase: write a reflog entry when finishing (53f2ffa)
   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# commit, commitdiff: merge, large
 278test_expect_success \
 279        'Create a merge' \
 280        'git checkout b &&
 281         echo "Branch" >> b &&
 282         git add b &&
 283         git commit -a -m "On branch" &&
 284         git checkout master &&
 285         git pull . b'
 286
 287test_expect_success \
 288        'commit(0): merge commit' \
 289        'gitweb_run "p=.git;a=commit"'
 290
 291test_expect_success \
 292        'commitdiff(0): merge commit' \
 293        'gitweb_run "p=.git;a=commitdiff"'
 294
 295test_expect_success \
 296        'Prepare large commit' \
 297        'git checkout b &&
 298         echo "To be changed" > 01-change &&
 299         echo "To be renamed" > 02-pure-rename-from &&
 300         echo "To be deleted" > 03-delete &&
 301         echo "To be renamed and changed" > 04-rename-from &&
 302         echo "To have mode changed" > 05-mode-change &&
 303         echo "File to symlink" > 06-file-or-symlink &&
 304         echo "To be changed and have mode changed" > 07-change-mode-change     &&
 305         git add 0* &&
 306         git commit -a -m "Prepare large commit" &&
 307         echo "Changed" > 01-change &&
 308         git mv 02-pure-rename-from 02-pure-rename-to &&
 309         git rm 03-delete && rm -f 03-delete &&
 310         echo "A new file" > 03-new &&
 311         git add 03-new &&
 312         git mv 04-rename-from 04-rename-to &&
 313         echo "Changed" >> 04-rename-to &&
 314         test_chmod +x 05-mode-change &&
 315         rm -f 06-file-or-symlink &&
 316         if test_have_prereq SYMLINKS; then
 317                ln -s 01-change 06-file-or-symlink
 318         else
 319                printf %s 01-change > 06-file-or-symlink
 320         fi &&
 321         echo "Changed and have mode changed" > 07-change-mode-change   &&
 322         test_chmod +x 07-change-mode-change &&
 323         git commit -a -m "Large commit" &&
 324         git checkout master'
 325
 326test_expect_success \
 327        'commit(1): large commit' \
 328        'gitweb_run "p=.git;a=commit;h=b"'
 329
 330test_expect_success \
 331        'commitdiff(1): large commit' \
 332        'gitweb_run "p=.git;a=commitdiff;h=b"'
 333
 334# ----------------------------------------------------------------------
 335# tags testing
 336
 337test_expect_success \
 338        'tags: list of different types of tags' \
 339        'git checkout master &&
 340         git tag -a -m "Tag commit object" tag-commit HEAD &&
 341         git tag -a -m "" tag-commit-nomessage HEAD &&
 342         git tag -a -m "Tag tag object" tag-tag tag-commit &&
 343         git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
 344         git tag -a -m "Tag blob object" tag-blob HEAD:file &&
 345         git tag lightweight/tag-commit HEAD &&
 346         git tag lightweight/tag-tag tag-commit &&
 347         git tag lightweight/tag-tree HEAD^{tree} &&
 348         git tag lightweight/tag-blob HEAD:file &&
 349         gitweb_run "p=.git;a=tags"'
 350
 351test_expect_success \
 352        'tag: Tag to commit object' \
 353        'gitweb_run "p=.git;a=tag;h=tag-commit"'
 354
 355test_expect_success \
 356        'tag: on lightweight tag (invalid)' \
 357        'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
 358
 359# ----------------------------------------------------------------------
 360# logs
 361
 362test_expect_success \
 363        'logs: log (implicit HEAD)' \
 364        'gitweb_run "p=.git;a=log"'
 365
 366test_expect_success \
 367        'logs: shortlog (implicit HEAD)' \
 368        'gitweb_run "p=.git;a=shortlog"'
 369
 370test_expect_success \
 371        'logs: history (implicit HEAD, file)' \
 372        'gitweb_run "p=.git;a=history;f=file"'
 373
 374test_expect_success \
 375        'logs: history (implicit HEAD, non-existent file)' \
 376        'gitweb_run "p=.git;a=history;f=non-existent"'
 377
 378test_expect_success \
 379        'logs: history (implicit HEAD, deleted file)' \
 380        'git checkout master &&
 381         echo "to be deleted" > deleted_file &&
 382         git add deleted_file &&
 383         git commit -m "Add file to be deleted" &&
 384         git rm deleted_file &&
 385         git commit -m "Delete file" &&
 386         gitweb_run "p=.git;a=history;f=deleted_file"'
 387
 388# ----------------------------------------------------------------------
 389# path_info links
 390test_expect_success \
 391        'path_info: project' \
 392        'gitweb_run "" "/.git"'
 393
 394test_expect_success \
 395        'path_info: project/branch' \
 396        'gitweb_run "" "/.git/b"'
 397
 398test_expect_success \
 399        'path_info: project/branch:file' \
 400        'gitweb_run "" "/.git/master:file"'
 401
 402test_expect_success \
 403        'path_info: project/branch:dir/' \
 404        'gitweb_run "" "/.git/master:foo/"'
 405
 406test_expect_success \
 407        'path_info: project/branch:file (non-existent)' \
 408        'gitweb_run "" "/.git/master:non-existent"'
 409
 410test_expect_success \
 411        'path_info: project/branch:dir/ (non-existent)' \
 412        'gitweb_run "" "/.git/master:non-existent/"'
 413
 414
 415test_expect_success \
 416        'path_info: project/branch:/file' \
 417        'gitweb_run "" "/.git/master:/file"'
 418
 419test_expect_success \
 420        'path_info: project/:/file (implicit HEAD)' \
 421        'gitweb_run "" "/.git/:/file"'
 422
 423test_expect_success \
 424        'path_info: project/:/ (implicit HEAD, top tree)' \
 425        'gitweb_run "" "/.git/:/"'
 426
 427
 428# ----------------------------------------------------------------------
 429# feed generation
 430
 431test_expect_success \
 432        'feeds: OPML' \
 433        'gitweb_run "a=opml"'
 434
 435test_expect_success \
 436        'feed: RSS' \
 437        'gitweb_run "p=.git;a=rss"'
 438
 439test_expect_success \
 440        'feed: Atom' \
 441        'gitweb_run "p=.git;a=atom"'
 442
 443# ----------------------------------------------------------------------
 444# encoding/decoding
 445
 446test_expect_success \
 447        'encode(commit): utf8' \
 448        '. "$TEST_DIRECTORY"/t3901-utf8.txt &&
 449         test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
 450         test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
 451         echo "UTF-8" >> file &&
 452         git add file &&
 453         git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
 454         gitweb_run "p=.git;a=commit"'
 455
 456test_expect_success \
 457        'encode(commit): iso-8859-1' \
 458        '. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
 459         test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
 460         test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
 461         echo "ISO-8859-1" >> file &&
 462         git add file &&
 463         git config i18n.commitencoding ISO-8859-1 &&
 464         test_when_finished "git config --unset i18n.commitencoding" &&
 465         git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
 466         gitweb_run "p=.git;a=commit"'
 467
 468test_expect_success \
 469        'encode(log): utf-8 and iso-8859-1' \
 470        'gitweb_run "p=.git;a=log"'
 471
 472# ----------------------------------------------------------------------
 473# extra options
 474
 475test_expect_success \
 476        'opt: log --no-merges' \
 477        'gitweb_run "p=.git;a=log;opt=--no-merges"'
 478
 479test_expect_success \
 480        'opt: atom --no-merges' \
 481        'gitweb_run "p=.git;a=log;opt=--no-merges"'
 482
 483test_expect_success \
 484        'opt: "file" history --no-merges' \
 485        'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
 486
 487test_expect_success \
 488        'opt: log --no-such-option (invalid option)' \
 489        'gitweb_run "p=.git;a=log;opt=--no-such-option"'
 490
 491test_expect_success \
 492        'opt: tree --no-merges (invalid option for action)' \
 493        'gitweb_run "p=.git;a=tree;opt=--no-merges"'
 494
 495# ----------------------------------------------------------------------
 496# testing config_to_multi / cloneurl
 497
 498test_expect_success \
 499       'URL: no project URLs, no base URL' \
 500       'gitweb_run "p=.git;a=summary"'
 501
 502test_expect_success \
 503       'URL: project URLs via gitweb.url' \
 504       'git config --add gitweb.url git://example.com/git/trash.git &&
 505        git config --add gitweb.url http://example.com/git/trash.git &&
 506        gitweb_run "p=.git;a=summary"'
 507
 508cat >.git/cloneurl <<\EOF
 509git://example.com/git/trash.git
 510http://example.com/git/trash.git
 511EOF
 512
 513test_expect_success \
 514       'URL: project URLs via cloneurl file' \
 515       'gitweb_run "p=.git;a=summary"'
 516
 517# ----------------------------------------------------------------------
 518# gitweb config and repo config
 519
 520cat >>gitweb_config.perl <<\EOF
 521
 522# turn on override for each overridable feature
 523foreach my $key (keys %feature) {
 524        if ($feature{$key}{'sub'}) {
 525                $feature{$key}{'override'} = 1;
 526        }
 527}
 528EOF
 529
 530test_expect_success \
 531        'config override: projects list (implicit)' \
 532        'gitweb_run'
 533
 534test_expect_success \
 535        'config override: tree view, features not overridden in repo config' \
 536        'gitweb_run "p=.git;a=tree"'
 537
 538test_expect_success \
 539        'config override: tree view, features disabled in repo config' \
 540        'git config gitweb.blame no &&
 541         git config gitweb.snapshot none &&
 542         git config gitweb.avatar gravatar &&
 543         gitweb_run "p=.git;a=tree"'
 544
 545test_expect_success \
 546        'config override: tree view, features enabled in repo config (1)' \
 547        'git config gitweb.blame yes &&
 548         git config gitweb.snapshot "zip,tgz, tbz2" &&
 549         gitweb_run "p=.git;a=tree"'
 550
 551cat >.git/config <<\EOF
 552# testing noval and alternate separator
 553[gitweb]
 554        blame
 555        snapshot = zip tgz
 556EOF
 557test_expect_success \
 558        'config override: tree view, features enabled in repo config (2)' \
 559        'gitweb_run "p=.git;a=tree"'
 560
 561# ----------------------------------------------------------------------
 562# non-ASCII in README.html
 563
 564test_expect_success \
 565        'README.html with non-ASCII characters (utf-8)' \
 566        'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
 567         cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
 568         gitweb_run "p=.git;a=summary"'
 569
 570# ----------------------------------------------------------------------
 571# syntax highlighting
 572
 573
 574highlight --version >/dev/null 2>&1
 575if [ $? -eq 127 ]; then
 576        say "Skipping syntax highlighting test, because 'highlight' was not found"
 577else
 578        test_set_prereq HIGHLIGHT
 579        cat >>gitweb_config.perl <<-\EOF
 580        our $highlight_bin = "highlight";
 581        $feature{'highlight'}{'override'} = 1;
 582        EOF
 583fi
 584
 585test_expect_success HIGHLIGHT \
 586        'syntax highlighting (no highlight, unknown syntax)' \
 587        'git config gitweb.highlight yes &&
 588         gitweb_run "p=.git;a=blob;f=file"'
 589
 590test_expect_success HIGHLIGHT \
 591        'syntax highlighting (highlighted, shell script)' \
 592        'git config gitweb.highlight yes &&
 593         echo "#!/usr/bin/sh" > test.sh &&
 594         git add test.sh &&
 595         git commit -m "Add test.sh" &&
 596         gitweb_run "p=.git;a=blob;f=test.sh"'
 597
 598# ----------------------------------------------------------------------
 599# forks of projects
 600
 601cat >>gitweb_config.perl <<\EOF &&
 602$feature{'forks'}{'default'} = [1];
 603EOF
 604
 605test_expect_success \
 606        'forks: prepare' \
 607        'git init --bare foo.git &&
 608         git --git-dir=foo.git --work-tree=. add file &&
 609         git --git-dir=foo.git --work-tree=. commit -m "Initial commit" &&
 610         echo "foo" > foo.git/description &&
 611         mkdir -p foo &&
 612         (cd foo &&
 613          git clone --shared --bare ../foo.git foo-forked.git &&
 614          echo "fork of foo" > foo-forked.git/description)'
 615
 616test_expect_success \
 617        'forks: projects list' \
 618        'gitweb_run'
 619
 620test_expect_success \
 621        'forks: forks action' \
 622        'gitweb_run "p=foo.git;a=forks"'
 623
 624# ----------------------------------------------------------------------
 625# content tags (tag cloud)
 626
 627cat >>gitweb_config.perl <<-\EOF &&
 628# we don't test _setting_ content tags, so any true value is good
 629$feature{'ctags'}{'default'} = ['ctags_script.cgi'];
 630EOF
 631
 632test_expect_success \
 633        'ctags: tag cloud in projects list' \
 634        'mkdir .git/ctags &&
 635         echo "2" > .git/ctags/foo &&
 636         echo "1" > .git/ctags/bar &&
 637        gitweb_run'
 638
 639test_expect_success \
 640        'ctags: search projects by existing tag' \
 641        'gitweb_run "by_tag=foo"'
 642
 643test_expect_success \
 644        'ctags: search projects by non existent tag' \
 645        'gitweb_run "by_tag=non-existent"'
 646
 647# ----------------------------------------------------------------------
 648# categories
 649
 650test_expect_success \
 651        'categories: projects list, only default category' \
 652        'echo "\$projects_list_group_categories = 1;" >>gitweb_config.perl &&
 653         gitweb_run'
 654
 655test_done