]> granicus.if.org Git - cgit/log
cgit
10 years agoemail-gravatar.py: fix UTF-8
Christian Hesse [Tue, 14 Jan 2014 10:11:23 +0000 (11:11 +0100)]
email-gravatar.py: fix UTF-8

10 years agoemail-gravatar.lua: fix for lua 5.2
Christian Hesse [Tue, 14 Jan 2014 10:32:54 +0000 (11:32 +0100)]
email-gravatar.lua: fix for lua 5.2

10 years agomakefile: only display lua message once
Jason A. Donenfeld [Tue, 14 Jan 2014 12:47:28 +0000 (13:47 +0100)]
makefile: only display lua message once

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoREADME: document lua makefile flags
Jason A. Donenfeld [Tue, 14 Jan 2014 02:48:23 +0000 (03:48 +0100)]
README: document lua makefile flags

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agocgitrc.5.txt: Fix documentation of the snapshot mask
Lukas Fleischer [Mon, 13 Jan 2014 23:49:48 +0000 (00:49 +0100)]
cgitrc.5.txt: Fix documentation of the snapshot mask

Mention that the snapshot setting only specifies the formats that links
are generated for and not the set of formats that are accessible via
HTTP.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agomakefile: auto-detect presence of various Lua, bsd
Jason A. Donenfeld [Tue, 14 Jan 2014 00:50:31 +0000 (01:50 +0100)]
makefile: auto-detect presence of various Lua, bsd

We favor LuaJIT over Lua. We disable Lua if neither can be found. We
error out if a particular Lua is specified via LUA_IMPLEMENTATION=JIT or
LUA_IMPLEMENTATION=VANILLA, but cannot be found. We print a status
message depending on what happens.

Also, we do not link against libdl on the BSDs, since they include it as
part of libc.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: style tweaks
Jason A. Donenfeld [Mon, 13 Jan 2014 22:54:28 +0000 (23:54 +0100)]
filter: style tweaks

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: add page source to email filter
Jason A. Donenfeld [Mon, 13 Jan 2014 15:24:40 +0000 (16:24 +0100)]
filter: add page source to email filter

Since the email filter is called from lots of places, the script might
benefit from knowing the origin. That way it can modify its contents
and/or size depending.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: add gravatar scripts
Jason A. Donenfeld [Fri, 10 Jan 2014 05:17:09 +0000 (06:17 +0100)]
filter: add gravatar scripts

The lua one is hugely faster than the python one, but both are included
for comparison.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: add support for email filter
Jason A. Donenfeld [Mon, 13 Jan 2014 03:04:52 +0000 (04:04 +0100)]
filter: add support for email filter

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: return on null filter from open and close
Jason A. Donenfeld [Mon, 13 Jan 2014 02:56:50 +0000 (03:56 +0100)]
filter: return on null filter from open and close

So that we don't have to include the if(filter) open_filter(filter)
block everywhere, we introduce the guard in the function itself. This
should simplify quite a bit of code.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: add lua support
Jason A. Donenfeld [Mon, 13 Jan 2014 13:18:51 +0000 (14:18 +0100)]
filter: add lua support

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: basic write hooking infrastructure
Jason A. Donenfeld [Mon, 13 Jan 2014 13:16:18 +0000 (14:16 +0100)]
filter: basic write hooking infrastructure

Filters can now call hook_write and unhook_write if they want to
redirect writing to stdout to a different function. This saves us from
potential file descriptor pipes and other less efficient mechanisms.

We do this instead of replacing the call in html_raw because some places
stdlib's printf functions are used (ui-patch or within git itself),
which has its own internal buffering, which makes it difficult to
interlace our function calls. So, we dlsym libc's write and then
override it in the link stage.

While we're at it, we move considerations of argument count into the
generic new filter handler.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: allow for cleanup hook for filter types
Jason A. Donenfeld [Sun, 12 Jan 2014 19:58:21 +0000 (20:58 +0100)]
filter: allow for cleanup hook for filter types

At some point, we're going to want to do lazy deallocation of filters.
For example, if we implement lua, we'll want to load the lua runtime
once for each filter, even if that filter is called many times.
Similarly, for persistent exec filters, we'll want to load it once,
despite many open_filter and close_filter calls, and only reap the child
process at the end of the cgit process. For this reason, we add here a
cleanup function that is called at the end of cgit's main().

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: introduce "filter type" prefix
John Keeping [Sun, 12 Jan 2014 17:13:53 +0000 (17:13 +0000)]
filter: introduce "filter type" prefix

This allows different filter implementations to be specified in the
configuration file.  Currently only "exec" is supported, but it may now
be specified either with or without the "exec:" prefix.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agofilter: add interface layer
John Keeping [Sun, 12 Jan 2014 17:13:52 +0000 (17:13 +0000)]
filter: add interface layer

Change the existing cgit_{open,close,fprintf}_filter functions to
delegate to filter-specific implementations accessed via function
pointers on the cgit_filter object.

We treat the "exec" filter type slightly specially here by putting its
structure definition in the header file and providing an "init" function
to set up the function pointers.  This is required so that the
ui-snapshot.c code that applies a compression filter can continue to use
the filter interface to do so.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agofilter: add fprintf_filter function
John Keeping [Sun, 12 Jan 2014 17:13:51 +0000 (17:13 +0000)]
filter: add fprintf_filter function

This stops the code in cgit.c::print_repo needing to inspect the
cgit_filter structure, meaning that we can abstract out different filter
types that will have different fields that need to be printed.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agoauthors: specify maintainers
Jason A. Donenfeld [Tue, 14 Jan 2014 00:59:28 +0000 (01:59 +0100)]
authors: specify maintainers

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilters: Improved syntax-highlighting.py
Stefan Tatschner [Mon, 13 Jan 2014 21:10:45 +0000 (22:10 +0100)]
filters: Improved syntax-highlighting.py

- Switched back to python2 according to a problem in pygments with python3.
  With the next release of pygments this problem should be fixed.
  Issue see here:
  https://bitbucket.org/birkenfeld/pygments-main/issue/901/problems-with-python3
- Just read the stdin, decode it to utf-8 and ignore unknown signs. This ensures
  that even destroyed files do not cause any errors in the filter.
- Improved language guessing:
  -> At first use guess_lexer_for_filename for a better detection of the used
     programming languages (even mixed cases will be detected, e.g. php + html).
  -> If nothing was found look if there is a shebang and use guess_lexer.
  -> As default/fallback choose TextLexer.

Signed-off-by: Stefan Tatschner <stefan@sevenbyte.org>
10 years agotests: add CGIT_TEST_OPTS variable to Makefile
John Keeping [Sun, 12 Jan 2014 19:46:42 +0000 (19:46 +0000)]
tests: add CGIT_TEST_OPTS variable to Makefile

This allows running the entire test suite with a set of command-line
options.  For example:

make test CGIT_TEST_OPTS=--valgrind

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agoui-repolist: HTML-escape cgit_rooturl() response
John Keeping [Sun, 12 Jan 2014 19:45:17 +0000 (19:45 +0000)]
ui-repolist: HTML-escape cgit_rooturl() response

This is for consistency with other callers.  The value returned from
cgit_rooturl is not guaranteed to be HTML-safe.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agoui-shared: URL-escape script_name
John Keeping [Sun, 12 Jan 2014 19:45:16 +0000 (19:45 +0000)]
ui-shared: URL-escape script_name

As far as I know, there is no requirement that $SCRIPT_NAME contain only
URL-safe characters, so we need to make sure that any special characters
are escaped.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agoui-refs: escape HTML chars in author and tagger names
John Keeping [Sun, 12 Jan 2014 19:45:15 +0000 (19:45 +0000)]
ui-refs: escape HTML chars in author and tagger names

Everywhere else we use html_txt to escape any special characters in
these variables.  Do so here as well.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agofilter: pass extra arguments via cgit_open_filter
John Keeping [Sun, 12 Jan 2014 17:13:50 +0000 (17:13 +0000)]
filter: pass extra arguments via cgit_open_filter

This avoids poking into the filter data structure at various points in
the code.  We rely on the fact that the number of arguments is fixed
based on the filter type (set in cgit_new_filter) and that the call
sites all know which filter type they're using.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agoui-snapshot: set unused cgit_filter fields to zero
John Keeping [Sun, 12 Jan 2014 17:13:49 +0000 (17:13 +0000)]
ui-snapshot: set unused cgit_filter fields to zero

By switching the assignment of fields in the cgit_filter structure to
use designated initializers, the compiler will initialize all other
fields to their default value.  This will be needed when we add the
extra_args field in the next patch.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agohtml: remove redundant htmlfd variable
John Keeping [Sun, 12 Jan 2014 17:13:48 +0000 (17:13 +0000)]
html: remove redundant htmlfd variable

This is never changed from STDOUT_FILENO, so just use that value
directly.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agotests: add Valgrind support
John Keeping [Mon, 8 Apr 2013 19:12:38 +0000 (20:12 +0100)]
tests: add Valgrind support

Now running tests with the "--valgrind" option will run cgit under
Valgrind instead of all Git commands.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agocache: don't leave cache_slot fields uninitialized
John Keeping [Sun, 12 Jan 2014 16:49:40 +0000 (16:49 +0000)]
cache: don't leave cache_slot fields uninitialized

Valgrind says:

==18344== Conditional jump or move depends on uninitialised value(s)
==18344==    at 0x406C83: open_slot (cache.c:63)
==18344==    by 0x407478: cache_ls (cache.c:403)
==18344==    by 0x404C9A: process_request (cgit.c:639)
==18344==    by 0x406BD2: fill_slot (cache.c:190)
==18344==    by 0x4071A0: cache_process (cache.c:284)
==18344==    by 0x404461: main (cgit.c:952)
==18344==  Uninitialised value was created by a stack allocation
==18344==    at 0x40738B: cache_ls (cache.c:375)

This is caused by the keylen field being used to calculate whether or
not a slot is matched.  We never then check the value of this and the
length of data read depends on the key length read from the file so this
isn't dangerous, but it's nice to avoid branching based on uninitialized
data.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years agofilter: split filter functions into their own file
Jason A. Donenfeld [Fri, 10 Jan 2014 04:19:05 +0000 (05:19 +0100)]
filter: split filter functions into their own file

A first step for more interesting things.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: make exit status local
Jason A. Donenfeld [Fri, 10 Jan 2014 02:51:02 +0000 (03:51 +0100)]
filter: make exit status local

It's only used in one place, and not useful to have around since
close_filter will die() if exit_status isn't what it expects, anyway. So
this is best as just a local variable instead of as part of the struct.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoparsing: fix header typo
Jason A. Donenfeld [Fri, 10 Jan 2014 03:59:34 +0000 (04:59 +0100)]
parsing: fix header typo

10 years agocgit.c: Fix comment on bit mask hack
Lukas Fleischer [Fri, 10 Jan 2014 13:55:31 +0000 (14:55 +0100)]
cgit.c: Fix comment on bit mask hack

* Formatting and spelling fixes.

* A bit mask with the size of one byte only allows for storing 8 (not
  255!) different flags.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agocgit.c: Use "else" for mutually exclusive branches
Lukas Fleischer [Fri, 10 Jan 2014 13:55:30 +0000 (14:55 +0100)]
cgit.c: Use "else" for mutually exclusive branches

When parsing command line arguments, no pair of command line options can
ever match simultaneously. Use "else if" blocks to reflect this. This
change improves both readability and speed.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoui-snapshot.c: Do not reinvent suffixcmp()
Lukas Fleischer [Fri, 10 Jan 2014 11:44:38 +0000 (12:44 +0100)]
ui-snapshot.c: Do not reinvent suffixcmp()

Use suffixcmp() from Git instead of reimplementing it. This is a
preparation for moving to ends_with() in Git 1.8.6.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoRefactor cgit_parse_snapshots_mask()
Lukas Fleischer [Fri, 10 Jan 2014 11:44:37 +0000 (12:44 +0100)]
Refactor cgit_parse_snapshots_mask()

Use Git string lists instead of str{spn,cspn,ncmp}() magic. This
significantly improves readability.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoDisallow use of undocumented snapshot delimiters
Lukas Fleischer [Fri, 10 Jan 2014 11:44:36 +0000 (12:44 +0100)]
Disallow use of undocumented snapshot delimiters

Since the introduction of selective snapshot format configuration in
dc3c9b5 (allow selective enabling of snapshots, 2007-07-21), we allowed
seven different delimiters for snapshot formats, while the documentation
has always been clear about spaces being the only valid delimiter:

    The value is a space-separated list of zero or more of the values
    "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip".

Supporting the undocumented delimiters makes the code unnecessarily
complex. Remove them.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoReplace most uses of strncmp() with prefixcmp()
Lukas Fleischer [Fri, 10 Jan 2014 11:44:35 +0000 (12:44 +0100)]
Replace most uses of strncmp() with prefixcmp()

This is a preparation for replacing all prefix checks with either
strip_prefix() or starts_with() when Git 1.8.6 is released.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoREADME: Fix dependencies
Lukas Fleischer [Thu, 9 Jan 2014 18:44:27 +0000 (19:44 +0100)]
README: Fix dependencies

* Remove the dependency on Git (which can be obtained automatically when
  building, using either the Git submodule or `make get-git`).

* Use proper upstream names of dependencies.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoREADME: Spelling and formatting fixes
Lukas Fleischer [Wed, 8 Jan 2014 18:45:29 +0000 (19:45 +0100)]
README: Spelling and formatting fixes

* Several small spelling and capitalization fixes.

* Use consistent and better-looking formatting that is compatible with
  AsciiDoc (and partly compatible with RST).

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoFix UTF-8 with syntax-highlighting.py
Přemysl Janouch [Wed, 11 Sep 2013 18:10:12 +0000 (20:10 +0200)]
Fix UTF-8 with syntax-highlighting.py

Previously the script tried to encode output from Pygments with
the ASCII codec, which failed.

Signed-off-by: Přemysl Janouch <p.janouch@gmail.com>
10 years agoAdd a suggestion to the manpage
Přemysl Janouch [Wed, 11 Sep 2013 18:10:14 +0000 (20:10 +0200)]
Add a suggestion to the manpage

So that people wishing to use "enable-http-clone" don't have to find
out the correct settings on their own.

Signed-off-by: Přemysl Janouch <p.janouch@gmail.com>
10 years agoFix the example configuration
Přemysl Janouch [Wed, 11 Sep 2013 18:10:13 +0000 (20:10 +0200)]
Fix the example configuration

"enable-git-clone" doesn't exist, replaced with "enable-http-clone".

Signed-off-by: Přemysl Janouch <p.janouch@gmail.com>
10 years agoFix about-formatting.sh
Přemysl Janouch [Wed, 11 Sep 2013 18:10:11 +0000 (20:10 +0200)]
Fix about-formatting.sh

dash failed to parse the script.

Signed-off-by: Přemysl Janouch <p.janouch@gmail.com>
10 years agoFix some spelling errors
Přemysl Janouch [Wed, 11 Sep 2013 18:10:10 +0000 (20:10 +0200)]
Fix some spelling errors

Signed-off-by: Přemysl Janouch <p.janouch@gmail.com>
10 years agofilters: highlight.sh: add css comments for highlight 2.6 and 3.8
Ferry Huberts [Sat, 9 Nov 2013 19:34:55 +0000 (20:34 +0100)]
filters: highlight.sh: add css comments for highlight 2.6 and 3.8

v2: add highlight 3.13 as present on Fedora 19

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
10 years agoAdd AUTHORS file
Lukas Fleischer [Wed, 8 Jan 2014 14:18:03 +0000 (15:18 +0100)]
Add AUTHORS file

Contains a list of contributors with more than 20 patches, to be updated
regularly.

Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
10 years agoUpdate copyright information
Lukas Fleischer [Wed, 8 Jan 2014 14:10:49 +0000 (15:10 +0100)]
Update copyright information

* Name "cgit Development Team" as copyright holder to avoid listing
  every single developer.

* Update copyright ranges.

Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
10 years agogit: update to 1.8.5
Christian Hesse [Wed, 27 Nov 2013 23:19:50 +0000 (00:19 +0100)]
git: update to 1.8.5

Everything works just bumping the version in Makefile and commit hash
in submodule. No code changes required.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoReduce line number bloat, fix hover effect
Peter Wu [Thu, 3 Oct 2013 10:17:23 +0000 (12:17 +0200)]
Reduce line number bloat, fix hover effect

Currently line numbers look like (for blob view and sdiff respectively):

    <a class='no' id='n68' name='n68' href='#n68'>68</a>
    <td class='lineno'><a class='no' href='...#n1' id='n1' name='n1'>1</a></td>

name=".." is unnecessary if the id attribute is set (this even applies
to IE6), so drop it. (aside, in HTML5, the name attribute is gone.)

The line number links can be selected through their parent classes, no
need for another class "no", so drop it too.

For a file with 2000 lines, this yields a saving of 40% (29% gzipped).

While at it, fix the hover effect of line numbers: now the line number
get a black background as was intended.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoplain: don't append charset for binary MIME types
John Keeping [Sun, 6 Oct 2013 11:14:41 +0000 (12:14 +0100)]
plain: don't append charset for binary MIME types

When outputting the Content-Type HTTP header we print the MIME type and
then append "; charset=<charset>" if the charset variable is non-null.

We don't want a charset when we have selected "application/octet-stream"
or when the user has specified a custom MIME type, since they may have
specified their own charset.  To avoid this, make sure we set the page's
charset to NULL in ui-plain before we generate the HTTP headers.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoui-log.c: Several simplifications
Lukas Fleischer [Fri, 22 Nov 2013 12:30:58 +0000 (13:30 +0100)]
ui-log.c: Several simplifications

* Use argv_array_pushf() for inserting formatted strings.
* Remove unneeded static strings.
* Replace "if" by "else if" for readability and speed.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoUse argv_array in place of vector
Lukas Fleischer [Fri, 22 Nov 2013 12:24:52 +0000 (13:24 +0100)]
Use argv_array in place of vector

Instead of using our own vector implementation, use argv_array from Git
which has been specifically designed for dynamic size argv arrays.

Drop vector.h and vector.c which are no longer needed.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoui-stats.c: Remove unused macro
Lukas Fleischer [Fri, 22 Nov 2013 08:50:17 +0000 (09:50 +0100)]
ui-stats.c: Remove unused macro

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoscan-tree.c: Remove unused macro
Lukas Fleischer [Fri, 22 Nov 2013 08:49:31 +0000 (09:49 +0100)]
scan-tree.c: Remove unused macro

This is no longer needed since commit fb3655df (use struct strbuf
instead of static buffers, 2013-04-06).

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-shared: Drop filepair_cb_raw() and helper
Lukas Fleischer [Tue, 27 Aug 2013 08:40:51 +0000 (10:40 +0200)]
ui-shared: Drop filepair_cb_raw() and helper

Remove filepair_cb_raw() and all related functions. These are no longer
needed. We now use Git's internal functions for raw diff formatting
everywhere.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-diff: Use diff_tree_sha1() for raw diff formatting
Lukas Fleischer [Tue, 27 Aug 2013 08:40:50 +0000 (10:40 +0200)]
ui-diff: Use diff_tree_sha1() for raw diff formatting

Use Git's internal diff_tree_sha1() function for the /rawdiff/ command
instead of trying to recreate this functionality.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agotests/: Add t0110-rawdiff.sh
Lukas Fleischer [Mon, 26 Aug 2013 18:56:55 +0000 (20:56 +0200)]
tests/: Add t0110-rawdiff.sh

This adds some basic tests for the /rawdiff/ command.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agot0108: Add tests for revision ranges
Lukas Fleischer [Mon, 26 Aug 2013 18:38:35 +0000 (20:38 +0200)]
t0108: Add tests for revision ranges

Add tests to check whether generating multiple patches at once works.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agot0108: Compare output with git-format-patch(1)
Lukas Fleischer [Mon, 26 Aug 2013 18:38:34 +0000 (20:38 +0200)]
t0108: Compare output with git-format-patch(1)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-patch.c: Add additional newline after each patch
Lukas Fleischer [Mon, 26 Aug 2013 18:38:33 +0000 (20:38 +0200)]
ui-patch.c: Add additional newline after each patch

For consistency with git-format-patch(1).

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-patch.c: Fix signature delimiter
Lukas Fleischer [Mon, 26 Aug 2013 18:38:32 +0000 (20:38 +0200)]
ui-patch.c: Fix signature delimiter

Add a missing space after the "--" marker that introduces the patch
signature.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agot0108: Avoid unnecessary fork()
Lukas Fleischer [Mon, 26 Aug 2013 18:38:31 +0000 (20:38 +0200)]
t0108: Avoid unnecessary fork()

Use `git rev-list --max-parents=0 HEAD` instead of `git rev-list HEAD |
tail -1` to get the root commit. This works since Git 1.7.4.2.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agogit: update to 1.8.4
John Keeping [Fri, 23 Aug 2013 23:28:39 +0000 (00:28 +0100)]
git: update to 1.8.4

No code changes required, just bump the submodule and makefile versions.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoui-patch.c: Fix formatting for merge commits
Lukas Fleischer [Thu, 22 Aug 2013 12:48:47 +0000 (14:48 +0200)]
ui-patch.c: Fix formatting for merge commits

Add max_parents = 1 to the revision walk in order to make sure we do not
include the footer signature twice for merge commits.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-patch: Rename variables
Lukas Fleischer [Tue, 20 Aug 2013 16:56:15 +0000 (18:56 +0200)]
ui-patch: Rename variables

Rename parameters and local variables to match those from ui-diff. Also,
convert a "char *" to "const char *".

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoAllow for creating patch series
Lukas Fleischer [Tue, 20 Aug 2013 16:56:14 +0000 (18:56 +0200)]
Allow for creating patch series

This allows for specifying a revision range using the id2 parameter of
/patch/. The output that is produced is similar to

    $ git format-patch --stdout id2..id

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-patch.c: Use log_tree_commit() to generate diffs
Lukas Fleischer [Tue, 20 Aug 2013 16:56:13 +0000 (18:56 +0200)]
ui-patch.c: Use log_tree_commit() to generate diffs

Instead of using our own formatting, use log_tree_commit() from Git to
create patches. This removes unnecessary duplicate code and also fixes a
bug with e-mail address formatting that existed in our own
implementation.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-diff: Check the return value of get_sha1()
Lukas Fleischer [Tue, 20 Aug 2013 16:56:12 +0000 (18:56 +0200)]
ui-diff: Check the return value of get_sha1()

Sync with what we do everywhere else and check the return value of
get_sha1() instead of calling sha1_object_info() to validate the object.
Note that we later call lookup_commit_reference(), which checks that
both SHA1 values refer to commits, anyway.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agocmd.c: Add a "rawdiff" command
Lukas Fleischer [Wed, 14 Aug 2013 08:50:33 +0000 (10:50 +0200)]
cmd.c: Add a "rawdiff" command

This can be used to generate raw diffs between arbitrary revisions using
something like

     /rawdiff/?id=v0.9&id2=v0.9.1

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoAllow for creating raw diffs with cgit_print_diff()
Lukas Fleischer [Wed, 14 Aug 2013 08:50:32 +0000 (10:50 +0200)]
Allow for creating raw diffs with cgit_print_diff()

This adds a parameter to cgit_print_diff() to create raw diffs, using
the same format as `git diff <commit>`.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoExtract filepair_cb from ui-patch.c
Lukas Fleischer [Wed, 14 Aug 2013 08:50:31 +0000 (10:50 +0200)]
Extract filepair_cb from ui-patch.c

Move filepair_cb() from ui-patch.c to ui-shared.c and rename it to
filepair_cb_raw(). This callback will be used in ui-diff.c in a
follow-up patch.

Note that it is not straightforward to extract filepair_cb() from
ui-diff.c which is why it is not done here as well.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoFix silly spelling error.
Jason A. Donenfeld [Fri, 16 Aug 2013 19:15:17 +0000 (13:15 -0600)]
Fix silly spelling error.

11 years agoFix section-from-path > 1
Lukas Fleischer [Fri, 28 Jun 2013 08:58:14 +0000 (08:58 +0000)]
Fix section-from-path > 1

When having found the first path separator occurrence at position i, we
invoked strchr() on the same position i in subsequent iterations
resulting in the same path separator being returned by strchr() over and
over again. Increase the position by one to skip the occurrence that has
just been found and advance to the next separator.

Reported-by: Konstantin Ryabitsev <mricon@kernel.org>
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoMakefile: Change default prefix to "/usr/local"
Lukas Fleischer [Tue, 18 Jun 2013 12:42:09 +0000 (12:42 +0000)]
Makefile: Change default prefix to "/usr/local"

Locally installed packages are usually installed to /usr/local.
Packagers can use `make prefix=/usr` to get back the old behavior.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoUse strbuf for reading configuration files
Lukas Fleischer [Tue, 4 Jun 2013 14:47:53 +0000 (14:47 +0000)]
Use strbuf for reading configuration files

Use struct strbuf from Git instead of fixed-size buffers to remove the
limit on the length of configuration file lines and refactor
read_config_line() to improve readability.

Note that this also fixes a buffer overflow that existed with the
original fixed-size buffer implementation.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoadd a note about generating agefile in hook
Christian Hesse [Mon, 22 Jul 2013 07:13:39 +0000 (09:13 +0200)]
add a note about generating agefile in hook

11 years agocache: id means static, even if head is specified too
Jason A. Donenfeld [Tue, 28 May 2013 14:43:02 +0000 (16:43 +0200)]
cache: id means static, even if head is specified too

Pages like /commit?h=wip&id=8a335ce618ba77fbf05148d6f8be17bd48ba4340
were being marked as dynamic, because of h=wip, when it should be
static, because of id=.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agocache: document negative ttls and add about ttl
Jason A. Donenfeld [Tue, 28 May 2013 14:33:30 +0000 (16:33 +0200)]
cache: document negative ttls and add about ttl

We've long supported negative ttls, for infinite cache, except the
documentation incorrectly showed one of our defaults as being 5 and not
-1. As well, with a negative ttl, we were actually making the HTTP
expired header go backwards. This changes it to go ahead ten years
instead.

Further, we add an cache-about-ttl option to set a different ttl for
about pages, which are now increasingly being filtered through markdown
or just sent statically anyway.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agorobots.txt: disallow access to snapshots
Jason A. Donenfeld [Tue, 28 May 2013 12:17:00 +0000 (14:17 +0200)]
robots.txt: disallow access to snapshots

My dmesg is filled with the oom killer bringing down processes while the
Bingbot downloads every snapshot for every commit of the Linux kernel in
tar.xz format. Sure, I should be running with memory limits, and now I'm
using cgroups, but a more general solution is to prevent crawlers from
wasting resources like that in the first place.

Suggested-by: Natanael Copa <ncopa@alpinelinux.org>
Suggested-by: Julius Plenz <plenz@cis.fu-berlin.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agouse favicon by default
Christian Hesse [Mon, 22 Jul 2013 06:56:50 +0000 (08:56 +0200)]
use favicon by default

11 years agoAdd favicon
Christian Hesse [Wed, 29 May 2013 08:16:06 +0000 (10:16 +0200)]
Add favicon

This adds a favicon to cgit. It is not enabled by default, though.
The file contains two icons, 16x16 and 32x32 pixels, optimized for size.

11 years agoui-summary: do not free ref
Jason A. Donenfeld [Tue, 28 May 2013 07:31:45 +0000 (09:31 +0200)]
ui-summary: do not free ref

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agofilters: toggle perl utf8 situation
Jason A. Donenfeld [Tue, 28 May 2013 05:55:40 +0000 (07:55 +0200)]
filters: toggle perl utf8 situation

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoCGIT-0.9.2 v0.9.2
Jason A. Donenfeld [Mon, 27 May 2013 20:00:13 +0000 (22:00 +0200)]
CGIT-0.9.2

Features:
- update to git v1.8.3.
- expanded set of default filters to include markdown, restructuredtext, and
  man pages.
- better sample configuration file in man page.
- "readme" may now be specified multiple times, and cgit will choose the first
  one it finds.
- "readme" no longer needs a branch name. If prefixed with simply ":" it will
  use the default branch.
- "branch-sort" allowing branches to be sorted either by "age" or "name", for
  kernel.org.
- "enable-index-owner" allowing the owner column to be disabled in the index
  page.
- print submodule revision next to submodule link.
- integrate more closely with git apis, such as strbuf.
- rely on git test harness and git makefiles.
- more robust test suite.
- more rebust makefile dependency accounting.
- pager navigation is now unordered list.
- span tag wraps commit directions.

Behavior changes:
- HOME is no longer passed as an environment variable to any filter api
  scripts.
- "about-filter" now receives the filename being filtered as argv[1]. This may
  disrupt existing scripts, so adjust accordingly.
- gitconfig and gitattributes are no longer loaded from any system directories
  or home directories.

Security:
- CVE-2013-2117: disallow directory traversal when readme is set to filesystem
  path.

Bug fixes:
- ssdiff now correctly manages tab expansion.
- support unannotated tags in http git clone.
- lots of cleanups of global variables and memory leaks.
- do not rely on gettext/libintl.
- better C standard compliance.
- make several functions and variables static.
- improved constification.
- remove unused functions.
- fix colspan values to correct width.
- fix out-of-bounds memory accesses with virtual_root="".
- cache repo config more precisely.
- die when write fails.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoREADME: add trailing slash to homepage
Jason A. Donenfeld [Mon, 27 May 2013 19:56:57 +0000 (21:56 +0200)]
README: add trailing slash to homepage

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agocgitrc.5: improve example config
Jason A. Donenfeld [Mon, 27 May 2013 19:47:02 +0000 (21:47 +0200)]
cgitrc.5: improve example config

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agofilters: import more modern scripts
Jason A. Donenfeld [Mon, 27 May 2013 19:39:43 +0000 (21:39 +0200)]
filters: import more modern scripts

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoreadme: use string_list instead of space deliminations
Jason A. Donenfeld [Sun, 26 May 2013 13:20:02 +0000 (15:20 +0200)]
readme: use string_list instead of space deliminations

Now this is possible in cgitrc -

readme=:README.md
readme=:readme.md
readme=:README.mkd
readme=:readme.mkd
readme=:README.rst
readme=:readme.rst
readme=:README.html
readme=:readme.html
readme=:README.htm
readme=:readme.htm
readme=:README.txt
readme=:readme.txt
readme=:README
readme=:readme
readme=:INSTALL.txt
readme=:install.txt
readme=:INSTALL
readme=:install

Suggested-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoui-summary: Disallow directory traversal
Jason A. Donenfeld [Sat, 25 May 2013 17:47:15 +0000 (19:47 +0200)]
ui-summary: Disallow directory traversal

Using the url= query string, it was possible request arbitrary files
from the filesystem if the readme for a given page was set to a
filesystem file. The following request would return my /etc/passwd file:

http://git.zx2c4.com/?url=/somerepo/about/../../../../etc/passwd
http://data.zx2c4.com/cgit-directory-traversal.png

This fix uses realpath(3) to canonicalize all paths, and then compares
the base components.

This fix introduces a subtle timing attack, whereby a client can check
whether or not strstr is called using timing measurements in order
to determine if a given file exists on the filesystem.

This fix also does not account for filesystem race conditions (TOCTOU)
in resolving symlinks.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agocgitrc.5: information on directory traversal and multiple readme files
Jason A. Donenfeld [Sat, 25 May 2013 18:30:57 +0000 (20:30 +0200)]
cgitrc.5: information on directory traversal and multiple readme files

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoreadme: Accept multiple candidates and test them.
Jason A. Donenfeld [Sat, 25 May 2013 14:32:37 +0000 (16:32 +0200)]
readme: Accept multiple candidates and test them.

The readme variable may now contain multiple space deliminated entries,
which per usual are either a filepath or a git ref filepath. If multiple
are specified, cgit will now select the first one in the list that
exists. This is to make it easier to specify multiple default readme
types in the main cgitrc file and have them automatically get applied to
each repo based on what exists.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoui-summary: Pass filename to about-filter
Jason A. Donenfeld [Sat, 25 May 2013 12:50:19 +0000 (14:50 +0200)]
ui-summary: Pass filename to about-filter

This gives the about-filter API the same semantics as source-filter,
where the filter receives the filename so it can decide what to do next
with it.

While we're at it, plug a memory leak.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoui-summary: Use default branch for readme if : prefix
Jason A. Donenfeld [Sat, 25 May 2013 12:19:10 +0000 (14:19 +0200)]
ui-summary: Use default branch for readme if : prefix

If the readme value begins with ":", and has no specified branch before
it, use the repository's default branch.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agocgit.c: Do not reset HOME after unsetting it.
Jason A. Donenfeld [Sat, 25 May 2013 17:25:56 +0000 (19:25 +0200)]
cgit.c: Do not reset HOME after unsetting it.

The number of odd cases in which git will try to read config is far too
great to keep putting a bandaid over each one, so we'll just unset it.

If it turns out that scripts really liked to know about $HOME, we can
always reset it in the filter forks.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agocgit.c: sync repo config printing with struct cgit_repo
Jason A. Donenfeld [Sat, 25 May 2013 12:05:06 +0000 (14:05 +0200)]
cgit.c: sync repo config printing with struct cgit_repo

We've now added quite a few config keys for repositories, but we've
forgotten to update the printing of it for cache files. Synchronize the
two.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agogit: update to 1.8.3
John Keeping [Sat, 25 May 2013 10:19:00 +0000 (11:19 +0100)]
git: update to 1.8.3

No changes required, just bump the submodule and Makefile versions.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agocache.c: cache ls_cache output properly
John Keeping [Sat, 18 May 2013 17:46:39 +0000 (18:46 +0100)]
cache.c: cache ls_cache output properly

By using the standard library's printf, cache_ls does not redirect its
output to the cache when we change the process' stdout file descriptor
to point to the cache file.  Fix this by using "htmlf" in the same way
that we do for writing HTTP headers.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agotests: introduce strip_header() helper function
John Keeping [Sat, 18 May 2013 17:46:38 +0000 (18:46 +0100)]
tests: introduce strip_header() helper function

This means that we can avoid hardcoding the number of headers we expect
CGit to generate in test cases and simply remove whatever headers happen
to by there when we are checking body content.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoshared.c: use die_errno() where appropriate
John Keeping [Sat, 18 May 2013 15:21:36 +0000 (16:21 +0100)]
shared.c: use die_errno() where appropriate

This replaces some code that is re-implementing die_errno by just
calling the function.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agohtml.c: die when write fails
John Keeping [Sat, 18 May 2013 14:57:03 +0000 (15:57 +0100)]
html.c: die when write fails

If we fail to write HTML output once, there's no point carrying on so
just write a failure message once and die.  By using Git's die_errno
function we also let the user know in what way the write failed.

Signed-off-by: John Keeping <john@keeping.me.uk>