The snapshot support needs to be split between output- and config-related
functions to get the layering between shared.c and ui-*.c right. There
is also some codestyle-issues which needs fixing to make the snapshot
functions more similar to the rest of the cgit code.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This struct is used when generating http headers, and as such is another
small step towards the goal of the whole cleanup series; to invoke each
page/view function with a function pointer.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
All html-functions can be quite easily separated from the rest of cgit, so
lets do it; the only issue was html_filemode which uses some git-defined
macros so the function is moved into ui-shared.c::cgit_print_filemode().
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>
Using the functions offered by libgit feels like the right thing to do. Also,
make sure that config errors gets properly reported.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This removes the global variable which is used to keep track of the
currently selected repository, and adds a new variable in the cgit_context
structure.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This removes another big set of global variables, and introduces the
cgit_prepare_context() function which populates a context-variable with
compile-time default values.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This struct will hold all the cgit runtime information currently found in
a multitude of global variables.
The first cleanup removes all querystring-related variables.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
When no branch is specified and the repository does not have a default branch,
use the first branch.
Also, print sensible errormessages when the repository does not contain any
branches and when invalid branchnames are specified.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The new view mimics the output from `git format-patch`, making it possible
to cherry-pick directly from cgit with something like `curl $url | git am`.
Inspired by a patch to `git-apply` by Mike Hommey:
http://thread.gmane.org/gmane.comp.version-control.git/67611/focus=67610
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This adds support for two new parameters to cgitrc: clone-prefix and
repo.clone-url.
If clone-prefix is specified, all repos will get a clone url printed in the
sidebar; the url is generated by clone-prefix + repo.url.
Additionally, each repo can specify repo.clone-url which will override any
such auto-generated url.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
We used to rely on the result from strncmp() without comparing the length of
the strings involved. Even worse, any single-character format specifier would
enable zip-format due to the optional '.'-prefix since the length of the
mask then would become zero.
Noticed-by: Evan Martin <sys@neugierig.org>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Otherwise, when you leave out a description for a repository, the NULL
default causes cgit to print out titles like "cgit - (null)".
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
When a commit or tag lacks author/committer/tagger timestamp, do not skip
the next line in the commit/tag object.
Also, do not bother to print timestamps with value 0 as it is close to certain
to be bogus.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
With this change, cgit will start to generate the "robots" meta-tag, using
a default value of "index, nofollow".
The default value can be modified with a new cgitrc variable, "robots".
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The testsuite revealed that cgit snapshots don't set any useful timestamp on
the files contained in the snapshot.
Cherry-picked-from: 2ff33a8a04
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The testsuite revealed that cgit snapshots don't set any useful timestamp on
the files contained in the snapshot.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The cache-cleaning is potentially dangerous, so lets move it away from the
install target. A special emptycache target can be used to run the rm -rf.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
When the virtual-root was a single "/", it would be normalized to NULL due
to removal of trailing slashes, which in turn would fool us to belive that
we shouldn't generate virtual urls.
This makes the "/" normalize to "", effectively allowing virtual urls like
http://example.com/projectname to be generated without specifying the
full domain name as the virtual root.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>