When a commit is referenced by a branch or tag the commit subject-
line will be suffixed with the proper decorations, hence the test
for this line needs to be updated.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Since cgit now returns a 404 error when the snapshot filename cannot be
resolved to a commit object, the testscript needs to request a valid
snapshot name.
Also, the script assumed that the toplevel directory in the snapshot
would get the name of the repository but it's now named similar to
the requested snapshot.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The "((expr))" construct is not implemented by e.g. dash, so this commit
replaces the construct with a more portable one.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The system shell (/bin/sh) on Ubuntu is dash, which aims to be a
POSIX standard shell. In particular, dash does not implement any
of the common extensions to the standard that, say, bash and ksh
do.
Replace some non-POSIX constructs in setup.sh with more portable
and mundane code.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The struct member was introduces in git commit d53fe8187c38, but the cgit
testsuite failed to detect that cgit always generated archives without
prefixes, i.e. the result from cgit_repobasename was ignored.
This fixes the bug and the testsuite.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The link-generating functions are updated to use the new html_url_arg
function, thereby fixing links to strange repos, branches and files.
Also, the test-suite is updated to verify some cases of strange urls.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Both cgit_print_diff() and cgit_diff_tree() handles root commits nicely,
but cgit_print_commit() forgot to check the case of 0 parents.
This fixes it, and adds tests to avoid future regressions.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The original caching layer in cgit has no upper bound on the number of
concurrent cache entries, so when cgit is traversed by a spider (like the
googlebot), the cache might end up filling your disk. Also, if any error
occurs in the cache layer, no content is returned to the client.
This patch redesigns the caching layer to avoid these flaws by
* giving the cache a bound number of slots
* disabling the cache for the current request when errors occur
The cache size limit is implemented by hashing the querystring (the cache
lookup key) and generating a cache filename based on this hash modulo the
cache size. In order to detect hash collisions, the full lookup key (i.e.
the querystring) is stored in the cache file (separated from its associated
content by ascii 0).
The cache filename is the reversed 8-digit hexadecimal representation of
hash(key) % cache_size
which should make the filesystem lookup pretty fast (if directory content
is indexed/sorted); reversing the representation avoids the problem where
all keys have equal prefix.
There is a new config option, cache-size, which sets the upper bound for
the cache. Default value for this option is 0, which has the same effect
as setting nocache=1 (hence nocache is now deprecated).
Included in this patch is also a new testfile which verifies that the
new option works as intended.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The code for patch view assumed the current commit would always have a parent,
which made cgit segfault when that wasn't the case.
This fixes the bug and adds a test-script for patch view which includes a test
for the inital commit.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Log the complete output from each test-script in test-output.log and tell the
user about the logfile when a test-script fails.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The earlier segfault in cgit passed by unnoticed by this test-script due to
the pipe between cgit and sed.
There might be a more elegant solution to this problem, but my shellscript-
foo is weak.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
For some inexplicable reason I'd gotten the semantics of `grep -v` totally
backwards, thinking it somehow would make the exitcode from grep indicate
the non-match of the specified pattern.
This fixes the broken tests and gives me a valuable lession about shell
programming at the same time.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The segfault fixed in commit eacde43d71 was
triggered when the html-functions manipulated string literals. One callpatch
which could trigger the bug is in ui-repolist.c when repo descriptions are
passed to html_ntxt(): if a repo is lacking a description, the literal
string "[no description]" is used.
This patch changes test/setup.sh such that the first repo has no description,
and adds tests for both "[no description]" and "the bar repo" (description
of the other repo) to tests/t0101-index.sh, which should be enought to catch
regressions in these functions.
Noticed-by: Hiroki Hattori <seagull.kamome@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>