2007-05-19 00:19:20 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Jakub Narebski
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='gitweb as standalone script (basic tests).
|
|
|
|
|
|
|
|
This test runs gitweb (git web interface) as CGI script from
|
|
|
|
commandline, and checks that it would not write any errors
|
|
|
|
or warnings to log.'
|
|
|
|
|
|
|
|
|
2020-11-18 23:44:43 +00:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-18 23:44:19 +00:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2021-02-09 21:41:53 +00:00
|
|
|
. ./lib-gitweb.sh
|
2007-05-19 00:19:20 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# no commits (empty, just initialized repository)
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: projects_list (implicit)' \
|
|
|
|
'gitweb_run'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: projects_index' \
|
|
|
|
'gitweb_run "a=project_index"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: .git summary (implicit)' \
|
|
|
|
'gitweb_run "p=.git"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: .git commit (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=commit"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: .git commitdiff (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: .git tree (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=tree"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: .git heads' \
|
|
|
|
'gitweb_run "p=.git;a=heads"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'no commits: .git tags' \
|
|
|
|
'gitweb_run "p=.git;a=tags"'
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# initial commit
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'Make initial commit' \
|
2020-03-22 21:14:21 +00:00
|
|
|
'echo "Not an empty file." >file &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git add file &&
|
|
|
|
git commit -a -m "Initial commit." &&
|
|
|
|
git branch b'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'projects_list (implicit)' \
|
|
|
|
'gitweb_run'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'projects_index' \
|
|
|
|
'gitweb_run "a=project_index"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git summary (implicit)' \
|
|
|
|
'gitweb_run "p=.git"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commit (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=commit"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commitdiff (implicit HEAD, root commit)' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commitdiff_plain (implicit HEAD, root commit)' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff_plain"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commit (HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=commit;h=HEAD"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git tree (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=tree"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git blob (file)' \
|
|
|
|
'gitweb_run "p=.git;a=blob;f=file"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git blob_plain (file)' \
|
|
|
|
'gitweb_run "p=.git;a=blob_plain;f=file"'
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# nonexistent objects
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commit (non-existent)' \
|
|
|
|
'gitweb_run "p=.git;a=commit;h=non-existent"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commitdiff (non-existent)' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git commitdiff (non-existent vs HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git tree (0000000000000000000000000000000000000000)' \
|
|
|
|
'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git tag (0000000000000000000000000000000000000000)' \
|
|
|
|
'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git blob (non-existent)' \
|
|
|
|
'gitweb_run "p=.git;a=blob;f=non-existent"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'.git blob_plain (non-existent)' \
|
|
|
|
'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# commitdiff testing (implicit, one implicit tree-ish)
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): root' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): file added' \
|
2020-03-22 21:14:21 +00:00
|
|
|
'echo "New file" >new_file &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git add new_file &&
|
|
|
|
git commit -a -m "File added." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): mode change' \
|
2009-02-28 20:12:57 +00:00
|
|
|
'test_chmod +x new_file &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -a -m "Mode changed." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): file renamed' \
|
|
|
|
'git mv new_file renamed_file &&
|
|
|
|
git commit -a -m "File renamed." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
2013-06-07 20:53:28 +00:00
|
|
|
test_expect_success \
|
2007-05-19 00:19:20 +00:00
|
|
|
'commitdiff(0): file to symlink' \
|
|
|
|
'rm renamed_file &&
|
2013-06-07 20:53:28 +00:00
|
|
|
test_ln_s_add file renamed_file &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -a -m "File to symlink." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): file deleted' \
|
|
|
|
'git rm renamed_file &&
|
|
|
|
rm -f renamed_file &&
|
|
|
|
git commit -a -m "File removed." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): file copied / new file' \
|
|
|
|
'cp file file2 &&
|
|
|
|
git add file2 &&
|
|
|
|
git commit -a -m "File copied." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): mode change and modified' \
|
2020-03-22 21:14:21 +00:00
|
|
|
'echo "New line" >>file2 &&
|
2009-02-28 20:12:57 +00:00
|
|
|
test_chmod +x file2 &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -a -m "Mode change and modification." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): renamed and modified' \
|
|
|
|
'cat >file2<<EOF &&
|
|
|
|
Dominus regit me,
|
|
|
|
et nihil mihi deerit.
|
|
|
|
In loco pascuae ibi me collocavit,
|
|
|
|
super aquam refectionis educavit me;
|
|
|
|
animam meam convertit,
|
|
|
|
deduxit me super semitas jusitiae,
|
|
|
|
propter nomen suum.
|
|
|
|
EOF
|
|
|
|
git commit -a -m "File added." &&
|
|
|
|
git mv file2 file3 &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "Propter nomen suum." >>file3 &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -a -m "File rename and modification." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): renamed, mode change and modified' \
|
|
|
|
'git mv file3 file2 &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "Propter nomen suum." >>file2 &&
|
2009-02-28 20:12:57 +00:00
|
|
|
test_chmod +x file2 &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -a -m "File rename, mode change and modification." &&
|
|
|
|
gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# commitdiff testing (taken from t4114-apply-typechange.sh)
|
|
|
|
|
2013-06-07 20:53:28 +00:00
|
|
|
test_expect_success 'setup typechange commits' '
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "hello world" >foo &&
|
|
|
|
echo "hi planet" >bar &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git update-index --add foo bar &&
|
|
|
|
git commit -m initial &&
|
|
|
|
git branch initial &&
|
|
|
|
rm -f foo &&
|
2013-06-07 20:53:28 +00:00
|
|
|
test_ln_s_add bar foo &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -m "foo symlinked to bar" &&
|
|
|
|
git branch foo-symlinked-to-bar &&
|
|
|
|
rm -f foo &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "how far is the sun?" >foo &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git update-index foo &&
|
|
|
|
git commit -m "foo back to file" &&
|
|
|
|
git branch foo-back-to-file &&
|
|
|
|
rm -f foo &&
|
|
|
|
git update-index --remove foo &&
|
|
|
|
mkdir foo &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "if only I knew" >foo/baz &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git update-index --add foo/baz &&
|
|
|
|
git commit -m "foo becomes a directory" &&
|
|
|
|
git branch "foo-becomes-a-directory" &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "hello world" >foo/baz &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git update-index foo/baz &&
|
|
|
|
git commit -m "foo/baz is the original foo" &&
|
|
|
|
git branch foo-baz-renamed-from-foo
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): file renamed from foo to foo/baz' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): file renamed from foo/baz to foo' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): directory becomes file' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): file becomes directory' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): file becomes symlink' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): symlink becomes file' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): symlink becomes directory' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(2): directory becomes symlink' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
|
|
|
|
|
2011-10-30 23:36:24 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# commitdiff testing (incomplete lines)
|
|
|
|
|
|
|
|
test_expect_success 'setup incomplete lines' '
|
|
|
|
cat >file<<-\EOF &&
|
|
|
|
Dominus regit me,
|
|
|
|
et nihil mihi deerit.
|
|
|
|
In loco pascuae ibi me collocavit,
|
|
|
|
super aquam refectionis educavit me;
|
|
|
|
animam meam convertit,
|
|
|
|
deduxit me super semitas jusitiae,
|
|
|
|
propter nomen suum.
|
|
|
|
CHANGE_ME
|
|
|
|
EOF
|
|
|
|
git commit -a -m "Preparing for incomplete lines" &&
|
|
|
|
echo "incomplete" | tr -d "\\012" >>file &&
|
|
|
|
git commit -a -m "Add incomplete line" &&
|
|
|
|
git tag incomplete_lines_add &&
|
|
|
|
sed -e s/CHANGE_ME/change_me/ <file >file+ &&
|
|
|
|
mv -f file+ file &&
|
|
|
|
git commit -a -m "Incomplete context line" &&
|
|
|
|
git tag incomplete_lines_ctx &&
|
|
|
|
echo "Dominus regit me," >file &&
|
|
|
|
echo "incomplete line" | tr -d "\\012" >>file &&
|
|
|
|
git commit -a -m "Change incomplete line" &&
|
2015-03-20 10:07:15 +00:00
|
|
|
git tag incomplete_lines_chg &&
|
2011-10-30 23:36:24 +00:00
|
|
|
echo "Dominus regit me," >file &&
|
|
|
|
git commit -a -m "Remove incomplete line" &&
|
|
|
|
git tag incomplete_lines_rem
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commitdiff(1): addition of incomplete line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_add"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commitdiff(1): incomplete line as context line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_ctx"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commitdiff(1): change incomplete line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_chg"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commitdiff(1): removal of incomplete line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_rem"
|
|
|
|
'
|
|
|
|
|
2007-05-19 00:19:20 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# commit, commitdiff: merge, large
|
|
|
|
test_expect_success \
|
|
|
|
'Create a merge' \
|
|
|
|
'git checkout b &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "Branch" >>b &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git add b &&
|
|
|
|
git commit -a -m "On branch" &&
|
2020-11-18 23:44:43 +00:00
|
|
|
git checkout main &&
|
2013-10-31 09:25:33 +00:00
|
|
|
git merge b &&
|
2011-10-30 23:36:25 +00:00
|
|
|
git tag merge_commit'
|
2007-05-19 00:19:20 +00:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commit(0): merge commit' \
|
|
|
|
'gitweb_run "p=.git;a=commit"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(0): merge commit' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'Prepare large commit' \
|
|
|
|
'git checkout b &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "To be changed" >01-change &&
|
|
|
|
echo "To be renamed" >02-pure-rename-from &&
|
|
|
|
echo "To be deleted" >03-delete &&
|
|
|
|
echo "To be renamed and changed" >04-rename-from &&
|
|
|
|
echo "To have mode changed" >05-mode-change &&
|
|
|
|
echo "File to symlink" >06-file-or-symlink &&
|
2020-03-22 21:14:22 +00:00
|
|
|
echo "To be changed and have mode changed" >07-change-mode-change &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git add 0* &&
|
|
|
|
git commit -a -m "Prepare large commit" &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "Changed" >01-change &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git mv 02-pure-rename-from 02-pure-rename-to &&
|
|
|
|
git rm 03-delete && rm -f 03-delete &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "A new file" >03-new &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git add 03-new &&
|
|
|
|
git mv 04-rename-from 04-rename-to &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "Changed" >>04-rename-to &&
|
2009-02-28 20:12:57 +00:00
|
|
|
test_chmod +x 05-mode-change &&
|
2009-03-04 21:38:24 +00:00
|
|
|
rm -f 06-file-or-symlink &&
|
2013-06-07 20:53:28 +00:00
|
|
|
test_ln_s_add 01-change 06-file-or-symlink &&
|
2020-03-22 21:14:22 +00:00
|
|
|
echo "Changed and have mode changed" >07-change-mode-change &&
|
2009-02-28 20:12:57 +00:00
|
|
|
test_chmod +x 07-change-mode-change &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git commit -a -m "Large commit" &&
|
2020-11-18 23:44:43 +00:00
|
|
|
git checkout main'
|
2007-05-19 00:19:20 +00:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commit(1): large commit' \
|
|
|
|
'gitweb_run "p=.git;a=commit;h=b"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'commitdiff(1): large commit' \
|
|
|
|
'gitweb_run "p=.git;a=commitdiff;h=b"'
|
|
|
|
|
2011-10-30 23:36:25 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# side-by-side diff
|
|
|
|
|
|
|
|
test_expect_success 'side-by-side: addition of incomplete line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_add;ds=sidebyside"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'side-by-side: incomplete line as context line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_ctx;ds=sidebyside"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'side-by-side: changed incomplete line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_chg;ds=sidebyside"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'side-by-side: removal of incomplete line' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=incomplete_lines_rem;ds=sidebyside"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'side-by-side: merge commit' '
|
|
|
|
gitweb_run "p=.git;a=commitdiff;h=merge_commit;ds=sidebyside"
|
|
|
|
'
|
|
|
|
|
2007-05-19 00:19:20 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# tags testing
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'tags: list of different types of tags' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'git checkout main &&
|
2007-05-19 00:19:20 +00:00
|
|
|
git tag -a -m "Tag commit object" tag-commit HEAD &&
|
|
|
|
git tag -a -m "" tag-commit-nomessage HEAD &&
|
|
|
|
git tag -a -m "Tag tag object" tag-tag tag-commit &&
|
|
|
|
git tag -a -m "Tag tree object" tag-tree HEAD^{tree} &&
|
|
|
|
git tag -a -m "Tag blob object" tag-blob HEAD:file &&
|
|
|
|
git tag lightweight/tag-commit HEAD &&
|
|
|
|
git tag lightweight/tag-tag tag-commit &&
|
|
|
|
git tag lightweight/tag-tree HEAD^{tree} &&
|
|
|
|
git tag lightweight/tag-blob HEAD:file &&
|
|
|
|
gitweb_run "p=.git;a=tags"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'tag: Tag to commit object' \
|
|
|
|
'gitweb_run "p=.git;a=tag;h=tag-commit"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'tag: on lightweight tag (invalid)' \
|
|
|
|
'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# logs
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'logs: log (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=log"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'logs: shortlog (implicit HEAD)' \
|
|
|
|
'gitweb_run "p=.git;a=shortlog"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'logs: history (implicit HEAD, file)' \
|
|
|
|
'gitweb_run "p=.git;a=history;f=file"'
|
|
|
|
|
gitweb: Fix 'history' view for deleted files with history
When asked for history of a file which is not present in given branch
("HEAD", i.e. current branch, or given by transient $hash_hase ('hb')
parameter), but is present deeper in the history (meaning that "git
rev-list --full-history $hash_base -- $file_name" is not empty), and
there is no $hash ('h') parameter set for a file, gitweb would spew
multiple of "Use of uninitialized value" warnings, and some links
would be missing. This commit fixes this bug.
This bug occurs in the rare cases when "git log -- <path>" is empty
and "git log --full-history -- <path>" is not, or to be more exact in
the cases when full-history starts later than given branch. It can
happen if you are using handcrafted gitwb URL, or if you follow
generic 'history' link or bookmark for a file which got deleted.
Gitweb tried to get file type ('tree', or 'blob', or even 'commit')
from the commit we start searching from (where the file was not
present), and not among found commits. This was the cause of "Use of
uninitialized value" warnings.
This commit also add tests for such situation to t9500 test.
While we are it, return HTTP error if there is _no_ history; it means
that file or directory was not found (for given branch). Also error
out if type of item could not be found: it should not happen now, but
better be sure.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-13 12:12:15 +00:00
|
|
|
test_expect_success \
|
|
|
|
'logs: history (implicit HEAD, non-existent file)' \
|
|
|
|
'gitweb_run "p=.git;a=history;f=non-existent"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'logs: history (implicit HEAD, deleted file)' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'git checkout main &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "to be deleted" >deleted_file &&
|
gitweb: Fix 'history' view for deleted files with history
When asked for history of a file which is not present in given branch
("HEAD", i.e. current branch, or given by transient $hash_hase ('hb')
parameter), but is present deeper in the history (meaning that "git
rev-list --full-history $hash_base -- $file_name" is not empty), and
there is no $hash ('h') parameter set for a file, gitweb would spew
multiple of "Use of uninitialized value" warnings, and some links
would be missing. This commit fixes this bug.
This bug occurs in the rare cases when "git log -- <path>" is empty
and "git log --full-history -- <path>" is not, or to be more exact in
the cases when full-history starts later than given branch. It can
happen if you are using handcrafted gitwb URL, or if you follow
generic 'history' link or bookmark for a file which got deleted.
Gitweb tried to get file type ('tree', or 'blob', or even 'commit')
from the commit we start searching from (where the file was not
present), and not among found commits. This was the cause of "Use of
uninitialized value" warnings.
This commit also add tests for such situation to t9500 test.
While we are it, return HTTP error if there is _no_ history; it means
that file or directory was not found (for given branch). Also error
out if type of item could not be found: it should not happen now, but
better be sure.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-13 12:12:15 +00:00
|
|
|
git add deleted_file &&
|
|
|
|
git commit -m "Add file to be deleted" &&
|
|
|
|
git rm deleted_file &&
|
|
|
|
git commit -m "Delete file" &&
|
|
|
|
gitweb_run "p=.git;a=history;f=deleted_file"'
|
|
|
|
|
2008-10-02 14:52:20 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# path_info links
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project' \
|
|
|
|
'gitweb_run "" "/.git"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch' \
|
|
|
|
'gitweb_run "" "/.git/b"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch:file' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'gitweb_run "" "/.git/main:file"'
|
2008-10-02 14:52:20 +00:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch:dir/' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'gitweb_run "" "/.git/main:foo/"'
|
2008-10-02 14:52:20 +00:00
|
|
|
|
2012-01-07 10:47:38 +00:00
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch (non-existent)' \
|
|
|
|
'gitweb_run "" "/.git/non-existent"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch:filename (non-existent branch)' \
|
|
|
|
'gitweb_run "" "/.git/non-existent:non-existent"'
|
|
|
|
|
2008-10-02 14:52:20 +00:00
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch:file (non-existent)' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'gitweb_run "" "/.git/main:non-existent"'
|
2008-10-02 14:52:20 +00:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch:dir/ (non-existent)' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'gitweb_run "" "/.git/main:non-existent/"'
|
2008-10-02 14:52:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/branch:/file' \
|
2020-11-18 23:44:43 +00:00
|
|
|
'gitweb_run "" "/.git/main:/file"'
|
2008-10-02 14:52:20 +00:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/:/file (implicit HEAD)' \
|
|
|
|
'gitweb_run "" "/.git/:/file"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'path_info: project/:/ (implicit HEAD, top tree)' \
|
|
|
|
'gitweb_run "" "/.git/:/"'
|
|
|
|
|
|
|
|
|
2007-05-19 00:19:20 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# feed generation
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'feeds: OPML' \
|
|
|
|
'gitweb_run "a=opml"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'feed: RSS' \
|
|
|
|
'gitweb_run "p=.git;a=rss"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'feed: Atom' \
|
|
|
|
'gitweb_run "p=.git;a=atom"'
|
|
|
|
|
2007-06-03 15:42:44 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# encoding/decoding
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'encode(commit): utf8' \
|
2017-05-09 12:54:24 +00:00
|
|
|
'. "$TEST_DIRECTORY"/t3901/utf8.txt &&
|
2011-02-27 16:58:32 +00:00
|
|
|
test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
|
|
|
|
test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "UTF-8" >>file &&
|
2007-06-03 15:42:44 +00:00
|
|
|
git add file &&
|
2008-08-08 09:26:28 +00:00
|
|
|
git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
|
2007-06-03 15:42:44 +00:00
|
|
|
gitweb_run "p=.git;a=commit"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'encode(commit): iso-8859-1' \
|
2017-05-09 12:54:24 +00:00
|
|
|
'. "$TEST_DIRECTORY"/t3901/8859-1.txt &&
|
2011-02-27 16:58:32 +00:00
|
|
|
test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
|
|
|
|
test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "ISO-8859-1" >>file &&
|
2007-06-03 15:42:44 +00:00
|
|
|
git add file &&
|
2013-03-24 21:06:13 +00:00
|
|
|
test_config i18n.commitencoding ISO-8859-1 &&
|
2009-05-18 23:44:38 +00:00
|
|
|
git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
|
2007-06-03 15:42:44 +00:00
|
|
|
gitweb_run "p=.git;a=commit"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'encode(log): utf-8 and iso-8859-1' \
|
|
|
|
'gitweb_run "p=.git;a=log"'
|
|
|
|
|
2007-07-28 14:27:32 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# extra options
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'opt: log --no-merges' \
|
|
|
|
'gitweb_run "p=.git;a=log;opt=--no-merges"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'opt: atom --no-merges' \
|
|
|
|
'gitweb_run "p=.git;a=log;opt=--no-merges"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'opt: "file" history --no-merges' \
|
|
|
|
'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'opt: log --no-such-option (invalid option)' \
|
|
|
|
'gitweb_run "p=.git;a=log;opt=--no-such-option"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'opt: tree --no-merges (invalid option for action)' \
|
|
|
|
'gitweb_run "p=.git;a=tree;opt=--no-merges"'
|
|
|
|
|
2007-12-08 11:30:59 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# testing config_to_multi / cloneurl
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'URL: no project URLs, no base URL' \
|
|
|
|
'gitweb_run "p=.git;a=summary"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'URL: project URLs via gitweb.url' \
|
|
|
|
'git config --add gitweb.url git://example.com/git/trash.git &&
|
|
|
|
git config --add gitweb.url http://example.com/git/trash.git &&
|
|
|
|
gitweb_run "p=.git;a=summary"'
|
|
|
|
|
|
|
|
cat >.git/cloneurl <<\EOF
|
|
|
|
git://example.com/git/trash.git
|
|
|
|
http://example.com/git/trash.git
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'URL: project URLs via cloneurl file' \
|
|
|
|
'gitweb_run "p=.git;a=summary"'
|
|
|
|
|
2007-11-02 23:41:18 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# gitweb config and repo config
|
|
|
|
|
gitweb: Fix project-specific feature override behavior
This commit fixes a bug in processing project-specific override in
a situation when there is no project, e.g. for the projects list page.
When 'snapshot' feature had project specific config override enabled
by putting
$feature{'snapshot'}{'override'} = 1;
(or equivalent) in $GITWEB_CONFIG, and when viewing toplevel gitweb
page, which means the projects list page (to be more exact this
happens for any project-less action), gitweb would put the following
Perl warnings in error log:
gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2065.
fatal: error processing config file(s)
gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2221.
gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2218.
The problem is in the following fragment of code:
# path to the current git repository
our $git_dir;
$git_dir = "$projectroot/$project" if $project;
# list of supported snapshot formats
our @snapshot_fmts = gitweb_get_feature('snapshot');
@snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
For the toplevel gitweb page, which is the list of projects, $project is not
defined, therefore neither is $git_dir. gitweb_get_feature() subroutine
calls git_get_project_config() if project specific override is turned
on... but we don't have project here.
Those errors mentioned above occur in the following fragment of code in
git_get_project_config():
# get config
if (!defined $config_file ||
$config_file ne "$git_dir/config") {
%config = git_parse_project_config('gitweb');
$config_file = "$git_dir/config";
}
git_parse_project_config() calls git_cmd() which has '--git-dir='.$git_dir
There are (at least) three possible solutions:
1. Harden gitweb_get_feature() so that it doesn't call
git_get_project_config() if $project (and therefore $git_dir) is not
defined; there is no project for project specific config.
2. Harden git_get_project_config() like you did in your fix, returning early
if $git_dir is not defined.
3. Harden git_cmd() so that it doesn't add "--git-dir=$git_dir" if $git_dir
is not defined, and change git_get_project_config() so that it doesn't
even try to access $git_dir if it is not defined.
This commit implements both 1.) and 2.), i.e. gitweb_get_feature() doesn't
call project-specific override if $git_dir is not defined (if there is no
project), and git_get_project_config() returns early if $git_dir is not
defined.
Add a test for this bug to t/t9500-gitweb-standalone-no-errors.sh test.
Reported-by: Eli Barzilay <eli@barzilay.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-01 21:51:34 +00:00
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
|
|
|
|
# turn on override for each overridable feature
|
|
|
|
foreach my $key (keys %feature) {
|
|
|
|
if ($feature{$key}{'sub'}) {
|
|
|
|
$feature{$key}{'override'} = 1;
|
|
|
|
}
|
|
|
|
}
|
2007-11-02 23:41:18 +00:00
|
|
|
EOF
|
|
|
|
|
gitweb: Fix project-specific feature override behavior
This commit fixes a bug in processing project-specific override in
a situation when there is no project, e.g. for the projects list page.
When 'snapshot' feature had project specific config override enabled
by putting
$feature{'snapshot'}{'override'} = 1;
(or equivalent) in $GITWEB_CONFIG, and when viewing toplevel gitweb
page, which means the projects list page (to be more exact this
happens for any project-less action), gitweb would put the following
Perl warnings in error log:
gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2065.
fatal: error processing config file(s)
gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2221.
gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2218.
The problem is in the following fragment of code:
# path to the current git repository
our $git_dir;
$git_dir = "$projectroot/$project" if $project;
# list of supported snapshot formats
our @snapshot_fmts = gitweb_get_feature('snapshot');
@snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
For the toplevel gitweb page, which is the list of projects, $project is not
defined, therefore neither is $git_dir. gitweb_get_feature() subroutine
calls git_get_project_config() if project specific override is turned
on... but we don't have project here.
Those errors mentioned above occur in the following fragment of code in
git_get_project_config():
# get config
if (!defined $config_file ||
$config_file ne "$git_dir/config") {
%config = git_parse_project_config('gitweb');
$config_file = "$git_dir/config";
}
git_parse_project_config() calls git_cmd() which has '--git-dir='.$git_dir
There are (at least) three possible solutions:
1. Harden gitweb_get_feature() so that it doesn't call
git_get_project_config() if $project (and therefore $git_dir) is not
defined; there is no project for project specific config.
2. Harden git_get_project_config() like you did in your fix, returning early
if $git_dir is not defined.
3. Harden git_cmd() so that it doesn't add "--git-dir=$git_dir" if $git_dir
is not defined, and change git_get_project_config() so that it doesn't
even try to access $git_dir if it is not defined.
This commit implements both 1.) and 2.), i.e. gitweb_get_feature() doesn't
call project-specific override if $git_dir is not defined (if there is no
project), and git_get_project_config() returns early if $git_dir is not
defined.
Add a test for this bug to t/t9500-gitweb-standalone-no-errors.sh test.
Reported-by: Eli Barzilay <eli@barzilay.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-01 21:51:34 +00:00
|
|
|
test_expect_success \
|
|
|
|
'config override: projects list (implicit)' \
|
|
|
|
'gitweb_run'
|
|
|
|
|
2009-02-18 13:09:41 +00:00
|
|
|
test_expect_success \
|
|
|
|
'config override: tree view, features not overridden in repo config' \
|
|
|
|
'gitweb_run "p=.git;a=tree"'
|
|
|
|
|
2007-11-02 23:41:18 +00:00
|
|
|
test_expect_success \
|
|
|
|
'config override: tree view, features disabled in repo config' \
|
|
|
|
'git config gitweb.blame no &&
|
|
|
|
git config gitweb.snapshot none &&
|
2009-06-29 22:00:51 +00:00
|
|
|
git config gitweb.avatar gravatar &&
|
2007-11-02 23:41:18 +00:00
|
|
|
gitweb_run "p=.git;a=tree"'
|
|
|
|
|
|
|
|
test_expect_success \
|
2009-02-18 13:09:41 +00:00
|
|
|
'config override: tree view, features enabled in repo config (1)' \
|
2007-11-02 23:41:18 +00:00
|
|
|
'git config gitweb.blame yes &&
|
|
|
|
git config gitweb.snapshot "zip,tgz, tbz2" &&
|
|
|
|
gitweb_run "p=.git;a=tree"'
|
|
|
|
|
2020-07-29 23:14:14 +00:00
|
|
|
test_expect_success 'setup' '
|
|
|
|
version=$(git config core.repositoryformatversion) &&
|
|
|
|
algo=$(test_might_fail git config extensions.objectformat) &&
|
2023-12-29 07:27:13 +00:00
|
|
|
refstorage=$(test_might_fail git config extensions.refstorage) &&
|
2020-07-29 23:14:14 +00:00
|
|
|
cat >.git/config <<-\EOF &&
|
|
|
|
# testing noval and alternate separator
|
|
|
|
[gitweb]
|
|
|
|
blame
|
|
|
|
snapshot = zip tgz
|
|
|
|
EOF
|
|
|
|
git config core.repositoryformatversion "$version" &&
|
|
|
|
if test -n "$algo"
|
|
|
|
then
|
|
|
|
git config extensions.objectformat "$algo"
|
2023-12-29 07:27:13 +00:00
|
|
|
fi &&
|
|
|
|
if test -n "$refstorage"
|
|
|
|
then
|
|
|
|
git config extensions.refstorage "$refstorage"
|
2020-07-29 23:14:14 +00:00
|
|
|
fi
|
|
|
|
'
|
|
|
|
|
2009-02-18 13:09:41 +00:00
|
|
|
test_expect_success \
|
|
|
|
'config override: tree view, features enabled in repo config (2)' \
|
|
|
|
'gitweb_run "p=.git;a=tree"'
|
|
|
|
|
2012-02-15 16:37:06 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# searching
|
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
|
|
|
|
# enable search
|
|
|
|
$feature{'search'}{'default'} = [1];
|
|
|
|
$feature{'grep'}{'default'} = [1];
|
|
|
|
$feature{'pickaxe'}{'default'} = [1];
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'search: preparation' \
|
|
|
|
'echo "1st MATCH" >>file &&
|
|
|
|
echo "2nd MATCH" >>file &&
|
|
|
|
echo "MATCH" >>bar &&
|
|
|
|
git add file bar &&
|
|
|
|
git commit -m "Added MATCH word"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'search: commit author' \
|
|
|
|
'gitweb_run "p=.git;a=search;h=HEAD;st=author;s=A+U+Thor"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'search: commit message' \
|
|
|
|
'gitweb_run "p=.git;a=search;h=HEAD;st=commitr;s=MATCH"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'search: grep' \
|
|
|
|
'gitweb_run "p=.git;a=search;h=HEAD;st=grep;s=MATCH"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'search: pickaxe' \
|
|
|
|
'gitweb_run "p=.git;a=search;h=HEAD;st=pickaxe;s=MATCH"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'search: projects' \
|
|
|
|
'gitweb_run "a=project_list;s=.git"'
|
|
|
|
|
2008-12-08 13:13:21 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# non-ASCII in README.html
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'README.html with non-ASCII characters (utf-8)' \
|
2020-03-22 21:14:21 +00:00
|
|
|
'echo "<b>UTF-8 example:</b><br />" >.git/README.html &&
|
|
|
|
cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >>.git/README.html &&
|
2008-12-08 13:13:21 +00:00
|
|
|
gitweb_run "p=.git;a=summary"'
|
|
|
|
|
2010-04-27 19:34:45 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# syntax highlighting
|
|
|
|
|
|
|
|
|
2013-10-06 20:50:46 +00:00
|
|
|
highlight_version=$(highlight --version </dev/null 2>/dev/null)
|
2010-04-27 19:34:45 +00:00
|
|
|
if [ $? -eq 127 ]; then
|
2013-10-06 20:50:46 +00:00
|
|
|
say "Skipping syntax highlighting tests: 'highlight' not found"
|
|
|
|
elif test -z "$highlight_version"; then
|
|
|
|
say "Skipping syntax highlighting tests: incorrect 'highlight' found"
|
2010-04-27 19:34:45 +00:00
|
|
|
else
|
|
|
|
test_set_prereq HIGHLIGHT
|
2010-10-13 11:57:41 +00:00
|
|
|
cat >>gitweb_config.perl <<-\EOF
|
|
|
|
our $highlight_bin = "highlight";
|
|
|
|
$feature{'highlight'}{'override'} = 1;
|
|
|
|
EOF
|
2010-04-27 19:34:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
test_expect_success HIGHLIGHT \
|
2010-10-13 11:57:41 +00:00
|
|
|
'syntax highlighting (no highlight, unknown syntax)' \
|
2010-04-27 19:34:45 +00:00
|
|
|
'git config gitweb.highlight yes &&
|
|
|
|
gitweb_run "p=.git;a=blob;f=file"'
|
|
|
|
|
|
|
|
test_expect_success HIGHLIGHT \
|
2010-10-13 11:57:41 +00:00
|
|
|
'syntax highlighting (highlighted, shell script)' \
|
2010-04-27 19:34:45 +00:00
|
|
|
'git config gitweb.highlight yes &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "#!/usr/bin/sh" >test.sh &&
|
2010-04-27 19:34:45 +00:00
|
|
|
git add test.sh &&
|
|
|
|
git commit -m "Add test.sh" &&
|
|
|
|
gitweb_run "p=.git;a=blob;f=test.sh"'
|
|
|
|
|
gitweb: use highlight's shebang detection
The "highlight" binary can, in some cases, determine the language type
by the means of file contents, for example the shebang in the first line
for some scripting languages. Make use of this autodetection for files
which syntax is not known by gitweb. In that case, pass the blob
contents to "highlight --force"; the parameter is needed to make it
always generate HTML output (which includes HTML-escaping).
Although we now run highlight on files which do not end up highlighted,
performance is virtually unaffected because when we call highlight, it
is used for escaping HTML. In the case that highlight is used, gitweb
calls sanitize() instead of esc_html(), and the latter is significantly
slower (it does more, being roughly a superset of sanitize()). Simple
benchmark comparing performance of 'blob' view of files without syntax
highlighting in gitweb before and after this change indicates ±1%
difference in request time for all file types. Benchmark was performed
on local instance on Debian, using Apache/2.4.23 web server and CGI.
Document the feature and improve syntax highlight documentation, add
test to ensure gitweb doesn't crash when language detection is used.
Signed-off-by: Ian Kelling <ian@iankelling.org>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-24 22:32:58 +00:00
|
|
|
test_expect_success HIGHLIGHT \
|
|
|
|
'syntax highlighting (highlighter language autodetection)' \
|
|
|
|
'git config gitweb.highlight yes &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "#!/usr/bin/perl" >test &&
|
gitweb: use highlight's shebang detection
The "highlight" binary can, in some cases, determine the language type
by the means of file contents, for example the shebang in the first line
for some scripting languages. Make use of this autodetection for files
which syntax is not known by gitweb. In that case, pass the blob
contents to "highlight --force"; the parameter is needed to make it
always generate HTML output (which includes HTML-escaping).
Although we now run highlight on files which do not end up highlighted,
performance is virtually unaffected because when we call highlight, it
is used for escaping HTML. In the case that highlight is used, gitweb
calls sanitize() instead of esc_html(), and the latter is significantly
slower (it does more, being roughly a superset of sanitize()). Simple
benchmark comparing performance of 'blob' view of files without syntax
highlighting in gitweb before and after this change indicates ±1%
difference in request time for all file types. Benchmark was performed
on local instance on Debian, using Apache/2.4.23 web server and CGI.
Document the feature and improve syntax highlight documentation, add
test to ensure gitweb doesn't crash when language detection is used.
Signed-off-by: Ian Kelling <ian@iankelling.org>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-24 22:32:58 +00:00
|
|
|
git add test &&
|
|
|
|
git commit -m "Add test" &&
|
|
|
|
gitweb_run "p=.git;a=blob;f=test"'
|
|
|
|
|
2011-04-29 17:51:56 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# forks of projects
|
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<\EOF &&
|
|
|
|
$feature{'forks'}{'default'} = [1];
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'forks: prepare' \
|
|
|
|
'git init --bare foo.git &&
|
|
|
|
git --git-dir=foo.git --work-tree=. add file &&
|
|
|
|
git --git-dir=foo.git --work-tree=. commit -m "Initial commit" &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "foo" >foo.git/description &&
|
2011-04-29 17:51:56 +00:00
|
|
|
mkdir -p foo &&
|
|
|
|
(cd foo &&
|
|
|
|
git clone --shared --bare ../foo.git foo-forked.git &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "fork of foo" >foo-forked.git/description)'
|
2011-04-29 17:51:56 +00:00
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'forks: projects list' \
|
|
|
|
'gitweb_run'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'forks: forks action' \
|
|
|
|
'gitweb_run "p=foo.git;a=forks"'
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# content tags (tag cloud)
|
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<-\EOF &&
|
|
|
|
# we don't test _setting_ content tags, so any true value is good
|
|
|
|
$feature{'ctags'}{'default'} = ['ctags_script.cgi'];
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'ctags: tag cloud in projects list' \
|
|
|
|
'mkdir .git/ctags &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "2" >.git/ctags/foo &&
|
|
|
|
echo "1" >.git/ctags/bar &&
|
2011-04-29 17:51:56 +00:00
|
|
|
gitweb_run'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'ctags: search projects by existing tag' \
|
|
|
|
'gitweb_run "by_tag=foo"'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'ctags: search projects by non existent tag' \
|
|
|
|
'gitweb_run "by_tag=non-existent"'
|
|
|
|
|
2011-06-09 07:08:57 +00:00
|
|
|
test_expect_success \
|
|
|
|
'ctags: malformed tag weights' \
|
|
|
|
'mkdir -p .git/ctags &&
|
2020-03-22 21:14:21 +00:00
|
|
|
echo "not-a-number" >.git/ctags/nan &&
|
|
|
|
echo "not-a-number-2" >.git/ctags/nan2 &&
|
2011-06-09 07:08:57 +00:00
|
|
|
echo "0.1" >.git/ctags/floating-point &&
|
|
|
|
gitweb_run'
|
|
|
|
|
2011-04-29 17:52:01 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# categories
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'categories: projects list, only default category' \
|
|
|
|
'echo "\$projects_list_group_categories = 1;" >>gitweb_config.perl &&
|
|
|
|
gitweb_run'
|
|
|
|
|
2012-02-15 15:36:41 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# unborn branches
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'unborn HEAD: "summary" page (with "heads" subview)' \
|
2015-03-20 10:10:21 +00:00
|
|
|
'{
|
|
|
|
git checkout orphan_branch ||
|
|
|
|
git checkout --orphan orphan_branch
|
|
|
|
} &&
|
2020-11-18 23:44:43 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2012-02-15 15:36:41 +00:00
|
|
|
gitweb_run "p=.git;a=summary"'
|
|
|
|
|
2007-05-19 00:19:20 +00:00
|
|
|
test_done
|