Commit Graph

263 Commits (11695a58fd732689be486edf88d145578a787c89)

Author SHA1 Message Date
Christian Hesse 11695a58fd git: update to v2.10.0
Upstream continues to replace unsigned char *sha1 with struct
object_id old_oid. This makes the required changes.

The git lib has its own main function now. Rename our main function
to cmd_main, it is called from main then.
8 years ago
Jason A. Donenfeld 5f2664f13c ui-shared: add homepage to tabs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
8 years ago
John Keeping 75298209bf ui-atom: avoid DATE_STRFTIME
Git's DATE_STRFTIME ignores the timezone argument and just uses the
local timezone regardless of whether the "local" flag is set.

Since Atom accepts ISO8601 dates [1], we can use Git's
DATE_ISO8601_STRICT instead, which does get this right.  Additionally,
we never use the local timezone here so we can use the
date_mode_from_type() wrapper to simplify the code a bit.

[1] https://tools.ietf.org/html/rfc4287#section-3.3

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years ago
John Keeping 9c15f3c695 Avoid DATE_STRFTIME for long/short dates
Git's DATE_STRFTIME ignores the timezone argument and just uses the
local timezone regardless of whether the "local" flag is set.

Since our existing FMT_LONGDATE and FMT_SHORTDATE are pretty-much
perfect matches to DATE_ISO8601 and DATE_SHORT, switch to taking a
date_mode_type directly in cgit_date_mode().

Signed-off-by: John Keeping <john@keeping.me.uk>
8 years ago
John Keeping 45c87ca1c3 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 ago
Jason A. Donenfeld c326f3eb02 ui-plain: add enable-html-serving flag
Unrestricts plain/ to contents likely to be executed by browser.
8 years ago
Jason A. Donenfeld 1c581a0726 ui-blob: Do not accept mimetype from user 8 years ago
Christian Hesse aa943bc9a6 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 ago
Christian Hesse f5c83d7b5d move get_mimetype_from_file() to shared
Signed-off-by: Christian Hesse <mail@eworm.de>
9 years ago
John Keeping 7105a78b17 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 ago
John Keeping e09574bdf6 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 ago
John Keeping 30304d8156 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>
9 years ago
John Keeping 044e2d26da shared: make cgit_diff_tree_cb public
This will allow us to use this nice wrapper function elsewhere, avoiding
dealing with the diff queue when we only need to inspect a filepair.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
Christian Hesse de83de276b git: update to v2.5.0
Update to git version v2.5.0.

* Upstream commit 5455ee0573a22bb793a7083d593ae1ace909cd4c (Merge branch
  'bc/object-id') changed API:

  for_each_ref() callback functions were taught to name the objects
  not with "unsigned char sha1[20]" but with "struct object_id".

* Upstream commit dcf692625ac569fefbe52269061230f4fde10e47 (path.c: make
  get_pathname() call sites return const char *)

Signed-off-by: Christian Hesse <mail@eworm.de>
9 years ago
Lukas Fleischer c58cec9dff Add repo.hide and repo.ignore
These options can be used to hide a repository from the index or
completely ignore a repository, respectively. They are particularly
useful when used in combination with scan-path.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
9 years ago
Chris Burroughs 96ceb9a95a repolist: add owner-filter
This allows custom links to be used for repository owners by
configuring a filter to be applied in the "Owner" column in the
repository list.
10 years ago
John Keeping ddfaef6bb2 ui-diff: add "stat only" diff type
This prints the diffstat but stops before printing (or generating) any
of the body of the diff.

No cgitrc option is added here so that we can wait to see how useful
this is before letting people set it as the default.

Suggested-by: Konstantin Ryabitsev <mricon@kernel.org>
Signed-off-by: John Keeping <john@keeping.me.uk>
10 years ago
John Keeping 1830271c59 Change "ss" diff flag to an enum
This will allow us to introduce a new "stat only" diff mode without
needing an explosion of mutually incompatible flags.

The old "ss" query parameter is still accepted in order to avoid
breaking saved links, but we no longer generate any URIs using it;
instead the new "dt" (diff type) parameter is used.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years ago
Lukas Fleischer a3722ec3c6 Add a cache-snapshot-ttl configuration variable
This can be used to specify the TTL for snapshots. Snapshots are usually
static and do not ever change. On the other hand, tarball generation is
CPU intensive.

One use case of this setting (apart from increasing the lifetime of
snapshot cache slots) is caching of snapshots while disabling the cache
for static/dynamic HTML pages (by setting TTL to zero for everything
except for snapshot requests).

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years ago
Jason A. Donenfeld d6e9200cc3 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 ago
Jason A. Donenfeld a5e1553726 filter: add support for email filter
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
10 years ago
Jason A. Donenfeld e83b51b4f6 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 ago
Jason A. Donenfeld d750c7a2c9 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 ago
John Keeping 7bd90b8048 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 ago
John Keeping 632efb25c0 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 ago
John Keeping 3d8a6507ca 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 ago
Jason A. Donenfeld 3eae406934 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 ago
Jason A. Donenfeld b67ea0c022 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 ago
Jason A. Donenfeld 61ff10065b 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 ago
Jason A. Donenfeld dcbc0438b2 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 ago
Jason A. Donenfeld 389cc17357 Add branch-sort and repo.branch-sort options.
When set to "name", branches are sorted by name, which is the current
default. When set to "age", branches are sorted by the age of the
repository.

This feature was requested by Konstantin Ryabitsev for use on
kernel.org.

Proposed-by: Konstantin Ryabitsev <mricon@kernel.org>
11 years ago
John Keeping d2e20e3814 shared.c: add strbuf_ensure_end
This is a small helper so that we can easily ensure that a strbuf ends
with the specified character.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
John Keeping fd00d2f9d6 html.c: add various strbuf and varadic helpers
This adds the fmtalloc helper, html_txtf, html_vtxtf, and html_attrf.

These takes a printf style format string like htmlf but escapes the
resulting string.  The html_vtxtf variant takes a va_list whereas
html_txtf is variadic.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
John Keeping 57d09bf448 Mark char* fields in struct cgit_page as const
Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
John Keeping b1f17f168b Fix out-of-bounds memory accesses with virtual_root=""
The CGit configuration variable virtual_root is normalized so that it
does not have a trailing '/' character, but it is allowed to be empty
(the empty string and NULL have different meanings here) and there is
code that is insufficiently cautious when checking if it ends in a '/':

	if (virtual_root[strlen(virtual_root) - 1] != '/')

Clearly this check is redundant, but rather than simply removing it we
get a slight efficiency improvement by switching the normalization so
that the virtual_root variable always ends in '/'.  Do this with a new
"ensure_end" helper.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
Lukas Fleischer 3a84324379 Maŕk cgit_environment members const
These reflect the values of environment variables and should never be
changed. Add another xstrdup() when we assign environment variables to
strings that are potentially non-constant.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years ago
Lukas Fleischer 1268afe836 Free reflists after usage
Free reflists in cgit_print_branches() and in cgit_print_tags() before
returning reflist structures to the stack.

This fixes following memory leaks seen with "PATH_INFO=/cgit/refs/":

    ==5710== 1,312 (32 direct, 1,280 indirect) bytes in 1 blocks are definitely lost in loss record 63 of 71
    ==5710==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5710==    by 0x4C2C2FF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5710==    by 0x46CA9B: xrealloc (wrapper.c:100)
    ==5710==    by 0x40AAA6: cgit_add_ref (shared.c:156)
    ==5710==    by 0x40ABC4: cgit_refs_cb (shared.c:186)
    ==5710==    by 0x44BCBA: do_one_ref (refs.c:527)
    ==5710==    by 0x44D240: do_for_each_ref_in_dir (refs.c:553)
    ==5710==    by 0x44D6BA: do_for_each_ref (refs.c:1298)
    ==5710==    by 0x410FE2: cgit_print_branches (ui-refs.c:191)
    ==5710==    by 0x4111E9: cgit_print_refs (ui-refs.c:244)
    ==5710==    by 0x407C85: refs_fn (cmd.c:105)
    ==5710==    by 0x405DDF: process_request (cgit.c:566)
    ==5710==
    ==5710== 6,846 (256 direct, 6,590 indirect) bytes in 1 blocks are definitely lost in loss record 68 of 71
    ==5710==    at 0x4C2C25E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5710==    by 0x46CA9B: xrealloc (wrapper.c:100)
    ==5710==    by 0x40AAA6: cgit_add_ref (shared.c:156)
    ==5710==    by 0x40ABC4: cgit_refs_cb (shared.c:186)
    ==5710==    by 0x44BCBA: do_one_ref (refs.c:527)
    ==5710==    by 0x44D240: do_for_each_ref_in_dir (refs.c:553)
    ==5710==    by 0x44D6EC: do_for_each_ref (refs.c:1288)
    ==5710==    by 0x4110D5: cgit_print_tags (ui-refs.c:218)
    ==5710==    by 0x4111FD: cgit_print_refs (ui-refs.c:246)
    ==5710==    by 0x407C85: refs_fn (cmd.c:105)
    ==5710==    by 0x405DDF: process_request (cgit.c:566)
    ==5710==    by 0x407490: cache_process (cache.c:322)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years ago
John Keeping 2ab1cd9f3b Update git to v1.7.7.7
This release changes the archive interface so that we now need to pass
argv into write_archive().

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
Florian Pritz b1e172acca Make "owner" column on index page configurable
This is not really needed for personal sites where all repos belong to
the same person. Since it is pretty useful for shared sites however, it
should be configurable.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years ago
Tobias Bieniek 792f813d34 ui-log: Add "commit-sort" option for controlling commit ordering
This makes it possible to use strict commit date ordering or strict
topological ordering by passing the corresponding flags to "git log".

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
12 years ago
Tobias Bieniek 7a4e7c8ffb ui-repolist: Add "section-sort" flag to control section sorting.
Flag which, when set to "1", will sort the sections on the repository
listing by name. Set this flag to "0" if the order in the cgitrc file
should be preserved. Default value: "1".

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
12 years ago
Jason A. Donenfeld 521e10c884 scan-tree: Unify gitweb.* and cgit.* settings into one config option.
After some back and forth with Jamie and René, it looks like the git
config semantics are going to be like this:

- gitweb.category maps to the cgit repo config key "section"
- gitweb.description maps to the cgit repo config key "desc"
- gitweb.owner maps to the cgit repo config key "owner"
- cgit.* maps to all cgit repo config keys

This option can be enabled with "enable-git-config=1", and replaces
all previous "enable-gitweb-*" config keys.

The order of operations is as follows:

- git config settings are applied in the order that they exist in
  the git config file
- if the owner is not set from git config, get the owner using the
  usual getpwuid call
- if the description is not set from git config, look inside the
  static $path/description file
- if section-from-path=1, override whatever previous settings were
  inside of git config using the section-from-path logic
- parse $path/cgitrc for local repo.* settings, that override all
  previous settings
12 years ago
Jason A. Donenfeld fdfb6a6d80 ui-repolist: Rename section-sort to repository-sort.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
12 years ago
Jason A. Donenfeld 184c5655b2 ui-repolist: Case insensitive sorting and age sort
Add two options, one for doing the ordinary name sorts in a
case-insensitive manner, and another for choosing to sort repos in each
section by age instead of by name.
12 years ago
Jason A. Donenfeld fc9181ff3d scan-tree: Support gitweb.category.
Use gitweb.category from git config to determine repo's section, if
option is enabled.
12 years ago
Jason A. Donenfeld b56be4ba3a scan-tree: Support gitweb.description.
Use gitweb.description instead of description file to determine
description, if option is enabled.
12 years ago
Lars Hjemli ae90a0b2d1 Merge branch 'fh/mimetypes' 12 years ago
Lars Hjemli 2b9fab8d30 Merge branch 'lh/module-links' 12 years ago
Lars Hjemli 04254fa903 Merge branch 'stable' 13 years ago
Tim Chen f2ced535e9 Fix diff mode switching when side-by-side-diffs=1
When side-by-side-diffs=1 was set in cgitrc, specyfing 'ss=0' in the query-
string would not switch to unified diffs. This patch fixes the issue by
introducing a separate variable to track the occurrence of "ss" in the
querystring.
13 years ago