aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* cgit: use cgit_print_error_page() where appropriateJohn Keeping2015-08-141-20/+7
| | | | | | | | These are more-or-less one-to-one translations but in the final hunk we gain an HTTP error code where we used to send "200 OK", which is an improvement. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: add cgit_print_error_page() functionJohn Keeping2015-08-142-0/+16
This will allow us to generate error responses with the correct HTTP response code without needing all of the layout boilerplate. Signed-off-by: John Keeping <john@keeping.me.uk>
* Makefile: make "git/config.mak.uname" inclusion optionalJohn Keeping2015-08-131-1/+1
| | | | | | | If we haven't got a "git" directory, it should still be possible to run "make get-git", so we cannot include this file unconditionally. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: show full date in tooltip if longer ago than max_relativeJohn Keeping2015-08-131-0/+4
| | | | | | | | | | | Commit caed6cb (ui-shared: show absolute time in tooltip for relative dates, 2014-12-20) added a toolip when we show a relative time. However, in some cases we show a short date (that is, the date but not the time) if an event was sufficiently far in the past and that commit did not update that case to add the same tooltip. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: use common function in print_rel_date()John Keeping2015-08-131-10/+1
| | | | Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: extract date formatting to a functionJohn Keeping2015-08-131-4/+9
| | | | | | This will allow this code to be common with print_rel_date. Signed-off-by: John Keeping <john@keeping.me.uk>
* filter: don't use dlsym unnecessarilyJohn Keeping2015-08-131-36/+42
| | | | | | | We only need to hook write() if Lua filter's are in use. If support has been disabled, remove the dependency on dlsym(). Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-tree: use "sane" isgraph()John Keeping2015-08-132-1/+3
| | | | | | | | | | | | | | | | | | Git's git-compat-util.h defines a "sane ctype" that does not use locale information and works with signed chars, but it does not include isgraph() so we have included ctype.h ourselves. However, this means we have to include a system header before git-compat-util.h which may lead to the system defining some macros (e.g. _FILE_OFFSET_BITS on Solaris) before git-compat-util.h redefines them with a different value. We cannot include ctype.h after git-compat-util.h because we have defined many of its functions as macros which causes a stream of compilation errors. Defining our own "sane" isgraph() using Git's sane isprint() and isspace() avoids all of these problems. Signed-off-by: John Keeping <john@keeping.me.uk>
* cgit.h: move stdbool.h from ui-shared.hJohn Keeping2015-08-132-2/+2
| | | | | | Follow the Git policy of including system headers in only one place. Signed-off-by: John Keeping <john@keeping.me.uk>
* cache.c: fix header orderJohn Keeping2015-08-131-3/+3
| | | | | | | | git-compat-util.h may define values that affect how system headers are interpreted, so move sys/sendfile.h after cgit.h (which includes git-compat-util.h). Signed-off-by: John Keeping <john@keeping.me.uk>
* configfile.c: don't include system headers directlyJohn Keeping2015-08-131-2/+1
| | | | | | | | | git-compat-util.h may define various values that affect the interpretation of system headers. In most places we include cgit.h first, which pulls in git-compat-util.h, but this file does not depend on anything else in CGit, so use git-compat-util.h directly. Signed-off-by: John Keeping <john@keeping.me.uk>
* Remove redundant includesJohn Keeping2015-08-136-16/+0
| | | | | | | These are all included in git-compat-util.h (when necessary), which we include in cgit.h. Signed-off-by: John Keeping <john@keeping.me.uk>
* Makefile: include Git's config.mak.unameJohn Keeping2015-08-131-0/+1
| | | | | | | This pulls in the correct value of $(INSTALL) on a wide variety of systems. Signed-off-by: John Keeping <john@keeping.me.uk>
* tests: allow shell to be overriddenJohn Keeping2015-08-131-1/+5
On some systems (e.g. Solaris), /bin/sh is not a POSIX shell. Git already provides suitable overrides in its config.mak.uname file and we provide cgit.conf to allow the user to further change this. The code for this is taken from Git's t/Makefile, meaning that we now invoke the tests in the same way that Git does. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-log: fix double countingJohn Keeping2015-08-121-2/+2
| | | | | | | This crept in while rebasing the previous commit onto an updated upstream. Signed-off-by: John Keeping <john@keeping.me.uk>
* log: allow users to follow a fileJohn Keeping2015-08-1210-18/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Teach the "log" UI to behave in the same way as "git log --follow", when given a suitable instruction by the user. The default behaviour remains to show the log without following renames, but the follow behaviour can be activated by following a link in the page header. Follow is not the default because outputting merges in follow mode is tricky ("git log --follow" will not show merges). We also disable the graph in follow mode because the commit graph is not simplified so we end up with frequent gaps in the graph and many lines that do not connect with any commits we're actually showing. We also teach the "diff" and "commit" UIs to respect the follow flag on URLs, causing the single-file version of these UIs to detect renames. This feature is needed only for commits that rename the path we're interested in. For commits before the file has been renamed (i.e. that appear later in the log list) we change the file path in the links from the log to point to the old name; this means that links to commits always limit by the path known to that commit. If we didn't do this we would need to walk down the log diff'ing every commit whenever we want to show a commit. The drawback is that the "Log" link in the top bar of such a page links to the log limited by the old name, so it will only show pre-rename commits. I consider this a reasonable trade-off since the "Back" button still works and the log matches the path displayed in the top bar. Since following renames requires running diff on every commit we consider, I've added a knob to the configuration file to globally enable/disable this feature. Note that we may consider a large number of commits the revision walking machinery no longer performs any path limitation so we have to examine every commit until we find a page full of commits that affect the target path or something related to it. Suggested-by: René Neumann <necoro@necoro.eu> Signed-off-by: John Keeping <john@keeping.me.uk>
* shared: make cgit_diff_tree_cb publicJohn Keeping2015-08-122-2/+5
This will allow us to use this nice wrapper function elsewhere, avoiding dealing with the diff queue when we only need to inspect a filepair. Signed-off-by: John Keeping <john@keeping.me.uk>
* contrib/hooks: add sample post-receive hook using agefileJohn Keeping2015-08-121-0/+19
One of the most frequent questions on the mailing list relates to the idle time in the repository list. The answer to this is to use the "agefile" feature to calculate the time of the last change whenever the repository receives changes. Add a sample post-receive hook in a new "contrib" directory so that we can just point people at the repository in the future. Signed-off-by: John Keeping <john@keeping.me.uk>
* html: avoid using a plain integer as a NULL pointerJohn Keeping2015-03-091-22/+32
| | | | | | | | | Sparse complains about this table because we use the integer zero as the NULL pointer. Use this as an opportunity to reformat the table so that it always contains 8 elements per row, making it easier to see which values are being set and which are not. Signed-off-by: John Keeping <john@keeping.me.uk>
* cache: don't use an integer as a NULL pointerJohn Keeping2015-03-091-1/+1
| | | | Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: don't use an integer as a NULL pointerJohn Keeping2015-03-091-1/+1
| | | | Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: avoid initializing static variable to zeroJohn Keeping2015-03-091-1/+1
| | | | | | | | | Sparse complains that we are using a plain integer as a NULL pointer here, but in fact we do not have to specify a value for this variable at all since it has static storage duration and thus will be initialized to NULL by the compiler. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-stats: make cgit_period definitions 'static const'John Keeping2015-03-092-8/+8
| | | | | | | These definitions should not be modified (and never are) so we can move them to .rodata. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: make cgit_doctype 'static'John Keeping2015-03-091-1/+1
| | | | | | This is not used outside this file and is not declared. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-repolist: make sortcolumn definitions 'static const'John Keeping2015-03-091-2/+2
| | | | | | | These are not used outside this file and are not declared; they are also never modified. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-log: make some variables 'static'John Keeping2015-03-091-1/+1
| | | | | | These are not used outside this file and are not declared. Signed-off-by: John Keeping <john@keeping.me.uk>
* shared: make some variables 'static'John Keeping2015-03-091-2/+2
| | | | | | These are not used outside this file and are not declared. Signed-off-by: John Keeping <john@keeping.me.uk>
* scan-tree: make some variables 'static'John Keeping2015-03-091-2/+2
| | | | | | These are not used outside this file and are not declared. Signed-off-by: John Keeping <john@keeping.me.uk>
* Avoid signed bitfieldsJohn Keeping2015-03-092-3/+3
| | | | | | | | Bitfields are only defined for unsigned types. Detected by sparse. Signed-off-by: John Keeping <john@keeping.me.uk>
* Avoid non-ANSI function declarationsJohn Keeping2015-03-099-25/+25
| | | | | | | | Sparse says things like: warning: non-ANSI function declaration of function 'calc_ttl' Signed-off-by: John Keeping <john@keeping.me.uk>
* Makefile: add a target to run CGit through sparseJohn Keeping2015-03-092-1/+11
Signed-off-by: John Keeping <john@keeping.me.uk>
* cache: use F_SETLK to avoid stale lock filesJohn Keeping2015-03-031-1/+14
If CGit is killed while it holds a lock on a cache slot (for example because it is taking too long to generate a page), the lock file will be left in place. This prevents any future attempt to use the same slot since it will fail to exclusively create the lock file. Since CGit is the only program that should be manipulating lock files, we can use advisory locking to detect whether another process is actually using the lock file or if it is now stale. I have confirmed that this works on Linux by setting a short TTL in a custom cgitrc and running the following with CGit patched to print a message to stderr if the fcntl(2) fails: $ export CGIT_CONFIG=$PWD/cgitrc $ export QUERY_STRING=url=cgit/tree/ui-shared.c $ ./cgit | grep -v -e '^<div class=.footer.>' \ -e '^Last-Modified: ' \ -e ^'Expires: ' >expect $ seq 50000 | dd bs=8192 | parallel -j200 "diff -u expect <(./cgit | grep -v -e '^<div class=.footer.>' \ -e '^Last-Modified: ' \ -e ^'Expires: ') || echo BAD" This printed the fail message several times without ever printing "BAD". Signed-off-by: John Keeping <john@keeping.me.uk>
* tag: reference with "h" instead of "id"John Keeping2015-01-194-9/+8
When clicking on "log" from a tag we end up showing the log of whatever branch we used to reach the tag. If the tag doesn't point onto a branch then the tagged commit won't appear in this output. By linking to tags with the head parameter instead of the "id" parameter the log link will show the log of the tag. This is clearly desirable when the tag has been reached from the refs UI and changing the behaviour for tag decorations makes them match branch decorations where log -> decoration -> log shows the log of the decoration. Reported-by: Ferry Huberts <mailings@hupie.com> Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-diff: don't link to single file diff statJohn Keeping2014-12-301-0/+10
| | | | | | | | | Seeing the diff stat for a single file is pretty useless, so reset the diff type before generating the links to individual files in the diff stat so that the links will show a useful diff. Reported-by: Konstantin Ryabitsev <mricon@kernel.org> Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-patch: match git-format-patch(1) outputJohn Keeping2014-12-282-3/+4
| | | | | | | | | | | | | Using (DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH) causes Git to emit a "---" line between the commit message and the body of the patch, which fixes a regression introduced in commit 455b598 (ui-patch.c: Use log_tree_commit() to generate diffs, 2013-08-20), prior to which we inserted the "---" line ourselves. DIFF_FORMAT_SUMMARY is added so that we match the output of git-format-patch(1) without the "-p" option. Signed-off-by: John Keeping <john@keeping.me.uk>
* t0108: modernize styleJohn Keeping2014-12-281-10/+10
* &&-chaining * use test_cmp instead of cmp * use strip_headers instead of knowing how many lines there will be Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: show absolute time in tooltip for relative datesJohn Keeping2014-12-231-12/+23
Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: add rel-vcs microformat links to HTML headerJohn Keeping2014-12-231-0/+11
| | | | | | As described at https://joeyh.name/rfc/rel-vcs/. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-summary: add "rel='vcs-git'" to clone URL linksJohn Keeping2014-12-231-2/+4
| | | | | | | | This is described in the rel-vcs microformat[1]. [1] https://joeyh.name/rfc/rel-vcs/ Signed-off-by: John Keeping <john@keeping.me.uk>
* Extract clone URL printing to ui-shared.cJohn Keeping2014-12-233-46/+51
This will allow us to reuse the same logic to add clone URL <link/> elements to the header of all repo-specific pages in order to support the rel-vcs microformat. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-diff: add "stat only" diff typeJohn Keeping2014-12-132-1/+5
| | | | | | | | | | | This prints the diffstat but stops before printing (or generating) any of the body of the diff. No cgitrc option is added here so that we can wait to see how useful this is before letting people set it as the default. Suggested-by: Konstantin Ryabitsev <mricon@kernel.org> Signed-off-by: John Keeping <john@keeping.me.uk>
* Change "ss" diff flag to an enumJohn Keeping2014-12-134-14/+24
| | | | | | | | | | | This will allow us to introduce a new "stat only" diff mode without needing an explosion of mutually incompatible flags. The old "ss" query parameter is still accepted in order to avoid breaking saved links, but we no longer generate any URIs using it; instead the new "dt" (diff type) parameter is used. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: remove toggle_ssdiff arg to cgit_diff_link()John Keeping2014-12-134-8/+8
| | | | | | | This argument is never used with a value other than zero, so remove it and simplify the code. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-shared: remove toggle_ssdiff arg to cgit_commit_link()John Keeping2014-12-135-13/+11
| | | | | | | This argument is never used with a value other than zero, so remove it and simplify the code. Signed-off-by: John Keeping <john@keeping.me.uk>
* git: update to v2.0.4John Keeping2014-08-072-1/+1
No CGit changes required. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-stats.c: set parent pointer to NULL after freeing itJohn Keeping2014-07-281-0/+1
| | | | | | We do this everywhere else, so we should be doing it here as well. Signed-off-by: John Keeping <john@keeping.me.uk>
* git: update to v2.0.3John Keeping2014-07-286-9/+7
| | | | | | | | | | This is slightly more involved than just bumping the version number because it pulls in a change to convert the commit buffer to a slab, removing the "buffer" field from "struct commit". All sites that access "commit->buffer" have been changed to use the new functions provided for this purpose. Signed-off-by: John Keeping <john@keeping.me.uk>
* parsing.c: make commit buffer constJohn Keeping2014-07-281-4/+4
This will be required in order to incorporate the changes to commit buffer handling in Git 2.0.2. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-patch: Flush stdout after outputting dataJohn Keeping2014-06-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It looks like cached patches are truncated to the nearest 1024-byte boundary in the patch body. E.g.: > mricon@nikko:[/tmp]$ wget -O no-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=6e1b4fdad5157bb9e88777d525704aba24389bee" ... > 2014-06-11 15:34:51 (80.4 MB/s) - ‘no-cache’ saved [4767] Patch is complete, without truncation. Next hit, with cache in place: > mricon@nikko:[/tmp]$ wget -O yes-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=6e1b4 > fdad5157bb9e88777d525704aba24389bee" ... > 2014-06-11 15:35:01 (17.0 MB/s) - ‘yes-cache’ saved [4096/4096] Length truncated to 4096. The cache on disk looks truncated as well, so the bug must me during the process of saving cache. The same is true for larger patches: > mricon@nikko:[/tmp]$ wget -O no-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=2840c566e95599cd60c7143762ca8b49d9395050" ... > 2014-06-11 15:41:33 (1.07 MB/s) - ‘no-cache’ saved [979644] 979644 bytes with a cache-miss > mricon@nikko:[/tmp]$ wget -O yes-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=2840c > 566e95599cd60c7143762ca8b49d9395050" ... > 2014-06-11 15:41:46 (1.05 MB/s) - ‘yes-cache’ saved [978944] 978944 (956KB exactly) with a cache-hit Since the "html" functions use raw write(2) to STDIO_FILENO, we don't notice problems with most pages, but raw patches write using printf(3). This is fine if we're outputting straight to stdout since the buffers are flushed on exit, but we close the cache output before this, so the cached output ends up being truncated. Make sure the buffers are flushed when we finish outputting a patch so that we avoid this. No other UIs use printf(3) so we do not need to worry about them. Actually, it's slightly more interesting than this... since we don't set GIT_FLUSH, Git decides whether or not it will flush stdout after writing each commit based on whether or not stdout points to a regular file (in maybe_flush_or_die()). Which means that when writing directly to the webserver, Git flushes stdout for us, but when we redirect stdout to the cache it points to a regular file so Git no longer flushes the output for us. The patch is still correct, but perhaps the full explanation is interesting! Reported-by: Konstantin Ryabitsev <mricon@kernel.org>
* ui-log: ignore unhandled argumentsJohn Keeping2014-06-281-3/+3
If you search for a bogus range string here: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/ Using something like "range" and "qwerty123456", it returns an "Internal Server Error" and the following in the logs: > [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] fatal: > ambiguous argument 'qwerty123456': unknown revision or path not in the > working tree., referer: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ > [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] Use '--' to > separate paths from revisions, like this:, referer: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ > [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] 'git <command> > [<revision>...] -- [<file>...]', referer: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ > [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] Premature end > of script headers: cgit, referer: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ The cache will kick in, so if you search for the same string again, it'll show an empty range, so you have to change the bogus strings each time. This is because we just pass the arguments straight to Git's revision parsing machinery which die()s if it cannot parse an argument, printing the above to stderr and exiting. The patch below makes it a bit friendlier by just ignoring unhandled arguments, but I can't see an easy way to report errors when we can't parse revision arguments without losing the flexibility of supporting all of the revision specifiers supported by Git. Reported-by: Konstantin Ryabitsev <mricon@kernel.org>