aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
11 hourscmd/cgitd: HTTP server for cgit CGIHEADmainShulhan
This program can be built into single binary, provides as an alternatives to common setup that require second application (web server with their own configuration).
32 hourscache: truncate lock file before fillingJason 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 globallyJason 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-repoJason 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 versionv1.3Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2026-02-24ui-log: don't free diff object when outputting diffJason 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 decoChristian Hesse
Signed-off-by: Christian Hesse <mail@eworm.de>
2026-02-24css: highlight line in diff...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 filtersChristian 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.txtChristian 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 unsetChristian 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 nameKian 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.0Christian 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.0Christian 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.2Christian 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.1Christian 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.0Christian 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.1Christian 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.0Christian 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.0Christian 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.1Christian 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.0Christian 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.1Christian 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.0Christian 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.2Christian 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.1Christian 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.0Christian 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 clangDenis 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 headerChristian Hesse
Signed-off-by: Christian Hesse <mail@eworm.de>
2024-06-01git: update to v2.45.2Christian 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.1Christian 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.0Christian 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.0Christian 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.2Christian 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.0Christian Hesse
Update to git version v2.43.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2023-11-02git: update to v2.42.1Christian Hesse
Update to git version v2.42.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2023-08-21git: update to v2.42.0Christian Hesse
Update to git version v2.42.0, this requires changes for these upstream commits: * bc5c5ec0446895f5c4139cd470066beb3c4ac6d5 cache.h: remove this no-longer-used header * aba070683295a20bdf4f49146384984961c794b2 path: move related function to path * a4e7e317f8f27f861321e6eb08b9c8c0f3ab570c config: add ctx arg to config_fn_t Signed-off-by: Christian Hesse <mail@eworm.de>
2023-06-01git: update to v2.41.0Christian Hesse
Update to git version v2.41.0, with lots of changes... This requires changes for these upstream commits: * 60ff56f50372c1498718938ef504e744fe011ffb banned.h: mark `strtok()` and `strtok_r()` as banned * 52acddf36c8cb3778ab2098a0d95cc2e375a4069 string-list: multi-delimiter `string_list_split_in_place()` * d850b7a545fcfbd97460a921c7f7c59d933eb0f7 cocci: apply the "cache.h" part of "the_repository.pending" * cb338c23d6d518947bf6f7240bf30e2ec232bd3b cocci: apply the "commit-reach.h" part of "the_repository.pending" * ecb5091fd4301ac647db0bd2504112b38f7ee06d cocci: apply the "commit.h" part of "the_repository.pending" * 085390328f5fe1dfba67039b1fd6cc51546a4e41 cocci: apply the "diff.h" part of "the_repository.pending" * bc726bd075929aab6b3e09d4dd5c2b0726fd5350 cocci: apply the "object-store.h" part of "the_repository.pending" * bab821646a74c446370fa8d01ca851f247df5033 cocci: apply the "pretty.h" part of "the_repository.pending" * afe27c889429438829bc8818ed17e4960bd3ef02 cocci: apply the "packfile.h" part of "the_repository.pending" * 12cb1c10a64170a5d600dd1c6c8abfeec105fb6b cocci: apply the "refs.h" part of "the_repository.pending" * 035c7de9e9ea11d26df5f9e4bb117f91ed11a9fd cocci: apply the "revision.h" part of "the_repository.pending" ... and some more I missed to list 😜 - for example the move and cleanup of headers and includes (see changes in `cgit.h`) comes to mind... Signed-off-by: Christian Hesse <mail@eworm.de>
2023-04-25git: update to v2.40.1Christian Hesse
Update to git version v2.40.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2023-03-13git: update to v2.40.0Christian Hesse
Update to git version v2.40.0, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2023-02-14git: update to v2.39.2Christian Hesse
Update to git version v2.39.2, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2023-01-18git: update to v2.39.1Christian Hesse
Update to git version v2.39.1, no additional changes required. Signed-off-by: Christian Hesse <mail@eworm.de>
2023-01-10config: make empty js= omit script tagSamuel Lidén Borell
According to the cgitrc man page, an empty js= value should cause the script tag to be omitted. But instead, a script tag with an empty URL is emitted. The same applies to css. So, skip emitting a tag if the specified string is empty. Signed-off-by: Samuel Lidén Borell <samuel@kodafritt.se> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-12-19js: add dynamic age updateAndy Green
This patch updates the emitted "ages" dynamically on the client side. After updating on completion of the document load, it sets a timer to update according to the smallest age it found. If there are any ages listed in minutes, then it will update again in 10s. When the most recent age is in hours, it updates every 5m. If days, then every 30m and so on. This keeps the cost of the dynamic updates at worst once per 10s. The updates are done entirely on the client side without contact with the server. To make this work reliably, since parsing datetimes is unreliable in browser js, the unix time is added as an attribute to all age spans. To make that reliable cross-platform, the unix time is treated as a uint64_t when it is formatted for printing. The rules for display conversion of the age is aligned with the existing server-side rules in ui-shared.h. If the client or server-side time are not synchronized by ntpd etc, ages shown on the client will not relate to the original ages computed at the server. The client updates the ages immediately when the DOM has finished loading, so in the case the times at the server and client are not aligned, this patch changes what the user sees on the page to reflect patch age compared to client time. If the server and client clocks are aligned, this patch makes no difference to what is seen on the page. Signed-off-by: Andy Green <andy@warmcat.com> Signed-off-by: Christian Hesse <mail@eworm.de>
2022-12-19config: add jsAndy Green
Just like the config allows setting css URL path, add a config for setting the js URL path Signed-off-by: Andy Green <andy@warmcat.com> Reviewed-by: John Keeping <john@keeping.me.uk> Signed-off-by: Christian Hesse <mail@eworm.de>
2022-12-19css: change to be a listAndy Green
Without changing the default behaviour of including /cgit.css if nothing declared, allow the "css" config to be given multiple times listing one or more alternative URL paths to be included in the document head area. Signed-off-by: Andy Green <andy@warmcat.com> Signed-off-by: Christian Hesse <mail@eworm.de>
2022-12-19cgitrc: handle value "0" for max-repo-countChristian Hesse
Setting max-repo-count to "0" makes cgit loop forever generating page links. Make this a special value to show all repositories. Signed-off-by: Christian Hesse <mail@eworm.de>
2022-12-19cache: tolerate short writes in print_slotHristo Venev
sendfile() can return after a short read/write, so we may need to call it more than once. As suggested in the manual page, we fall back to read/write if sendfile fails with EINVAL or ENOSYS. On the read/write path, use write_in_full which deals with short writes. Signed-off-by: Hristo Venev <hristo@venev.name> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-12-19global: use release_commit_memory()John Keeping
Instead of calling two separate Git functions to free memory associated with a commit object, use Git's wrapper which does this. This also counts as a potential future bug fix since release_commit_memory() also resets the parsed state of the commit, meaning any attempt to use it in the future will correctly fill out the fields again. release_commit_memory() does not set parents to zero, so keep that for additional safety in case CGit checks this without calling parse_commit() again. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-12-19css: reset font size for blame oidJohn Keeping
In Firefox, the hashes in the blame UI are out of step with the line number and content leading to ever increasing vertical misalignment. This is caused by the .oid class setting font-size to 90%, so override this back to 100% for the blame case, bringing the height of lines in all three columns of the table back into step. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>