Lars Hjemli [Tue, 22 Jul 2008 17:30:06 +0000 (19:30 +0200)]
Makefile: fix git dependency rules
The objectfiles depends unconditionally on some specific git binaries while
those git binaries depends on the phony `git` target and this patch seems to
get these dependencies spelled out correctly.
Lars Hjemli [Mon, 21 Jul 2008 08:10:48 +0000 (10:10 +0200)]
Adjust to new calling convention for read_tree_recursive()
In GIT-1.6.0, read_tree_recursive takes an extra void pointer for callback
data. We might want to use this to avoid some global variables, but for now
lets just make sure that we can still compile.
Lars Hjemli [Tue, 20 May 2008 20:32:22 +0000 (22:32 +0200)]
ui-tree.c: avoid peeking at GITLINK objects
When an object in the tree has GITLINK mode-bits we don't need to get any
more info about that particular object (and trying to get more info about
it will usually generate an annoying warning on stderr since the object
typically doesn't exist in the repo anyways).
Lars Hjemli [Tue, 20 May 2008 15:56:47 +0000 (17:56 +0200)]
cache.c: fix error checking in print_slot()
The change to print_slot() in cdc6b2f8e7a8d43dcfe0475a9d3498333ea686b8 made
the function return correct errno for read errors while ignoring write errors,
which is not what was intended. This patch tries to rectify things.
Lars Hjemli [Sun, 18 May 2008 21:59:11 +0000 (23:59 +0200)]
cache.c: do not ignore errors from print_slot()
If print_slot() fails, the client will be served an inferior response.
This patch makes sure that such an error will be returned to main(), which
in turn will try to inform about the error in the response itself.
The error is also printed to the cache_log, i.e. stderr, which will make
the error message appear in error_log (atleast when httpd==apache).
Noticed-by: Jim Meyering <jim@meyering.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Lars Hjemli [Sat, 3 May 2008 10:44:20 +0000 (12:44 +0200)]
Add link to index page from repo header, remove page name
This makes it more obvious how to get back to the index, especially when the
config option `logo-link` is used. And the page name displayed in the header
provided no extra information. It only consumed space and deserved to die.
While at it, make sure that the different parts of the header doesn't wrap
when horizontal space is limited.
Lars Hjemli [Sat, 3 May 2008 08:54:39 +0000 (10:54 +0200)]
Add a pager on the repolist
This enables a pager on the repolist which restricts the number of entries
displayed per page, controlled by the new option `max-repo-count` (default
value 50).
Print an error if filename is not found in html_include.
Normally when html_include cannot open the file it fails silently and
things can be a bit hard to figure out from just looking at apache's
log. This will be beneficial for those initially setting up their server
with cgit.
Signed-off-by: Harley Laue <losinggeneration@aim.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Lars Hjemli [Mon, 28 Apr 2008 23:13:08 +0000 (01:13 +0200)]
Merge branch 'lh/about'
* lh/about:
Add 'about site' and 'about repo' pages
Prepare for 'about site' page / add 'root-readme' option to cgitrc
Make it possible for a single cmd to work both with and without a repo
Re-enable 'index-info' and add support for 'root-desc' in cgitrc
Move included header-file out of repolist table
Prepare for 'about repo' page
Lars Hjemli [Mon, 28 Apr 2008 23:01:30 +0000 (01:01 +0200)]
Make it possible for a single cmd to work both with and without a repo
When cgit_cmd.want_repo was 0, we used to assume that the cmd would never
be invoked for a repo. But soon this will become untrue (the 'about' cmd
is rapidly approching), so from now on we will initialize any requested
repo even if want_repo==0 (and return an error if want_repo==1 but no repo
is specified).
Lars Hjemli [Mon, 28 Apr 2008 22:55:34 +0000 (00:55 +0200)]
Re-enable 'index-info' and add support for 'root-desc' in cgitrc
The 'index-info' option got lost when the layout was converted from
sidebar to old-fashioned header (noticed by Harley Laue, thanks!), and
this commit re-enables it.
But there is now also an alternative in the 'root-desc' option; where
'index-info' specifies a file to include, 'root-desc' specifies the text
literally. This might be nicer for the one-liner descriptions which these
options typically provides.
Lars Hjemli [Mon, 28 Apr 2008 10:10:13 +0000 (12:10 +0200)]
Add page 'ls_cache'
This new page will list all entries found in the current cache, which is
useful when reviewing the new cache implementation. There are no links to
the new page, but it's reachable by adding 'p=ls_cache' to any cgit url.
Lars Hjemli [Mon, 28 Apr 2008 09:32:42 +0000 (11:32 +0200)]
Redesign the caching layer
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.
Lars Hjemli [Thu, 24 Apr 2008 21:32:02 +0000 (23:32 +0200)]
Integrate diffstat with diff
This creates a generic diffstat function in ui-diff, which then is
invoked from cgit_print_diff with the result that both commit and diff-
view gets a diffstat.
Lars Hjemli [Thu, 17 Apr 2008 16:29:50 +0000 (18:29 +0200)]
Fix commitdiff annoyance
Someone were a bit sloppy when the commitdiff got included 'inline' in
commit 89aa3c0d0a4c6d9885272602005975b763ea1604. This patch deletes a
stray `)` and makes sure the diffstat summary `<div>` is closed before
the full diff is printed.
Lars Hjemli [Mon, 14 Apr 2008 08:17:33 +0000 (10:17 +0200)]
cgit.css: set form margins
According to the css2 spec, htmlforms have 1.12em top and bottom margins. That
doesn't play well with the placement of the search form, so lets force it to
use 0em margins.
Lars Hjemli [Sun, 13 Apr 2008 10:48:44 +0000 (12:48 +0200)]
Merge branch 'lh/layout'
* lh/layout:
Make repository search case insensitive
Remove 'patch' link from tab, add to commit view
Implement minimal freetext search in the repolist
More layout fixes
Minor fixup in tree-view css
Reintroduce the branch switcher
Add fixed link to index page from repo header
Include diff in commit view
Replace sidebar/logo
Lars Hjemli [Sun, 13 Apr 2008 10:20:00 +0000 (12:20 +0200)]
Remove 'patch' link from tab, add to commit view
It's a bit confusing to enter the patch view from the tab, since it has no
layout. And the commit view has always lacked showing the commit id. Both of
these warts are fixed by this commit, which adds a new header line in the
commit view which shows the commit id as a 'permalink' to the current commit
and also adds a link to the patch view of the current commit.
Lars Hjemli [Tue, 25 Mar 2008 01:43:51 +0000 (02:43 +0100)]
Don't specify mimetype in ui-blob.c
But be sure to specify correct filename. This way, the client can hopefully
guess a sensible mimetype based on the filename suffix, and cgit can ignore
the issue altogether.
Lars Hjemli [Tue, 8 Apr 2008 19:29:21 +0000 (21:29 +0200)]
Merge branch 'lh/cleanup'
* lh/cleanup: (21 commits)
Reset ctx.repo to NULL when the config parser is finished
Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring()
Move function for configfile parsing into configfile.[ch]
Add cache.h
Remove global and obsolete cgit_cmd
Makefile: copy the QUIET constructs from the Makefile in git.git
Move cgit_version from shared.c to cgit.c
Makefile: autobuild dependency rules
Initial Makefile cleanup
Move non-generic functions from shared.c to cgit.c
Add ui-shared.h
Add separate header-files for each page/view
Refactor snapshot support
Add command dispatcher
Remove obsolete cacheitem parameter to ui-functions
Add struct cgit_page to cgit_context
Introduce html.h
Improve initialization of git directory
Move cgit_repo into cgit_context
Add all config variables into struct cgit_context
...
Lars Hjemli [Tue, 8 Apr 2008 19:27:12 +0000 (21:27 +0200)]
Reset ctx.repo to NULL when the config parser is finished
This global variable is used by the config parsing callback to keep track
of the currently configured repository. If it is not reset to NULL when
the config parser is finished, and neither `url` or `r` is specified on the
querystring, cgit will wrongly consider the last configured repo as
selected.
Lars Hjemli [Mon, 24 Mar 2008 22:01:44 +0000 (23:01 +0100)]
Makefile: autobuild dependency rules
This uses gcc to generate dependency rules for each `.o` file, based on the
corresponding `.c` file, into a new set of `.d` files (which are also defined
to depend on the same set of source files as their `.o` files).
Result:
* all objectfile dependencies are correctly calculated
* only the necessary dependencies are recalculated when a sourcefile is updated
Inspiration for the build rules:
* http://www.gnu.org/software/make/manual/make.html#Automatic-Prerequisites
* http://make.paulandlesley.org/autodep.html
Lars Hjemli [Mon, 24 Mar 2008 15:00:27 +0000 (16:00 +0100)]
Refactor snapshot support
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.
Lars Hjemli [Sun, 23 Mar 2008 23:51:19 +0000 (00:51 +0100)]
Add struct cgit_page to cgit_context
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.
Lars Hjemli [Sat, 23 Feb 2008 21:45:33 +0000 (22:45 +0100)]
Introduce html.h
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().
Lars Hjemli [Sun, 24 Feb 2008 14:35:52 +0000 (15:35 +0100)]
Brown paper bag: don't use `grep -v`
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.
Lars Hjemli [Sun, 24 Feb 2008 14:27:33 +0000 (15:27 +0100)]
Add regression-test for description-less repos
The segfault fixed in commit eacde43d7184452e1fdc90b982b531f1f5239923 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>
Lars Hjemli [Sat, 16 Feb 2008 12:56:09 +0000 (13:56 +0100)]
Move cgit_repo into cgit_context
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.
Lars Hjemli [Sat, 16 Feb 2008 12:07:13 +0000 (13:07 +0100)]
Add all config variables into struct cgit_context
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.