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