]> granicus.if.org Git - cgit/log
cgit
8 years agoui: show ages in the originator's timezone
John Keeping [Tue, 19 Jan 2016 19:33:05 +0000 (19:33 +0000)]
ui: show ages in the originator's timezone

This affects the tooltip showing the full time and the case when a date
is sufficiently old to be shown in full rather than as an offset.

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoui-{commit,tag}: show dates in originator's timezone
John Keeping [Tue, 19 Jan 2016 19:33:04 +0000 (19:33 +0000)]
ui-{commit,tag}: show dates in originator's timezone

This is done by switching to Git's show_date() function and the mode
given by cgit_date_mode().

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoui-shared: add cgit_date_mode()
John Keeping [Tue, 19 Jan 2016 19:33:03 +0000 (19:33 +0000)]
ui-shared: add cgit_date_mode()

This returns the correct mode value for use with Git's show_date() based
on the current CGit configuration and will be used in the following
patches.

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoparsing: add timezone to ident structures
John Keeping [Tue, 19 Jan 2016 19:33:02 +0000 (19:33 +0000)]
parsing: add timezone to ident structures

This will allow us to mimic Git's behaviour of showing times in the
originator's timezone when displaying commits and tags.

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoui-shared: remove "format" from cgit_print_age()
John Keeping [Tue, 19 Jan 2016 19:33:01 +0000 (19:33 +0000)]
ui-shared: remove "format" from cgit_print_age()

We never use any format other than FMT_SHORTDATE, so move that into the
function.

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoui-tree: put reverse path in title
Jason A. Donenfeld [Mon, 18 Jan 2016 14:56:45 +0000 (15:56 +0100)]
ui-tree: put reverse path in title

8 years agosyntax-highlighting: always use utf-8 to avoid ascii codec issues
Jason A. Donenfeld [Mon, 18 Jan 2016 10:14:06 +0000 (11:14 +0100)]
syntax-highlighting: always use utf-8 to avoid ascii codec issues

8 years agocache: don't check for match with no key
John Keeping [Sat, 16 Jan 2016 11:03:07 +0000 (11:03 +0000)]
cache: don't check for match with no key

We call open_slot() from cache_ls() without a key since we simply want
to read the path out of the header.  Should the file happen to contain
an empty key then we end up calling memcmp() with NULL and a non-zero
length.  Fix this by assigning slot->match only if a key is set, which
is always will be in the code paths where we use slot->match.

Coverity-id: 13807
Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agocache: use size_t for string lengths
John Keeping [Sat, 16 Jan 2016 11:03:06 +0000 (11:03 +0000)]
cache: use size_t for string lengths

Avoid integer truncation on 64-bit systems.

Coverity-id: 13864
Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoui-log: handle parse_commit() errors
John Keeping [Sat, 16 Jan 2016 11:03:05 +0000 (11:03 +0000)]
ui-log: handle parse_commit() errors

If parse_commit() fails, none of the fields in the commit structure will
have been populated so we will dereference NULL when accessing
item->tree.

There isn't much we can do about the error at this point, but if we
return true then we'll try parsing the commit again from print_commit()
and we can report an error to the user at that point.

Coverity-id: 13801
Signed-off-by: John Keeping <john@keeping.me.uk>
8 years agoBump version v0.12
Jason A. Donenfeld [Thu, 14 Jan 2016 14:43:54 +0000 (15:43 +0100)]
Bump version

8 years agoui-plain: add enable-html-serving flag
Jason A. Donenfeld [Thu, 14 Jan 2016 13:53:28 +0000 (14:53 +0100)]
ui-plain: add enable-html-serving flag

Unrestricts plain/ to contents likely to be executed by browser.

8 years agoui-blob: set CSP just in case
Jason A. Donenfeld [Thu, 14 Jan 2016 13:43:43 +0000 (14:43 +0100)]
ui-blob: set CSP just in case

8 years agoui-blob: always use generic mimetypes
Jason A. Donenfeld [Thu, 14 Jan 2016 13:31:53 +0000 (14:31 +0100)]
ui-blob: always use generic mimetypes

8 years agoui-blob: Do not accept mimetype from user
Jason A. Donenfeld [Thu, 14 Jan 2016 13:31:13 +0000 (14:31 +0100)]
ui-blob: Do not accept mimetype from user

8 years agoui-shared: prevent malicious filename from injecting headers
Jason A. Donenfeld [Thu, 14 Jan 2016 13:28:37 +0000 (14:28 +0100)]
ui-shared: prevent malicious filename from injecting headers

8 years agoui-shared: Avoid new line injection into redirect header
Jason A. Donenfeld [Thu, 14 Jan 2016 13:13:39 +0000 (14:13 +0100)]
ui-shared: Avoid new line injection into redirect header

8 years agoFix missing prototype declarations
Peter Colberg [Wed, 13 Jan 2016 22:25:07 +0000 (17:25 -0500)]
Fix missing prototype declarations

Signed-off-by: Peter Colberg <peter@colberg.org>
8 years agoui-repolist: return HTTP 404 if no repositories found
Peter Colberg [Tue, 8 Dec 2015 17:53:09 +0000 (12:53 -0500)]
ui-repolist: return HTTP 404 if no repositories found

Return HTTP status code 404 Not found when querying a non-existent
repository, which signals to search engines that a repository no
longer exists. Further, some webservers such as nginx permit
logging requests to different files depending on the HTTP code.

Signed-off-by: Peter Colberg <peter@colberg.org>
8 years agoui-repolist: extract repo visibility criteria to separate function
Peter Colberg [Tue, 8 Dec 2015 17:53:08 +0000 (12:53 -0500)]
ui-repolist: extract repo visibility criteria to separate function

Signed-off-by: Peter Colberg <peter@colberg.org>
8 years agoFix segmentation fault in hc()
Lukas Fleischer [Sun, 13 Dec 2015 00:27:13 +0000 (01:27 +0100)]
Fix segmentation fault in hc()

The ctx.qry.page variable might be unset at this point, e.g. when an
invalid command is passed and cgit_print_pageheader() is called to show
an error message.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
8 years agogit: update to v2.7.0
Christian Hesse [Tue, 5 Jan 2016 06:38:53 +0000 (07:38 +0100)]
git: update to v2.7.0

Update to git version v2.7.0.

* Upstream commit ed1c9977cb1b63e4270ad8bdf967a2d02580aa08 (Remove
  get_object_hash.) changed API:

  Convert all instances of get_object_hash to use an appropriate
  reference to the hash member of the oid member of struct object.
  This provides no functional change, as it is essentially a macro
  substitution.

Signed-off-by: Christian Hesse <mail@eworm.de>
8 years agoui-repolist: initialize char *buf to NULL
Christian Hesse [Tue, 12 Jan 2016 23:45:03 +0000 (00:45 +0100)]
ui-repolist: initialize char *buf to NULL

readfile() can fail if the agefile is not readable. Make sure free()
does not free an ininitialized string.

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agofilter: avoid integer overflow in authenticate_post
Jason A. Donenfeld [Tue, 24 Nov 2015 10:28:00 +0000 (11:28 +0100)]
filter: avoid integer overflow in authenticate_post

ctx.env.content_length is an unsigned int, coming from the
CONTENT_LENGTH environment variable, which is parsed by strtoul. The
HTTP/1.1 spec says that "any Content-Length greater than or equal to
zero is a valid value." By storing this into an int, we potentially
overflow it, resulting in the following bounding check failing, leading
to a buffer overflow.

Reported-by: Erik Cabetas <Erik@cabetas.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agoabout-formatting.sh: comment text out of date
Jason A. Donenfeld [Thu, 12 Nov 2015 03:44:32 +0000 (04:44 +0100)]
about-formatting.sh: comment text out of date

9 years agofilters: port syntax-highlighting.py to python 3.x
Christian Hesse [Mon, 12 Oct 2015 16:23:56 +0000 (18:23 +0200)]
filters: port syntax-highlighting.py to python 3.x

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agomd2html: the default of stdin works fine
Jason A. Donenfeld [Mon, 12 Oct 2015 16:33:21 +0000 (18:33 +0200)]
md2html: the default of stdin works fine

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agofilters: misc cleanups
Jason A. Donenfeld [Mon, 12 Oct 2015 14:47:47 +0000 (16:47 +0200)]
filters: misc cleanups

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agomd2html: use pure python
Jason A. Donenfeld [Mon, 12 Oct 2015 14:42:48 +0000 (16:42 +0200)]
md2html: use pure python

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agocache: fix resource leak: close file handle before return
Christian Hesse [Sat, 10 Oct 2015 14:56:28 +0000 (16:56 +0200)]
cache: fix resource leak: close file handle before return

Coverity-id: 13910
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-atom: fix resource leak: free allocation from cgit_pageurl
Christian Hesse [Sat, 10 Oct 2015 14:56:27 +0000 (16:56 +0200)]
ui-atom: fix resource leak: free allocation from cgit_pageurl

Coverity-id: 13945
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-atom: fix resource leak: free before return
Christian Hesse [Sat, 10 Oct 2015 14:56:26 +0000 (16:56 +0200)]
ui-atom: fix resource leak: free before return

Coverity-id: 13946
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-atom: fix resource leak: free allocation from cgit_repourl
Christian Hesse [Sat, 10 Oct 2015 14:56:25 +0000 (16:56 +0200)]
ui-atom: fix resource leak: free allocation from cgit_repourl

Coverity-id: 13947
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-blob: fix resource leak: free before return
Christian Hesse [Sat, 10 Oct 2015 14:56:23 +0000 (16:56 +0200)]
ui-blob: fix resource leak: free before return

Coverity-id: 13944
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-blob: fix resource leak: free before return
Christian Hesse [Sat, 10 Oct 2015 14:56:24 +0000 (16:56 +0200)]
ui-blob: fix resource leak: free before return

Coverity-id: 13943
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-plain: fix resource leak: free before assigning NULL
Christian Hesse [Fri, 9 Oct 2015 12:55:50 +0000 (14:55 +0200)]
ui-plain: fix resource leak: free before assigning NULL

Coverity-id: 13939
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-plain: fix resource leak: free before return
Christian Hesse [Fri, 9 Oct 2015 12:55:49 +0000 (14:55 +0200)]
ui-plain: fix resource leak: free before return

Coverity-id: 13940
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-repolist: fix resource leak: free allocation from cgit_currenturl
Christian Hesse [Fri, 9 Oct 2015 12:55:48 +0000 (14:55 +0200)]
ui-repolist: fix resource leak: free allocation from cgit_currenturl

Coverity-id: 13930
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-repolist: fix resource leak: free before return
Christian Hesse [Fri, 9 Oct 2015 12:55:47 +0000 (14:55 +0200)]
ui-repolist: fix resource leak: free before return

Coverity-id: 13931
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agofilters: Simplify converters
Jason A. Donenfeld [Fri, 9 Oct 2015 13:13:35 +0000 (15:13 +0200)]
filters: Simplify converters

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agoui-shared: fix resource leak: free allocation from cgit_hosturl
Christian Hesse [Fri, 9 Oct 2015 11:15:51 +0000 (13:15 +0200)]
ui-shared: fix resource leak: free allocation from cgit_hosturl

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-shared: return value of cgit_hosturl is not const
Christian Hesse [Fri, 9 Oct 2015 11:15:50 +0000 (13:15 +0200)]
ui-shared: return value of cgit_hosturl is not const

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agocmd: fix resource leak: free allocation from cgit_currenturl and fmtalloc
Christian Hesse [Fri, 9 Oct 2015 11:15:49 +0000 (13:15 +0200)]
cmd: fix resource leak: free allocation from cgit_currenturl and fmtalloc

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-shared: fix resource leak: free allocation from cgit_currenturl
Christian Hesse [Fri, 9 Oct 2015 11:15:48 +0000 (13:15 +0200)]
ui-shared: fix resource leak: free allocation from cgit_currenturl

Coverity-id: 13927
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-shared: return value of cgit_currenturl is not const
Christian Hesse [Fri, 9 Oct 2015 11:15:47 +0000 (13:15 +0200)]
ui-shared: return value of cgit_currenturl is not const

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-shared: fix resource leak: free allocation from cgit_fileurl
Christian Hesse [Fri, 9 Oct 2015 11:15:46 +0000 (13:15 +0200)]
ui-shared: fix resource leak: free allocation from cgit_fileurl

Coverity-id: 13918
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-ssdiff: fix resource leak: free allocation from cgit_fileurl
Christian Hesse [Fri, 9 Oct 2015 11:15:45 +0000 (13:15 +0200)]
ui-ssdiff: fix resource leak: free allocation from cgit_fileurl

Coverity-id: 13929
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoui-tree: fix resource leak: free before return
Christian Hesse [Fri, 9 Oct 2015 11:15:44 +0000 (13:15 +0200)]
ui-tree: fix resource leak: free before return

Coverity-id: 13938
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agoAvoid use of non-reentrant functions
Jason A. Donenfeld [Fri, 9 Oct 2015 09:01:04 +0000 (11:01 +0200)]
Avoid use of non-reentrant functions

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agoMakefile: fix MAKEFLAGS tests with multiple flags
John Keeping [Sat, 5 Sep 2015 13:32:50 +0000 (14:32 +0100)]
Makefile: fix MAKEFLAGS tests with multiple flags

findstring is defined as $(findstring FIND,IN) so if multiple flags are
set these tests do the wrong thing unless $(MAKEFLAGS) is the second
argument.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoui-refs: remove useless null check
John Keeping [Thu, 8 Oct 2015 22:23:59 +0000 (23:23 +0100)]
ui-refs: remove useless null check

There is no way that "tag" can be null here.

Coverity-id: 13950
Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoui-blob: remove useless null check
John Keeping [Thu, 8 Oct 2015 22:23:58 +0000 (23:23 +0100)]
ui-blob: remove useless null check

We have already called strlen() on "path" by the time we get here, so we
know it can't be null.

Coverity-id: 13954
Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoscan-tree: remove useless strdup()
John Keeping [Thu, 8 Oct 2015 22:23:57 +0000 (23:23 +0100)]
scan-tree: remove useless strdup()

parse_configfile() takes a "const char *" and doesn't hold any
references to it after it returns; there is no reason to pass it a
duplicate.

Coverity-id: 13941
Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agocgit.c: remove useless null check
John Keeping [Thu, 8 Oct 2015 22:23:56 +0000 (23:23 +0100)]
cgit.c: remove useless null check

Everywhere else in this function we do not check whether the value is
null and parse_configfile() never passes a null value to this callback.

Coverity-id: 13846
Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agogit: update to v2.6.1
Christian Hesse [Tue, 6 Oct 2015 05:36:40 +0000 (07:36 +0200)]
git: update to v2.6.1

Update to git version v2.6.1, no changes required.

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agomime: rewrite detection function
Jason A. Donenfeld [Mon, 17 Aug 2015 12:35:20 +0000 (14:35 +0200)]
mime: rewrite detection function

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agoui-summary: send images plain for about page
Christian Hesse [Sun, 16 Aug 2015 12:53:53 +0000 (14:53 +0200)]
ui-summary: send images plain for about page

The about page used to display just fine, but images were broken: The
binary image data was embedded in html code.
Use cgit_print_plain() to send images in plain mode and make them
available on about page.

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agorefactor get_mimetype_from_file() to get_mimetype_for_filename()
Christian Hesse [Sun, 16 Aug 2015 12:53:52 +0000 (14:53 +0200)]
refactor get_mimetype_from_file() to get_mimetype_for_filename()

* handle mimetype within a single function
* return allocated memory on success

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agomove get_mimetype_from_file() to shared
Christian Hesse [Fri, 14 Aug 2015 14:50:56 +0000 (16:50 +0200)]
move get_mimetype_from_file() to shared

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years agocmd: fix command definition
John Keeping [Fri, 14 Aug 2015 14:20:23 +0000 (15:20 +0100)]
cmd: fix command definition

The previous commit removed the "pre" field from "struct cgit_cmd" but
forgot to update this macro.

Signed-off-by: John Keeping <john@keeping.me.uk>
Reviewed-by: Christian Hesse <mail@eworm.de>
9 years agocmd: no need for pre function hook now
Jason A. Donenfeld [Fri, 14 Aug 2015 13:54:32 +0000 (15:54 +0200)]
cmd: no need for pre function hook now

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
9 years agoui-shared: cache errors for "dynamic TTL"
John Keeping [Fri, 14 Aug 2015 11:47:22 +0000 (12:47 +0100)]
ui-shared: cache errors for "dynamic TTL"

Most errors we generate are (potentially) transient, such as
non-existent object IDs so we don't want them to be cached forever.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agocmd: remove "want_layout" field
John Keeping [Fri, 14 Aug 2015 11:47:21 +0000 (12:47 +0100)]
cmd: remove "want_layout" field

No commands use this any more.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agotree: move layout into page function
John Keeping [Fri, 14 Aug 2015 11:47:20 +0000 (12:47 +0100)]
tree: move layout into page function

This also allows us to return proper HTTP error codes when the requested
tree is not found and display an error message in one case (invalid path
inside valid commit) where we previously just displayed an empty page.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agotag: move layout into page function
John Keeping [Fri, 14 Aug 2015 11:47:19 +0000 (12:47 +0100)]
tag: move layout into page function

This also allows us to return proper HTTP error codes when something
goes wrong.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agosummary: move layout into page function
John Keeping [Fri, 14 Aug 2015 11:47:18 +0000 (12:47 +0100)]
summary: move layout into page function

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agostats: move layout into page function
John Keeping [Fri, 14 Aug 2015 11:47:17 +0000 (12:47 +0100)]
stats: move layout into page function

This also allows us to return proper HTTP error codes for invalid
requests.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agorefs: move layout to page function
John Keeping [Fri, 14 Aug 2015 11:47:16 +0000 (12:47 +0100)]
refs: move layout to page function

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agolog: move layout into page function
John Keeping [Fri, 14 Aug 2015 11:47:15 +0000 (12:47 +0100)]
log: move layout into page function

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agodiff: move layout to page function
John Keeping [Fri, 14 Aug 2015 11:47:14 +0000 (12:47 +0100)]
diff: move layout to page function

The existing "show_ctrls" flag is used to control whether we are running
in an existing page or control the page ourselves.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agocommit: move layout into page function
John Keeping [Fri, 14 Aug 2015 11:47:13 +0000 (12:47 +0100)]
commit: move layout into page function

This allows us to return a proper HTTP status code when an object is not
found by switching from cgit_print_error() to cgit_print_error_page().

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoabout: move layout into page functions
John Keeping [Fri, 14 Aug 2015 11:47:12 +0000 (12:47 +0100)]
about: move layout into page functions

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoui-shared: add cgit_print_layout_{start,end}()
John Keeping [Fri, 14 Aug 2015 11:47:11 +0000 (12:47 +0100)]
ui-shared: add cgit_print_layout_{start,end}()

These will avoid needing to call three functions to start page layout in
subsequent patches when we move the layout setup into each individual
page.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agohtml: remove html_status()
John Keeping [Fri, 14 Aug 2015 11:47:10 +0000 (12:47 +0100)]
html: remove html_status()

This is now unused.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agosnapshot: don't reimplement cgit_print_error_page()
John Keeping [Fri, 14 Aug 2015 11:47:09 +0000 (12:47 +0100)]
snapshot: don't reimplement cgit_print_error_page()

cgit_print_error_page() has the advantage that it sets a suitable HTTP
status code for the response.  Note that setting "mimetype" is redundant
here since it cannot have changed since being initialized in
cgit.c::prepare_context(), so we do not need to worry that
cgit_print_error_page() does not set it.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agosnapshot: use cgit_print_error_page() for HTTP status codes
John Keeping [Fri, 14 Aug 2015 11:47:08 +0000 (12:47 +0100)]
snapshot: use cgit_print_error_page() for HTTP status codes

This is a bugfix as well as an improvement to the HTTP status code
handling since previously we would not print HTTP headers on any of
these code paths.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agopatch: use cgit_print_error_page() for HTTP status codes
John Keeping [Fri, 14 Aug 2015 11:47:07 +0000 (12:47 +0100)]
patch: use cgit_print_error_page() for HTTP status codes

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoblob: use cgit_print_error_page() to add HTTP headers
John Keeping [Fri, 14 Aug 2015 11:47:06 +0000 (12:47 +0100)]
blob: use cgit_print_error_page() to add HTTP headers

This is a bugfix as well as an improvement to the HTTP status code
handling since previously we would not print HTTP headers on any of
these code paths.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agosnapshot: use cgit_print_error_page() instead of html_status()
John Keeping [Fri, 14 Aug 2015 11:47:05 +0000 (12:47 +0100)]
snapshot: use cgit_print_error_page() instead of html_status()

This provides a formatted error response rather than a simple HTTP
error.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoplain: use cgit_print_error_page() instead of html_status()
John Keeping [Fri, 14 Aug 2015 11:47:04 +0000 (12:47 +0100)]
plain: use cgit_print_error_page() instead of html_status()

This provides a formatted error response rather than a simple HTTP
error.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoclone: use cgit_print_error_page() instead of html_status()
John Keeping [Fri, 14 Aug 2015 11:47:03 +0000 (12:47 +0100)]
clone: use cgit_print_error_page() instead of html_status()

This provides a formatted error response rather than a simple HTTP
error.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agocgit: use cgit_print_error_page() where appropriate
John Keeping [Fri, 14 Aug 2015 11:47:02 +0000 (12:47 +0100)]
cgit: use cgit_print_error_page() where appropriate

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>
9 years agoui-shared: add cgit_print_error_page() function
John Keeping [Fri, 14 Aug 2015 11:47:01 +0000 (12:47 +0100)]
ui-shared: add cgit_print_error_page() function

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>
9 years agoui-patch: make sure to send http headers
Christian Hesse [Thu, 13 Aug 2015 22:02:50 +0000 (00:02 +0200)]
ui-patch: make sure to send http headers

Requesting a text/plain patch with bad commit id made cgit send text
without proper http headers. This results in "500 Internal Server Error"
with "Premature end of script headers" in server logs.
So print http headers before error message and return.

Signed-off-by: Christian Hesse <mail@eworm.de>
Reviewed-by: John Keeping <john@keeping.me.uk>
9 years agoMakefile: make "git/config.mak.uname" inclusion optional
John Keeping [Thu, 13 Aug 2015 14:54:37 +0000 (15:54 +0100)]
Makefile: make "git/config.mak.uname" inclusion optional

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>
9 years agoui-shared: show full date in tooltip if longer ago than max_relative
John Keeping [Thu, 13 Aug 2015 11:24:34 +0000 (12:24 +0100)]
ui-shared: show full date in tooltip if longer ago than max_relative

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>
9 years agoui-shared: use common function in print_rel_date()
John Keeping [Thu, 13 Aug 2015 11:24:33 +0000 (12:24 +0100)]
ui-shared: use common function in print_rel_date()

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agoui-shared: extract date formatting to a function
John Keeping [Thu, 13 Aug 2015 11:24:32 +0000 (12:24 +0100)]
ui-shared: extract date formatting to a function

This will allow this code to be common with print_rel_date.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agofilter: don't use dlsym unnecessarily
John Keeping [Thu, 13 Aug 2015 11:14:20 +0000 (12:14 +0100)]
filter: don't use dlsym unnecessarily

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>
9 years agoui-tree: use "sane" isgraph()
John Keeping [Thu, 13 Aug 2015 11:14:19 +0000 (12:14 +0100)]
ui-tree: use "sane" isgraph()

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>
9 years agocgit.h: move stdbool.h from ui-shared.h
John Keeping [Thu, 13 Aug 2015 11:14:18 +0000 (12:14 +0100)]
cgit.h: move stdbool.h from ui-shared.h

Follow the Git policy of including system headers in only one place.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agocache.c: fix header order
John Keeping [Thu, 13 Aug 2015 11:14:17 +0000 (12:14 +0100)]
cache.c: fix header order

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>
9 years agoconfigfile.c: don't include system headers directly
John Keeping [Thu, 13 Aug 2015 11:14:16 +0000 (12:14 +0100)]
configfile.c: don't include system headers directly

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>
9 years agoRemove redundant includes
John Keeping [Thu, 13 Aug 2015 11:14:15 +0000 (12:14 +0100)]
Remove redundant includes

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>
9 years agoMakefile: include Git's config.mak.uname
John Keeping [Thu, 13 Aug 2015 11:14:14 +0000 (12:14 +0100)]
Makefile: include Git's config.mak.uname

This pulls in the correct value of $(INSTALL) on a wide variety of
systems.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agotests: allow shell to be overridden
John Keeping [Thu, 13 Aug 2015 11:14:13 +0000 (12:14 +0100)]
tests: allow shell to be overridden

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>
9 years agoredirect: cleanliness
Jason A. Donenfeld [Thu, 13 Aug 2015 09:38:56 +0000 (11:38 +0200)]
redirect: cleanliness

9 years agoredirect: be more careful for different cgi setups
Jason A. Donenfeld [Thu, 13 Aug 2015 09:38:27 +0000 (11:38 +0200)]
redirect: be more careful for different cgi setups

9 years agoui-log: fix double counting
John Keeping [Wed, 12 Aug 2015 15:41:34 +0000 (16:41 +0100)]
ui-log: fix double counting

This crept in while rebasing the previous commit onto an updated
upstream.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years agolog: allow users to follow a file
John Keeping [Wed, 12 Aug 2015 14:55:28 +0000 (15:55 +0100)]
log: allow users to follow a file

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>