]> granicus.if.org Git - cgit/log
cgit
10 years agogen-version.sh: check if git is available before trying to call it
Fabien C [Sat, 1 Feb 2014 15:07:46 +0000 (16:07 +0100)]
gen-version.sh: check if git is available before trying to call it

Some people may clone the cgit repository and compile within a sandbox
or on another machine where git is not necessarily installed. When it
happens, cgit is getting compiled with an empty version number.

This commit fixes this.

10 years agosimple-authentication: style
Jason A. Donenfeld [Wed, 22 Jan 2014 23:58:07 +0000 (00:58 +0100)]
simple-authentication: style

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agomakefile: use LUA_PKGCONFIG to set Lua implementation
Natanael Copa [Wed, 22 Jan 2014 12:15:08 +0000 (13:15 +0100)]
makefile: use LUA_PKGCONFIG to set Lua implementation

This breaks compat with the previous LUA_IMPLEMENTATION but gives more
flexibility in that user can specify the pkg-config package name
directly.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
10 years agotests: only do lua tests if lua is compiled-in
Jason A. Donenfeld [Mon, 20 Jan 2014 12:11:10 +0000 (13:11 +0100)]
tests: only do lua tests if lua is compiled-in

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agocgit: add --version argument for printing info
Jason A. Donenfeld [Mon, 20 Jan 2014 12:05:08 +0000 (13:05 +0100)]
cgit: add --version argument for printing info

We need this to do runtime tests for make test.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agocache: use sendfile() instead of a pair of read() + write()
Sebastian Andrzej Siewior [Sat, 18 Jan 2014 20:24:58 +0000 (21:24 +0100)]
cache: use sendfile() instead of a pair of read() + write()

sendfile() does the same job and avoids to copy the content into userland
and back. One has to define NO_SENDFILE in case the OS (kernel / libc)
does not supported. It is disabled by default on non-linux environemnts.
According to the glibc, sendfile64() was added in Linux 2.4 (so it has
been there for a while) but after browsing over the mapage of FreeBSD's I
noticed that the prototype is little different.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
10 years agoREADME: document pkg-config for luajit
Jason A. Donenfeld [Fri, 17 Jan 2014 23:45:01 +0000 (00:45 +0100)]
README: document pkg-config for luajit

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agomakefile: bump version v0.10
Jason A. Donenfeld [Fri, 17 Jan 2014 15:09:16 +0000 (16:09 +0100)]
makefile: bump version

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agomailmap: source before lighttpd
Jason A. Donenfeld [Fri, 17 Jan 2014 15:04:12 +0000 (16:04 +0100)]
mailmap: source before lighttpd

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoui-shared: do not allow negative minutes
Jason A. Donenfeld [Fri, 17 Jan 2014 14:41:41 +0000 (15:41 +0100)]
ui-shared: do not allow negative minutes

Do to timestamp differences, sometimes cgit would should "-0 min", which
doesn't make any sense.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoauth: document tweakables in lua script
Jason A. Donenfeld [Fri, 17 Jan 2014 14:34:44 +0000 (15:34 +0100)]
auth: document tweakables in lua script

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agorepolist: make owner clickable to search
Jason A. Donenfeld [Thu, 16 Jan 2014 21:54:23 +0000 (22:54 +0100)]
repolist: make owner clickable to search

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoui-shared: move about tab all the way to the left
Jason A. Donenfeld [Fri, 17 Jan 2014 12:53:37 +0000 (13:53 +0100)]
ui-shared: move about tab all the way to the left

There were no objections (at the time of committing this):
   http://lists.zx2c4.com/pipermail/cgit/2013-May/001393.html
   http://lists.zx2c4.com/pipermail/cgit/2014-January/001904.html

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: don't forget to reap the auth filter
Jason A. Donenfeld [Fri, 17 Jan 2014 12:53:02 +0000 (13:53 +0100)]
filter: don't forget to reap the auth filter

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agocgit.c: free tmp variable
Jason A. Donenfeld [Thu, 16 Jan 2014 23:48:17 +0000 (00:48 +0100)]
cgit.c: free tmp variable

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoSwitch to exclusively using global ctx
Lukas Fleischer [Wed, 15 Jan 2014 20:53:15 +0000 (21:53 +0100)]
Switch to exclusively using global ctx

Drop the context parameter from the following functions (and all static
helpers used by them) and use the global context instead:

* cgit_print_http_headers()
* cgit_print_docstart()
* cgit_print_pageheader()

Remove context parameter from all commands

Drop the context parameter from the following functions (and all static
helpers used by them) and use the global context instead:

* cgit_get_cmd()
* All cgit command functions.
* cgit_clone_info()
* cgit_clone_objects()
* cgit_clone_head()
* cgit_print_plain()
* cgit_show_stats()

In initialization routines, use the global context variable instead of
passing a pointer around locally.

Remove callback data parameter for cache slots

This is no longer needed since the context is always read from the
global context variable.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoauth: have cgit calculate login address
Jason A. Donenfeld [Thu, 16 Jan 2014 22:21:54 +0000 (23:21 +0100)]
auth: have cgit calculate login address

This way we're sure to use virtual root, or any other strangeness
encountered.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoauth: lua string comparisons are time invariant
Jason A. Donenfeld [Thu, 16 Jan 2014 18:47:35 +0000 (19:47 +0100)]
auth: lua string comparisons are time invariant

By default, strings are compared by hash, so we can remove this comment.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoauthentication: use hidden form instead of referer
Jason A. Donenfeld [Thu, 16 Jan 2014 10:39:17 +0000 (11:39 +0100)]
authentication: use hidden form instead of referer

This also gives us some CSRF protection. Note that we make use of the
hmac to protect the redirect value.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agoauth: add basic authentication filter framework
Jason A. Donenfeld [Tue, 14 Jan 2014 20:49:31 +0000 (21:49 +0100)]
auth: add basic authentication filter framework

This leverages the new lua support. See
filters/simple-authentication.lua for explaination of how this works.
There is also additional documentation in cgitrc.5.txt.

Though this is a cookie-based approach, cgit's caching mechanism is
preserved for authenticated pages.

Very plugable and extendable depending on user needs.

The sample script uses an HMAC-SHA1 based cookie to store the
currently logged in user, with an expiration date.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agot0111: Additions and fixes
Lukas Fleischer [Wed, 15 Jan 2014 22:11:19 +0000 (23:11 +0100)]
t0111: Additions and fixes

* Rename the capitalize-* filters to dump.* since they also dump the
  arguments.

* Add full argument validation to the email filters.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoparsing.c: Remove leading space from committer
Lukas Fleischer [Wed, 15 Jan 2014 22:09:08 +0000 (23:09 +0100)]
parsing.c: Remove leading space from committer

This did not really break anything in the past since spaces are ignored
when rendering HTML. Remove the preceding space anyway to prevent from
potential future problems.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoAdd .mailmap
Lukas Fleischer [Tue, 14 Jan 2014 20:35:00 +0000 (21:35 +0100)]
Add .mailmap

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agot0111: Add basic tests for Lua filters
Lukas Fleischer [Tue, 14 Jan 2014 21:25:45 +0000 (22:25 +0100)]
t0111: Add basic tests for Lua filters

* Validate the email filter by manipulating stdin. Additional checks for
  all the arguments can be added in a later patch.

* Add the exec prefix to all informational messages.

* Rename the filter repository to filter-exec. The Git repository itself
  is not renamed since it can be shared amongst all filter types.

* In the filter checks, check whether all arguments are passed properly
  instead of validating the buffer/stdin only.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoemail-gravatar: fix html syntax issues
Christian Hesse [Wed, 15 Jan 2014 12:39:54 +0000 (13:39 +0100)]
email-gravatar: fix html syntax issues

an attribute value specification must be an attribute value literal
unless SHORTTAG YES is specified

10 years agoemail-gravatar: do not scale icons up
Jason A. Donenfeld [Tue, 14 Jan 2014 17:57:36 +0000 (18:57 +0100)]
email-gravatar: do not scale icons up

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agofilter: allow returning exit code from filter
Jason A. Donenfeld [Tue, 14 Jan 2014 17:07:23 +0000 (18:07 +0100)]
filter: allow returning exit code from filter

Filters can now indicate a status back to cgit by means of the exit code
for exec, or the return value from close for Lua.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years agotests/: Add t0111-filter.sh
Lukas Fleischer [Tue, 14 Jan 2014 11:01:06 +0000 (12:01 +0100)]
tests/: Add t0111-filter.sh

This adds basic tests for all types of exec filters.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years agoemail-gravatar: fix html syntax issues
Christian Hesse [Tue, 14 Jan 2014 11:01:58 +0000 (12:01 +0100)]
email-gravatar: fix html syntax issues

* make ampersand a html entity
* add required alt attribute
* add required img end tag

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>