t / t9500-gitweb-standalone-no-errors.shon commit t5520-pull: Add testcases showing spurious conflicts from git pull --rebase (3cee923)
   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'
  21test_debug 'cat gitweb.log'
  22
  23test_expect_success \
  24        'no commits: projects_index' \
  25        'gitweb_run "a=project_index"'
  26test_debug 'cat gitweb.log'
  27
  28test_expect_success \
  29        'no commits: .git summary (implicit)' \
  30        'gitweb_run "p=.git"'
  31test_debug 'cat gitweb.log'
  32
  33test_expect_success \
  34        'no commits: .git commit (implicit HEAD)' \
  35        'gitweb_run "p=.git;a=commit"'
  36test_debug 'cat gitweb.log'
  37
  38test_expect_success \
  39        'no commits: .git commitdiff (implicit HEAD)' \
  40        'gitweb_run "p=.git;a=commitdiff"'
  41test_debug 'cat gitweb.log'
  42
  43test_expect_success \
  44        'no commits: .git tree (implicit HEAD)' \
  45        'gitweb_run "p=.git;a=tree"'
  46test_debug 'cat gitweb.log'
  47
  48test_expect_success \
  49        'no commits: .git heads' \
  50        'gitweb_run "p=.git;a=heads"'
  51test_debug 'cat gitweb.log'
  52
  53test_expect_success \
  54        'no commits: .git tags' \
  55        'gitweb_run "p=.git;a=tags"'
  56test_debug 'cat gitweb.log'
  57
  58
  59# ----------------------------------------------------------------------
  60# initial commit
  61
  62test_expect_success \
  63        'Make initial commit' \
  64        'echo "Not an empty file." > file &&
  65         git add file &&
  66         git commit -a -m "Initial commit." &&
  67         git branch b'
  68
  69test_expect_success \
  70        'projects_list (implicit)' \
  71        'gitweb_run'
  72test_debug 'cat gitweb.log'
  73
  74test_expect_success \
  75        'projects_index' \
  76        'gitweb_run "a=project_index"'
  77test_debug 'cat gitweb.log'
  78
  79test_expect_success \
  80        '.git summary (implicit)' \
  81        'gitweb_run "p=.git"'
  82test_debug 'cat gitweb.log'
  83
  84test_expect_success \
  85        '.git commit (implicit HEAD)' \
  86        'gitweb_run "p=.git;a=commit"'
  87test_debug 'cat gitweb.log'
  88
  89test_expect_success \
  90        '.git commitdiff (implicit HEAD, root commit)' \
  91        'gitweb_run "p=.git;a=commitdiff"'
  92test_debug 'cat gitweb.log'
  93
  94test_expect_success \
  95        '.git commitdiff_plain (implicit HEAD, root commit)' \
  96        'gitweb_run "p=.git;a=commitdiff_plain"'
  97test_debug 'cat gitweb.log'
  98
  99test_expect_success \
 100        '.git commit (HEAD)' \
 101        'gitweb_run "p=.git;a=commit;h=HEAD"'
 102test_debug 'cat gitweb.log'
 103
 104test_expect_success \
 105        '.git tree (implicit HEAD)' \
 106        'gitweb_run "p=.git;a=tree"'
 107test_debug 'cat gitweb.log'
 108
 109test_expect_success \
 110        '.git blob (file)' \
 111        'gitweb_run "p=.git;a=blob;f=file"'
 112test_debug 'cat gitweb.log'
 113
 114test_expect_success \
 115        '.git blob_plain (file)' \
 116        'gitweb_run "p=.git;a=blob_plain;f=file"'
 117test_debug 'cat gitweb.log'
 118
 119# ----------------------------------------------------------------------
 120# nonexistent objects
 121
 122test_expect_success \
 123        '.git commit (non-existent)' \
 124        'gitweb_run "p=.git;a=commit;h=non-existent"'
 125test_debug 'cat gitweb.log'
 126
 127test_expect_success \
 128        '.git commitdiff (non-existent)' \
 129        'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
 130test_debug 'cat gitweb.log'
 131
 132test_expect_success \
 133        '.git commitdiff (non-existent vs HEAD)' \
 134        'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
 135test_debug 'cat gitweb.log'
 136
 137test_expect_success \
 138        '.git tree (0000000000000000000000000000000000000000)' \
 139        'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
 140test_debug 'cat gitweb.log'
 141
 142test_expect_success \
 143        '.git tag (0000000000000000000000000000000000000000)' \
 144        'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
 145test_debug 'cat gitweb.log'
 146
 147test_expect_success \
 148        '.git blob (non-existent)' \
 149        'gitweb_run "p=.git;a=blob;f=non-existent"'
 150test_debug 'cat gitweb.log'
 151
 152test_expect_success \
 153        '.git blob_plain (non-existent)' \
 154        'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
 155test_debug 'cat gitweb.log'
 156
 157
 158# ----------------------------------------------------------------------
 159# commitdiff testing (implicit, one implicit tree-ish)
 160
 161test_expect_success \
 162        'commitdiff(0): root' \
 163        'gitweb_run "p=.git;a=commitdiff"'
 164test_debug 'cat gitweb.log'
 165
 166test_expect_success \
 167        'commitdiff(0): file added' \
 168        'echo "New file" > new_file &&
 169         git add new_file &&
 170         git commit -a -m "File added." &&
 171         gitweb_run "p=.git;a=commitdiff"'
 172test_debug 'cat gitweb.log'
 173
 174test_expect_success \
 175        'commitdiff(0): mode change' \
 176        'test_chmod +x new_file &&
 177         git commit -a -m "Mode changed." &&
 178         gitweb_run "p=.git;a=commitdiff"'
 179test_debug 'cat gitweb.log'
 180
 181test_expect_success \
 182        'commitdiff(0): file renamed' \
 183        'git mv new_file renamed_file &&
 184         git commit -a -m "File renamed." &&
 185         gitweb_run "p=.git;a=commitdiff"'
 186test_debug 'cat gitweb.log'
 187
 188test_expect_success SYMLINKS \
 189        'commitdiff(0): file to symlink' \
 190        'rm renamed_file &&
 191         ln -s file renamed_file &&
 192         git commit -a -m "File to symlink." &&
 193         gitweb_run "p=.git;a=commitdiff"'
 194test_debug 'cat gitweb.log'
 195
 196test_expect_success \
 197        'commitdiff(0): file deleted' \
 198        'git rm renamed_file &&
 199         rm -f renamed_file &&
 200         git commit -a -m "File removed." &&
 201         gitweb_run "p=.git;a=commitdiff"'
 202test_debug 'cat gitweb.log'
 203
 204test_expect_success \
 205        'commitdiff(0): file copied / new file' \
 206        'cp file file2 &&
 207         git add file2 &&
 208         git commit -a -m "File copied." &&
 209         gitweb_run "p=.git;a=commitdiff"'
 210test_debug 'cat gitweb.log'
 211
 212test_expect_success \
 213        'commitdiff(0): mode change and modified' \
 214        'echo "New line" >> file2 &&
 215         test_chmod +x file2 &&
 216         git commit -a -m "Mode change and modification." &&
 217         gitweb_run "p=.git;a=commitdiff"'
 218test_debug 'cat gitweb.log'
 219
 220test_expect_success \
 221        'commitdiff(0): renamed and modified' \
 222        'cat >file2<<EOF &&
 223Dominus regit me,
 224et nihil mihi deerit.
 225In loco pascuae ibi me collocavit,
 226super aquam refectionis educavit me;
 227animam meam convertit,
 228deduxit me super semitas jusitiae,
 229propter nomen suum.
 230EOF
 231         git commit -a -m "File added." &&
 232         git mv file2 file3 &&
 233         echo "Propter nomen suum." >> file3 &&
 234         git commit -a -m "File rename and modification." &&
 235         gitweb_run "p=.git;a=commitdiff"'
 236test_debug 'cat gitweb.log'
 237
 238test_expect_success \
 239        'commitdiff(0): renamed, mode change and modified' \
 240        'git mv file3 file2 &&
 241         echo "Propter nomen suum." >> file2 &&
 242         test_chmod +x file2 &&
 243         git commit -a -m "File rename, mode change and modification." &&
 244         gitweb_run "p=.git;a=commitdiff"'
 245test_debug 'cat gitweb.log'
 246
 247# ----------------------------------------------------------------------
 248# commitdiff testing (taken from t4114-apply-typechange.sh)
 249
 250test_expect_success SYMLINKS 'setup typechange commits' '
 251        echo "hello world" > foo &&
 252        echo "hi planet" > bar &&
 253        git update-index --add foo bar &&
 254        git commit -m initial &&
 255        git branch initial &&
 256        rm -f foo &&
 257        ln -s bar foo &&
 258        git update-index foo &&
 259        git commit -m "foo symlinked to bar" &&
 260        git branch foo-symlinked-to-bar &&
 261        rm -f foo &&
 262        echo "how far is the sun?" > foo &&
 263        git update-index foo &&
 264        git commit -m "foo back to file" &&
 265        git branch foo-back-to-file &&
 266        rm -f foo &&
 267        git update-index --remove foo &&
 268        mkdir foo &&
 269        echo "if only I knew" > foo/baz &&
 270        git update-index --add foo/baz &&
 271        git commit -m "foo becomes a directory" &&
 272        git branch "foo-becomes-a-directory" &&
 273        echo "hello world" > foo/baz &&
 274        git update-index foo/baz &&
 275        git commit -m "foo/baz is the original foo" &&
 276        git branch foo-baz-renamed-from-foo
 277        '
 278
 279test_expect_success \
 280        'commitdiff(2): file renamed from foo to foo/baz' \
 281        'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
 282test_debug 'cat gitweb.log'
 283
 284test_expect_success \
 285        'commitdiff(2): file renamed from foo/baz to foo' \
 286        'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
 287test_debug 'cat gitweb.log'
 288
 289test_expect_success \
 290        'commitdiff(2): directory becomes file' \
 291        'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
 292test_debug 'cat gitweb.log'
 293
 294test_expect_success \
 295        'commitdiff(2): file becomes directory' \
 296        'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
 297test_debug 'cat gitweb.log'
 298
 299test_expect_success \
 300        'commitdiff(2): file becomes symlink' \
 301        'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
 302test_debug 'cat gitweb.log'
 303
 304test_expect_success \
 305        'commitdiff(2): symlink becomes file' \
 306        'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
 307test_debug 'cat gitweb.log'
 308
 309test_expect_success \
 310        'commitdiff(2): symlink becomes directory' \
 311        'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
 312test_debug 'cat gitweb.log'
 313
 314test_expect_success \
 315        'commitdiff(2): directory becomes symlink' \
 316        'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
 317test_debug 'cat gitweb.log'
 318
 319# ----------------------------------------------------------------------
 320# commit, commitdiff: merge, large
 321test_expect_success \
 322        'Create a merge' \
 323        'git checkout b &&
 324         echo "Branch" >> b &&
 325         git add b &&
 326         git commit -a -m "On branch" &&
 327         git checkout master &&
 328         git pull . b'
 329
 330test_expect_success \
 331        'commit(0): merge commit' \
 332        'gitweb_run "p=.git;a=commit"'
 333test_debug 'cat gitweb.log'
 334
 335test_expect_success \
 336        'commitdiff(0): merge commit' \
 337        'gitweb_run "p=.git;a=commitdiff"'
 338test_debug 'cat gitweb.log'
 339
 340test_expect_success \
 341        'Prepare large commit' \
 342        'git checkout b &&
 343         echo "To be changed" > 01-change &&
 344         echo "To be renamed" > 02-pure-rename-from &&
 345         echo "To be deleted" > 03-delete &&
 346         echo "To be renamed and changed" > 04-rename-from &&
 347         echo "To have mode changed" > 05-mode-change &&
 348         echo "File to symlink" > 06-file-or-symlink &&
 349         echo "To be changed and have mode changed" > 07-change-mode-change     &&
 350         git add 0* &&
 351         git commit -a -m "Prepare large commit" &&
 352         echo "Changed" > 01-change &&
 353         git mv 02-pure-rename-from 02-pure-rename-to &&
 354         git rm 03-delete && rm -f 03-delete &&
 355         echo "A new file" > 03-new &&
 356         git add 03-new &&
 357         git mv 04-rename-from 04-rename-to &&
 358         echo "Changed" >> 04-rename-to &&
 359         test_chmod +x 05-mode-change &&
 360         rm -f 06-file-or-symlink &&
 361         if test_have_prereq SYMLINKS; then
 362                ln -s 01-change 06-file-or-symlink
 363         else
 364                printf %s 01-change > 06-file-or-symlink
 365         fi &&
 366         echo "Changed and have mode changed" > 07-change-mode-change   &&
 367         test_chmod +x 07-change-mode-change &&
 368         git commit -a -m "Large commit" &&
 369         git checkout master'
 370
 371test_expect_success \
 372        'commit(1): large commit' \
 373        'gitweb_run "p=.git;a=commit;h=b"'
 374test_debug 'cat gitweb.log'
 375
 376test_expect_success \
 377        'commitdiff(1): large commit' \
 378        'gitweb_run "p=.git;a=commitdiff;h=b"'
 379test_debug 'cat gitweb.log'
 380
 381# ----------------------------------------------------------------------
 382# tags testing
 383
 384test_expect_success \
 385        'tags: list of different types of tags' \
 386        'git checkout master &&
 387         git tag -a -m "Tag commit object" tag-commit HEAD &&
 388         git tag -a -m "" tag-commit-nomessage HEAD &&
 389         git tag -a -m "Tag tag object" tag-tag tag-commit &&
 390         git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
 391         git tag -a -m "Tag blob object" tag-blob HEAD:file &&
 392         git tag lightweight/tag-commit HEAD &&
 393         git tag lightweight/tag-tag tag-commit &&
 394         git tag lightweight/tag-tree HEAD^{tree} &&
 395         git tag lightweight/tag-blob HEAD:file &&
 396         gitweb_run "p=.git;a=tags"'
 397test_debug 'cat gitweb.log'
 398
 399test_expect_success \
 400        'tag: Tag to commit object' \
 401        'gitweb_run "p=.git;a=tag;h=tag-commit"'
 402test_debug 'cat gitweb.log'
 403
 404test_expect_success \
 405        'tag: on lightweight tag (invalid)' \
 406        'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
 407test_debug 'cat gitweb.log'
 408
 409# ----------------------------------------------------------------------
 410# logs
 411
 412test_expect_success \
 413        'logs: log (implicit HEAD)' \
 414        'gitweb_run "p=.git;a=log"'
 415test_debug 'cat gitweb.log'
 416
 417test_expect_success \
 418        'logs: shortlog (implicit HEAD)' \
 419        'gitweb_run "p=.git;a=shortlog"'
 420test_debug 'cat gitweb.log'
 421
 422test_expect_success \
 423        'logs: history (implicit HEAD, file)' \
 424        'gitweb_run "p=.git;a=history;f=file"'
 425test_debug 'cat gitweb.log'
 426
 427test_expect_success \
 428        'logs: history (implicit HEAD, non-existent file)' \
 429        'gitweb_run "p=.git;a=history;f=non-existent"'
 430test_debug 'cat gitweb.log'
 431
 432test_expect_success \
 433        'logs: history (implicit HEAD, deleted file)' \
 434        'git checkout master &&
 435         echo "to be deleted" > deleted_file &&
 436         git add deleted_file &&
 437         git commit -m "Add file to be deleted" &&
 438         git rm deleted_file &&
 439         git commit -m "Delete file" &&
 440         gitweb_run "p=.git;a=history;f=deleted_file"'
 441test_debug 'cat gitweb.log'
 442
 443# ----------------------------------------------------------------------
 444# path_info links
 445test_expect_success \
 446        'path_info: project' \
 447        'gitweb_run "" "/.git"'
 448test_debug 'cat gitweb.log'
 449
 450test_expect_success \
 451        'path_info: project/branch' \
 452        'gitweb_run "" "/.git/b"'
 453test_debug 'cat gitweb.log'
 454
 455test_expect_success \
 456        'path_info: project/branch:file' \
 457        'gitweb_run "" "/.git/master:file"'
 458test_debug 'cat gitweb.log'
 459
 460test_expect_success \
 461        'path_info: project/branch:dir/' \
 462        'gitweb_run "" "/.git/master:foo/"'
 463test_debug 'cat gitweb.log'
 464
 465test_expect_success \
 466        'path_info: project/branch:file (non-existent)' \
 467        'gitweb_run "" "/.git/master:non-existent"'
 468test_debug 'cat gitweb.log'
 469
 470test_expect_success \
 471        'path_info: project/branch:dir/ (non-existent)' \
 472        'gitweb_run "" "/.git/master:non-existent/"'
 473test_debug 'cat gitweb.log'
 474
 475
 476test_expect_success \
 477        'path_info: project/branch:/file' \
 478        'gitweb_run "" "/.git/master:/file"'
 479test_debug 'cat gitweb.log'
 480
 481test_expect_success \
 482        'path_info: project/:/file (implicit HEAD)' \
 483        'gitweb_run "" "/.git/:/file"'
 484test_debug 'cat gitweb.log'
 485
 486test_expect_success \
 487        'path_info: project/:/ (implicit HEAD, top tree)' \
 488        'gitweb_run "" "/.git/:/"'
 489test_debug 'cat gitweb.log'
 490
 491
 492# ----------------------------------------------------------------------
 493# feed generation
 494
 495test_expect_success \
 496        'feeds: OPML' \
 497        'gitweb_run "a=opml"'
 498test_debug 'cat gitweb.log'
 499
 500test_expect_success \
 501        'feed: RSS' \
 502        'gitweb_run "p=.git;a=rss"'
 503test_debug 'cat gitweb.log'
 504
 505test_expect_success \
 506        'feed: Atom' \
 507        'gitweb_run "p=.git;a=atom"'
 508test_debug 'cat gitweb.log'
 509
 510# ----------------------------------------------------------------------
 511# encoding/decoding
 512
 513test_expect_success \
 514        'encode(commit): utf8' \
 515        '. "$TEST_DIRECTORY"/t3901-utf8.txt &&
 516         echo "UTF-8" >> file &&
 517         git add file &&
 518         git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
 519         gitweb_run "p=.git;a=commit"'
 520test_debug 'cat gitweb.log'
 521
 522test_expect_success \
 523        'encode(commit): iso-8859-1' \
 524        '. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
 525         echo "ISO-8859-1" >> file &&
 526         git add file &&
 527         git config i18n.commitencoding ISO-8859-1 &&
 528         git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
 529         git config --unset i18n.commitencoding &&
 530         gitweb_run "p=.git;a=commit"'
 531test_debug 'cat gitweb.log'
 532
 533test_expect_success \
 534        'encode(log): utf-8 and iso-8859-1' \
 535        'gitweb_run "p=.git;a=log"'
 536test_debug 'cat gitweb.log'
 537
 538# ----------------------------------------------------------------------
 539# extra options
 540
 541test_expect_success \
 542        'opt: log --no-merges' \
 543        'gitweb_run "p=.git;a=log;opt=--no-merges"'
 544test_debug 'cat gitweb.log'
 545
 546test_expect_success \
 547        'opt: atom --no-merges' \
 548        'gitweb_run "p=.git;a=log;opt=--no-merges"'
 549test_debug 'cat gitweb.log'
 550
 551test_expect_success \
 552        'opt: "file" history --no-merges' \
 553        'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
 554test_debug 'cat gitweb.log'
 555
 556test_expect_success \
 557        'opt: log --no-such-option (invalid option)' \
 558        'gitweb_run "p=.git;a=log;opt=--no-such-option"'
 559test_debug 'cat gitweb.log'
 560
 561test_expect_success \
 562        'opt: tree --no-merges (invalid option for action)' \
 563        'gitweb_run "p=.git;a=tree;opt=--no-merges"'
 564test_debug 'cat gitweb.log'
 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"'
 572test_debug 'cat gitweb.log'
 573
 574test_expect_success \
 575       'URL: project URLs via gitweb.url' \
 576       'git config --add gitweb.url git://example.com/git/trash.git &&
 577        git config --add gitweb.url http://example.com/git/trash.git &&
 578        gitweb_run "p=.git;a=summary"'
 579test_debug 'cat gitweb.log'
 580
 581cat >.git/cloneurl <<\EOF
 582git://example.com/git/trash.git
 583http://example.com/git/trash.git
 584EOF
 585
 586test_expect_success \
 587       'URL: project URLs via cloneurl file' \
 588       'gitweb_run "p=.git;a=summary"'
 589test_debug 'cat gitweb.log'
 590
 591# ----------------------------------------------------------------------
 592# gitweb config and repo config
 593
 594cat >>gitweb_config.perl <<EOF
 595
 596\$feature{'blame'}{'override'} = 1;
 597\$feature{'snapshot'}{'override'} = 1;
 598\$feature{'avatar'}{'override'} = 1;
 599EOF
 600
 601test_expect_success \
 602        'config override: tree view, features not overridden in repo config' \
 603        'gitweb_run "p=.git;a=tree"'
 604test_debug 'cat gitweb.log'
 605
 606test_expect_success \
 607        'config override: tree view, features disabled in repo config' \
 608        'git config gitweb.blame no &&
 609         git config gitweb.snapshot none &&
 610         git config gitweb.avatar gravatar &&
 611         gitweb_run "p=.git;a=tree"'
 612test_debug 'cat gitweb.log'
 613
 614test_expect_success \
 615        'config override: tree view, features enabled in repo config (1)' \
 616        'git config gitweb.blame yes &&
 617         git config gitweb.snapshot "zip,tgz, tbz2" &&
 618         gitweb_run "p=.git;a=tree"'
 619test_debug 'cat gitweb.log'
 620
 621cat >.git/config <<\EOF
 622# testing noval and alternate separator
 623[gitweb]
 624        blame
 625        snapshot = zip tgz
 626EOF
 627test_expect_success \
 628        'config override: tree view, features enabled in repo config (2)' \
 629        'gitweb_run "p=.git;a=tree"'
 630test_debug 'cat gitweb.log'
 631
 632# ----------------------------------------------------------------------
 633# non-ASCII in README.html
 634
 635test_expect_success \
 636        'README.html with non-ASCII characters (utf-8)' \
 637        'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
 638         cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
 639         gitweb_run "p=.git;a=summary"'
 640test_debug 'cat gitweb.log'
 641
 642test_done