aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2026-07-31style: replace hardcoded color codes with css variablesv1.3.1+10Gravatar Saya Andy
In order to: a) do custom theme simpler by just replacing necessary vars, b) apply this theme to filters as well; the main cgit.css file now defines CSS vars and uses them in color parameters.
2026-07-31licensing: add author preambles where changes were donev1.3.1+9Gravatar Saya Andy
Add a copyright for changes done by me, also note in README the nature of this repo
2026-07-30tests: check that a misconfigured repo.path is reportedGravatar Saya Andy
Check that a repo.path which does not exist or is not a repository is reported, for the summary page, for an unknown page name and for the ci page. cgit used to hang on these requests rather than fail, so the helper puts a deadline on each one: a regression should fail the test instead of wedging the suite. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30ui-ci: let a ci-filter decide whether the tab is shownGravatar Saya Andy
cgit cannot know whether the ref being viewed actually has a pipeline, so the "ci" tab is offered for every ref and only reveals a missing one once followed. Probing the ci system from cgit is not an option: the tab is part of the page header, so it would mean a blocking request for every page of every repository, cgit links no http client, and job pages are usually not readable anonymously. Add a ci filter instead, which receives the ref, whether it is a branch or a tag, and the expanded url, and answers with its exit status. This keeps credentials, timeouts and caching in a script, where they belong; filters/ci-jenkins.sh demonstrates all three against Jenkins' REST API. The verdict is memoized, so the filter runs once per request rather than once for the tab and again for the redirect, and it governs the page as well as the tab, so a hidden tab cannot be reached by typing the url. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30ui-ci: add a "ci" tab which redirects to an external ci systemGravatar Saya Andy
Add a "ci" page which redirects to an external ci system for the ref being viewed, along with a tab for it in the repository header. The target is a url template, configurable globally or per repository, with separate settings for branches and tags because pipelines for the two commonly live at different locations: on a Jenkins multibranch pipeline a branch is at job/<name>/job/<ref> while a tag is at job/<name>/view/tags/job/<ref>. $ref, $repo and $slug are substituted, $slug being the repository url with any ".git" suffix removed and slashes replaced by dashes, which is the shape job names usually take. An explicit repo.ci-url drops the branch and tag urls the repository would otherwise inherit from the global settings, as it could never take effect otherwise. The expansion is written to the Location header verbatim rather than through cgit_redirect(), which percent-encodes '?', '=' and '%' and would corrupt any url carrying a query string. An expansion containing CR or LF is refused so that it cannot smuggle in further headers. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30ui-shared: don't list branches when there is no repositoryGravatar Saya Andy
print_header() fills the branch switcher from the main ref store whenever ctx.repo is set. For a request which prints a page before prepare_repo_cmd() has cleared ctx.repo -- an unknown page name for a repository whose repo.path is broken, for instance -- the ref store has never been initialized, and get_main_ref_store() aborts after the response has already begun: BUG: refs.c:2301: reference backend is unknown get_main_ref_store print_header at ui-shared.c:1057 cgit_print_error_page(fmt="Invalid request") Add cgit_have_repository() to say whether the repository for this request was opened, and skip the switcher when it was not. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30cgit: don't initialize notes when there is no repositoryGravatar Saya Andy
prepare_repo_env() calls load_display_notes() unconditionally, even when setup_git_directory_gently() has just reported that repo.path is not a repository. init_notes() then resolves the default notes ref and dereferences the repository's hash algorithm, which is still NULL: EXC_BAD_ACCESS (code=1, address=0x18) get_oid_basic(str="refs/notes/commits", len=18) at object-name.c:688 -> if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) { A typo in repo.path therefore took out the request. On Linux this segfaults; on macOS nothing consumes the Mach exception, so the faulting instruction is retried forever and the worker process spins at 100% CPU instead of dying. Only load the notes once a repository has been opened. prepare_repo_cmd() reports the failure immediately afterwards, so such a request now renders "Failed to open <repo>: No such file or directory". Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30gen-version: report the version as semver with the commit distanceGravatar Saya Andy
`git describe` produces "v1.3.1-2-gfbb7", which is neither a Semantic Version nor especially readable. Derive the version from the most recent release tag and the number of commits made since it instead, giving "v1.3.1+7", and plain "v1.3.1" when building the tag itself. That is a valid Semantic Version 2.0.0 with the commit distance as build metadata. Note that build metadata is excluded from precedence, so "v1.3.1+7" and "v1.3.1" compare equal; the distance identifies a build rather than ordering it. Tarball builds keep falling back to the version in the Makefile, and release tags are expected to be named vMAJOR.MINOR.PATCH for the result to stay well-formed. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30Makefile: clean the dependency directory that is createdGravatar Saya Andy
cgit.mk generates dependency files into .depend, but clean removed .deps, so the stale .o.d files survived. They embed absolute compiler and SDK paths, which makes a tree that has been moved, shared between machines, or built inside a container fail after "make clean" with missing targets instead of rebuilding. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-07-30ui-shared: avoid the memrchr GNU extensionGravatar Saya Andy
memrchr() is a GNU extension which glibc and musl provide but macOS does not, so cgit_set_title_from_path() failed to compile there and the tree could not be built on macOS at all. Replace it with a small local helper. The search covers one path component at a time, so there is nothing to gain from a libc version. Signed-off-by: Saya Andy <saya.andy@posteo.com>
2026-05-04Bump versionorigin-masterGravatar Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-05-04global: fix libc constness warningsGravatar Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-05-04git: update to v2.54.0Gravatar Christian Hesse
Update to git version v2.54.0, this requires changes for these upstream commits: * d9ecf268ef3f69130fa269012318470d908978f6 odb: embed base source in the "files" backend * cb506a8a69c953f7b87bb3ae099e0bed8218d3ab odb: introduce "files" source ... and probably more related. Signed-off-by: Christian Hesse <mail@eworm.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-05-04cgit: truncate all config values at the newlineGravatar Jason A. Donenfeld
These would be largely invalid anyway (save, I suppose, for Linux file paths that technically can contain new lines). The actual problem is that these get printed back out into cached -- and trusted -- cgitrc files, and if the fields have newlines, the git-config way of less trusted users configuring repos on a shared system can be abused to inject newlines, which then can be used to smuggle global options (including filters, which execute code) into the cached cgitrc. So now, only ever duplicate up to the newline, when dealing with these inputs. Reported-by: Adrian Denkiewicz <adrian@doyensec.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-05-04cgit: use strchrnul instead of open codingGravatar Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-05-04cgit: devirtualize repo_configGravatar Jason A. Donenfeld
There's no reason to pass around function pointers. It was never used for anything beyond one function. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-04-13cache: truncate lock file before fillingGravatar Jason A. Donenfeld
lock_slot() opens the lock file with O_RDWR|O_CREAT but without O_TRUNC. If a previous cgit process was killed between lock_slot() and unlock_slot() (e.g. by a CGI timeout or OOM), the stale lock file remains on disk with the old content, and the kernel releases the fcntl lock. The next process to claim the same cache slot then opens this stale lock file, acquires the fcntl lock, writes its key and generated content on top of the old bytes. If the new response is shorter than what was previously in the file, trailing bytes from the old response survive beyond the end of the new content. fstat() in fill_slot() reports the total file size (including the stale tail), and print_slot() faithfully sends all of it -- producing a response that is the correct page followed by a fragment of whatever previously occupied that lock file. Fix this by truncating the lock file after acquiring the lock and before writing the new key. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-03-10cgit: override die routine globallyGravatar Jason A. Donenfeld
We don't get any return value from compile_grep_patterns calling compile_regexp_failed, causing the default die routine to print to stderr and then for cgit to exit ungracefully. Instead override the default die routine to show a normal error page. Perhaps compile_grep_patterns ought to change upstream to return an error. But this commit here will handle future issues as well, so perhaps not a bad idea to do anyway. Link: https://lists.zx2c4.com/pipermail/cgit/2026-March/004982.html Link: https://lists.zx2c4.com/pipermail/cgit/2026-March/004983.html Reported-by: Adrian C. <anrxc@sysphere.org> Reported-by: Aiden Woodruff <aiden@aidenw.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-02-24ui-log: allow link following to be disabled per-repoGravatar Jason A. Donenfeld
This exists for other CPU heavy operations like blame, but doesn't for the follow functionality. Add it for that. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-02-24Bump versionGravatar Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-02-24ui-log: don't free diff object when outputting diffGravatar Jason A. Donenfeld
In git 2.36, the logic for diff_flush() changed, resulting in our object getting freed, which led to following renames producing garbage commits until it eventually crashed. Fixes: bb02e24 ("git: update to v2.36.0") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-02-24css: round border edges for decoGravatar Christian Hesse
Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-24css: highlight line in diff...Gravatar Loïc
... specified in the URL, with a curved arrow ahead of the line number. Signed-off-by: Loïc <lagiraudiere+cgit@free.fr> Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-24Makefile: fix uninstall to remove filtersGravatar Christian Barcenas
Signed-off-by: Christian Barcenas <christian@cbarcenas.com> Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-24Makefile: fix uninstall to remove js and robots.txtGravatar Christian Barcenas
Signed-off-by: Christian Barcenas <christian@cbarcenas.com> Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-24ui-shared: don't write <link> if favicon unsetGravatar Christian Barcenas
Since the favicon setting defaults to "/favicon.ico", the user can only unset it with favicon=. However, that would write an empty string as the config value. Previously, such empty string always satisfied the if condition. In this case it is better to omit the <link> entirely. Signed-off-by: Christian Barcenas <christian@cbarcenas.com> Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-24scan-tree: fix error caused by missing parameter nameGravatar Kian Kasad
This fixes an error which was introduced by 2f50b47c72cbc4270bbd12ae7f520486d5f42736. Git 2.42.0 added a new argument to config_fn_t, and it was added to gitconfig_config(), but not named. This causes compile warnings/errors. This commit fixes that by naming the new parameter, and marking it unused. Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-02git: update to v2.53.0Gravatar Christian Hesse
Update to git version v2.53.0, this requires changes for these upstream commits: * bdbebe5714b25dc9d215b48efbb80f410925d7dd refs: introduce wrapper struct for `each_ref_fn` * 589127caa73090040200989ff4d24c3d54f473f2 packfile: move list of packs into the packfile store * 5a5c7359f77ecd1bc4b0e172563161d602f131d3 refs: drop `current_ref_iter` hack * b6e4cc8c32850315323961659e553d1d14591f7f tag: support arbitrary repositories in parse_tag() * 84f0e60b28de69d1ccb7a51b729af6202b6cf4c8 packfile: move packfile store into object source Signed-off-by: Christian Hesse <mail@eworm.de>
2025-11-17git: update to v2.52.0Gravatar Christian Hesse
Update to git version v2.52.0, this requires changes for these upstream commits: * 9f6dfe43c8a55b833ae16486bcafe29b543461f9 string-list: align string_list_split() with its _in_place() counterpart * 78237ea53d6546aeab7adb2c7547a1177311ccde packfile: split up responsibilities of `reprepare_packed_git()` * 751808b2a18acba76b824aed4d8b7442bd7f5fca packfile: refactor `get_packed_git()` to work on packfile store Signed-off-by: Christian Hesse <mail@eworm.de>
2025-10-27git: update to v2.51.2Gravatar Christian Hesse
Update to git version v2.51.2, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2025-10-16git: update to v2.51.1Gravatar Christian Hesse
Update to git version v2.51.1, this requires changes for these upstream commits: * e1d062e8ba0b72f49e9ef9713cc7011c330baab8 odb: drop deprecated wrapper functions Signed-off-by: Christian Hesse <mail@eworm.de>
2025-08-18git: update to v2.51.0Gravatar Christian Hesse
Update to git version v2.51.0, this requires changes for these upstream commits: * 8f49151763cb81adf4bcec53c1ae67057081b02d object-store: rename files to "odb.{c,h}" Signed-off-by: Christian Hesse <mail@eworm.de>
2025-07-08git: update to v2.50.1Gravatar Christian Hesse
Update to git version v2.50.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2025-06-16git: update to v2.50.0Gravatar Christian Hesse
Update to git version v2.50.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2025-03-15git: update to v2.49.0Gravatar Christian Hesse
Update to git version v2.49.0, this requires changes for these upstream commits: * 88dd321cfedc6ee190dfafe4670a83ea33cdf4a3 path: drop `git_path()` in favor of `repo_git_path()` Signed-off-by: Christian Hesse <mail@eworm.de>
2025-01-14git: update to v2.48.1Gravatar Christian Hesse
Update to git version v2.48.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2025-01-10git: update to v2.48.0Gravatar Christian Hesse
Update to git version v2.48.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-11-25git: update to v2.47.1Gravatar Christian Hesse
Update to git version v2.47.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-10-07git: update to v2.47.0Gravatar Christian Hesse
Update to git version v2.47.0, this requires changes for these upstream commits: * e8207717f1623325fe1c95338fb03c1104ed5687 refs: add referent to each_ref_fn Signed-off-by: Christian Hesse <mail@eworm.de>
2024-09-26git: update to v2.46.2Gravatar Christian Hesse
Update to git version v2.46.2, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-09-26git: update to v2.46.1Gravatar Christian Hesse
Update to git version v2.46.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-08-02git: update to v2.46.0Gravatar Christian Hesse
Update to git version v2.46.0, this requires changes for these upstream commits: * e7da9385708accf518a80a1e17969020fb361048 global: introduce `USE_THE_REPOSITORY_VARIABLE` macro * 9da95bda74cf10e1475384a71fd20914c3b99784 hash: require hash algorithm in `oidread()` and `oidclr()` * 30aaff437fddd889ba429b50b96ea4c151c502c5 refs: pass repo when peeling objects * c8f815c2083c4b340d4148a15d45c55f2fcc7d3f refs: remove functions without ref store Signed-off-by: Christian Hesse <mail@eworm.de>
2024-07-16fix building with clangGravatar Denis Pronin
fix error that is given because of macro overlapping cgit_filter member: ../filter.c:388:10: error: no member named '__fprintf_chk' in 'struct cgit_filter' 388 | filter->fprintf(filter, f, prefix); | ~~~~~~ ^ /usr/include/bits/stdio2.h:92:3: note: expanded from macro 'fprintf' 92 | __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) | ^ 1 error generated. Signed-off-by: Denis Pronin <dannftk@yandex.ru> Signed-off-by: Christian Hesse <mail@eworm.de>
2024-07-16ui-stats: add missing source headerGravatar Christian Hesse
Signed-off-by: Christian Hesse <mail@eworm.de>
2024-06-01git: update to v2.45.2Gravatar Christian Hesse
Update to git version v2.45.2, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-05-14git: update to v2.45.1Gravatar Christian Hesse
Update to git version v2.45.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-04-29git: update to v2.45.0Gravatar Christian Hesse
Update to git version v2.45.0, this requires changes for these upstream commits: * 9720d23e8caf4adee44b3a32803a9bb0480118bd date: make DATE_MODE thread-safe Signed-off-by: Christian Hesse <mail@eworm.de>
2024-02-23git: update to v2.44.0Gravatar Christian Hesse
Update to git version v2.44.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2024-02-14git: update to v2.43.2Gravatar Christian Hesse
Update to git version v2.43.2, no additional changes required. (Git v2.43.1 fails to build, thus skipping.) Signed-off-by: Christian Hesse <mail@eworm.de>
2023-11-20git: update to v2.43.0Gravatar Christian Hesse
Update to git version v2.43.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>