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