summaryrefslogtreecommitdiffstatshomepage
path: root/cgit.c (follow)
Commit message (Collapse)AuthorAgeLines
* Support Git over HTTP by proxying git-http-backend(1)git-http-backendWolfgang Müller2021-05-28-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cgit lacks an easy way to support the "smart" HTTP protocol out of the box. A patch [1] has been proposed in the past, but was never merged. A few years later there was a short discussion at [2] which did not go anywhere. The majority of users who want to support the "smart" HTTP protocol right now seem to conditionally point their web server to git-http-backend(1) directly. This relies on proper path-matching and regular expression support in the web server as seen in the EXMAPLES section of git-http-backend(1). As proposed in [3], it is possible to have cgit interface with the necessary functionality in Git directly, but that would require more work. It does not seem that this is something forthcoming in cgit. Instead, for now, use a modified version of the patch suggested in [1], which simply executes git-http-backend(1) when needed. This removes the need for any additional plumbing in the web server. Notable changes to the original patch: * Remove automatic handling of GIT_PROJECT_ROOT in favour of having the user set the variable correctly themselves. This reduces complexity. * Use the correct function to generate error pages. The original patch used html_status(), which does not exist anymore. * In cmd.c, adjust the struct entries to fit. Sadly we cannot use the def_cmd() macro directly, as the endpoints "git-upload-pack" and "git-receive-pack" contain dashes. [1] https://lists.zx2c4.com/pipermail/cgit/2014-December/002312.html [2] https://lists.zx2c4.com/pipermail/cgit/2016-February/002907.html [3] https://lists.zx2c4.com/pipermail/cgit/2016-February/002926.html
* git: update to v2.25.0Christian Hesse2020-01-13-1/+1
| | | | | | | | | | Update to git version v2.25.0. Upstream renamed 'init_display_notes()' to 'load_display_notes()' in commit 1e6ed5441a61b5085978e0429691e2e2425f6846 ("notes: rename to load_display_notes()"). Signed-off-by: Christian Hesse <mail@eworm.de>
* git: update to v2.22.0Christian Hesse2019-10-25-6/+11
| | | | | | | | | | Update to git version v2.22.0. Upstream commit bce9db6d ("trace2: use system/global config for default trace2 settings") caused a regression. We have to unset HOME and XDG_CONFIG_HOME before early loading of config from trace2 code kicks in. Signed-off-by: Christian Hesse <mail@eworm.de>
* ui-tree: allow per repository override for enable-blameChristian Hesse2019-06-25-0/+4
| | | | | | | The blame operation can cause high cost in terms of CPU load for huge repositories. Let's add a per repository override for enable-blame. Signed-off-by: Christian Hesse <mail@eworm.de>
* auth-filter: pass url with query string attachedJason A. Donenfeld2018-11-25-1/+1
| | | | | | Otherwise redirections come out wrong. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev2018-08-03-0/+2
| | | | | | | | Even if we find snapshot-prefix in the repo configuration, we are not writing it out into the rc- file, so setting the value does not have any effect. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
* auth-filter: do not write more than we've readJason A. Donenfeld2018-07-14-2/+2
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* extra-head-content: introduce another option for meta tagsJason A. Donenfeld2018-07-03-0/+4
| | | | | | | This is to support things like go-import meta tags, which are on a per-repo basis. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* Use string list strdup_strings for mimetypesJohn Keeping2018-06-27-2/+2
| | | | | | | There's no need to do this manually with the string list API will do it for us. Signed-off-by: John Keeping <john@keeping.me.uk>
* global: remove functionality we deprecated for cgit v1.0Christian Hesse2018-06-27-14/+3
| | | | | | | | The man page states these were deprecated for v1.0. We are past v1.1, so remove the functionality. Signed-off-by: Christian Hesse <mail@eworm.de> Reviewed-by: John Keeping <john@keeping.me.uk>
* snapshot: strip bit from struct cgit_snapshot_formatChristian Hesse2018-06-27-1/+1
| | | | | | | We had a static bit value in struct cgit_snapshot_format. We do not rely on it and things can be calculated on the fly. So strip it. Signed-off-by: Christian Hesse <mail@eworm.de>
* Add "snapshot-prefix" repo configurationJohn Keeping2018-06-27-0/+2
| | | | | | | | | | | | Allow using a user-specified value for the prefix in snapshot files instead of the repository basename. For example, files downloaded from the linux-stable.git repository should be named linux-$VERSION and not linux-stable-$VERSION, which can be achieved by setting: repo.snapshot-prefix=linux Signed-off-by: John Keeping <john@keeping.me.uk> Reviewed-by: Christian Hesse <mail@eworm.de>
* cgit: prepare repo before error pagesJason A. Donenfeld2018-02-12-7/+12
| | | | | | | This fixes a crash when showing a list of all heads in the <select> box in the header. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* git: update to v2.16.0Christian Hesse2018-01-19-1/+1
| | | | | | | | | | | | | | | Update to git version v2.16.0: * refs: convert resolve_ref_unsafe to struct object_id (49e61479be913f67e66bb3fdf8de9475c41b58bd) * diff: remove DIFF_OPT_SET macro (23dcf77f48feb49c54bad09210f093a799816334) * log: add option to choose which refs to decorate (65516f586b69307f977cd67cc45513a296cabc25) * diff: convert flags to be stored in bitfields (02f2f56bc377c287c411947d0e1482aac888f8db) Signed-off-by: Christian Hesse <mail@eworm.de>
* ui-blame: add blame UIJeff Smith2017-10-03-0/+2
| | | | | | | | | | Implement a page which provides the blame view of a specified file. This feature is controlled by a new config variable, "enable-blame", which is disabled by default. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: John Keeping <john@keeping.me.uk>
* cgit: don't set vpath unless repo is setJohn Keeping2017-08-10-6/+6
| | | | | | | | | After the previous two patches, this can be classified as a tidy up rather than a bug fix, but I think it makes sense to group all of the tests together before setting up the environment for the command to execute. Signed-off-by: John Keeping <john@keeping.me.uk>
* Use skip_prefix() to get rid of magic constantsLukas Fleischer2016-10-12-26/+30
| | | | Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
* cgit: replace 'unsigned char sha1[20]' with 'struct object_id oid'Christian Hesse2016-10-04-4/+5
| | | | | | Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id oid'. We have some code that can be changed independent from upstream. So here we go...
* git: update to v2.10.0Christian Hesse2016-09-04-1/+1
| | | | | | | | 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.
* Fix qry.head leak on errorRichard Maw2016-07-12-4/+4
| | | | | | This is run soon before exiting so it wasn't leaked for long. Signed-off-by: Richard Maw <richard.maw@gmail.com>
* Hosted on HTTPS nowJason A. Donenfeld2016-06-07-1/+1
|
* ui-shared: add homepage to tabsJason A. Donenfeld2016-02-22-0/+4
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* ui-plain: add enable-html-serving flagJason A. Donenfeld2016-01-14-0/+5
| | | | Unrestricts plain/ to contents likely to be executed by browser.
* ui-blob: Do not accept mimetype from userJason A. Donenfeld2016-01-14-2/+0
|
* filter: avoid integer overflow in authenticate_postJason A. Donenfeld2015-11-24-1/+1
| | | | | | | | | | | | 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>
* cgit.c: remove useless null checkJohn Keeping2015-10-09-1/+1
| | | | | | | | 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>
* cmd: no need for pre function hook nowJason A. Donenfeld2015-08-14-3/+0
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* cmd: remove "want_layout" fieldJohn Keeping2015-08-14-9/+0
| | | | | | No commands use this any more. Signed-off-by: John Keeping <john@keeping.me.uk>
* cgit: use cgit_print_error_page() where appropriateJohn Keeping2015-08-14-20/+7
| | | | | | | | These are more-or-less one-to-one translations but in the final hunk we gain an HTTP error code where we used to send "200 OK", which is an improvement. Signed-off-by: John Keeping <john@keeping.me.uk>
* log: allow users to follow a fileJohn Keeping2015-08-12-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* about: always ensure page has a trailing slashJason A. Donenfeld2015-08-12-0/+3
| | | | | | Otherwise we can't easily embed links to other /about/ pages. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* git: update to v2.5.0Christian Hesse2015-08-12-1/+1
| | | | | | | | | | | | | | | 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>
* Fix processing of repo.hide and repo.ignoreDaniel Reichelt2015-08-12-4/+4
| | | | | | | | If the global option enable-filter-overrides is set to 1 the repo-specific options repo.hide and repo.ignore never got processed. Signed-off-by: Daniel Reichelt <hacking@nachtgeist.net> Reviewed-by: John Keeping <john@keeping.me.uk>
* cgit: remember to set up env vars before empty clone pathJason A. Donenfeld2015-03-09-0/+1
|
* Avoid non-ANSI function declarationsJohn Keeping2015-03-09-1/+1
| | | | | | | | Sparse says things like: warning: non-ANSI function declaration of function 'calc_ttl' Signed-off-by: John Keeping <john@keeping.me.uk>
* cgit: show clone URLs for empty repoJason A. Donenfeld2015-03-05-0/+16
|
* git: update for v2.3.0Christian Hesse2015-02-08-1/+1
| | | | | | | | | * sort_string_list(): rename to string_list_sort() (upstream commit 3383e199) * update read_tree_recursive callback to pass strbuf as base (upstream commit 6a0b0b6d) Signed-off-by: Christian Hesse <mail@eworm.de>
* Add repo.hide and repo.ignoreLukas Fleischer2015-01-29-0/+6
| | | | | | | | 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>
* repolist: add owner-filterChris Burroughs2014-12-23-0/+6
| | | | | | 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.
* git: update to v2.2.1Christian Hesse2014-12-23-1/+1
| | | | | | Update to git version v2.2.1, including API changes. Signed-off-by: Christian Hesse <mail@eworm.de>
* Change "ss" diff flag to an enumJohn Keeping2014-12-13-4/+8
| | | | | | | | | | | 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>
* Always check if README exists in choose_readme()Lukas Fleischer2014-08-07-6/+0
| | | | | | | | | | | | | Specifying a nonexistent README file via the readme option is sometimes useful, e.g. when using scan-path and setting a global default. Currently, we check whether there is only one option in the readme option and, if so, we choose that file without checking whether it exists. As a consequence, all repositories are equipped with an about link in the aforementioned scenario, even if there is no about file. Remove the early check for the number of keys and always check whether the file exists instead. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* git: update for git 2.0Christian Hesse2014-06-28-13/+13
| | | | | | | prefixcmp() and suffixcmp() have been remove, functionality is now provided by starts_with() and ends_with(). Retrurn values have been changed, so instead of just renaming we have to fix logic. Everything else looks just fine.
* Add a cache-snapshot-ttl configuration variableLukas Fleischer2014-02-20-0/+6
| | | | | | | | | | | | | 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>
* cgit: add --version argument for printing infoJason A. Donenfeld2014-01-20-0/+17
| | | | | | We need this to do runtime tests for make test. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* cgit.c: free tmp variableJason A. Donenfeld2014-01-17-0/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* Switch to exclusively using global ctxLukas Fleischer2014-01-17-161/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* auth: have cgit calculate login addressJason A. Donenfeld2014-01-16-1/+2
| | | | | | | This way we're sure to use virtual root, or any other strangeness encountered. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* authentication: use hidden form instead of refererJason A. Donenfeld2014-01-16-14/+8
| | | | | | | 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>
* auth: add basic authentication filter frameworkJason A. Donenfeld2014-01-16-2/+94
| | | | | | | | | | | | | | | | 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>