From samuel at kodafritt.se Sun Jan 1 21:15:23 2023 From: samuel at kodafritt.se (=?UTF-8?q?Samuel=20Lid=C3=A9n=20Borell?=) Date: Sun, 1 Jan 2023 22:15:23 +0100 Subject: [PATCH] css: Optional support for dark mode Message-ID: <20230101214103.1E52F19A2@badger.kodafritt.se> Modern browsers have a "dark mode" preference, which enables alternate CSS rules on web sites that support this. This patch adds an optional dark color scheme, that can be copied into cgit.css. The color scheme is then auto-detected via a @media query. Note that filters that use color (such as source highlighters), and logotypes, may need to be updated to work with a black background. So this goes into a separate file, that can be copied into cgit.css for those who want to enable support for dark mode. Signed-off-by: Samuel Lid?n Borell --- contrib/css/cgit_dark.css | 131 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 contrib/css/cgit_dark.css diff --git a/contrib/css/cgit_dark.css b/contrib/css/cgit_dark.css new file mode 100644 index 0000000..464d765 --- /dev/null +++ b/contrib/css/cgit_dark.css @@ -0,0 +1,131 @@ +/* + Automatic dark mode via @media queries. This is supported in modern + web browsers. Older browser will just ignore it. + + To enable this, append this file to your cgit.css file. + + Plase note: Any filters that you use that use colored text, must also + have CSS rules for dark mode, or the text may become invisible (black + on black). If you use a custom logotype, you should also check that it + is legible on a black background. +*/ +:root { color-scheme: light dark; } + at media (prefers-color-scheme: dark) { + html, div#cgit { color: #ccc; background: black; } + div#cgit a { color: #66f; } + div#cgit table#header td.main a { color: #fff; } + div#cgit table#header td.sub { color: #888; } + div#cgit table.tabs { border-bottom-color: #333; } + div#cgit table.tabs td a { color: #888; } + div#cgit table.tabs td a.active { color: #fff; background-color: #333; } + div#cgit div.path { color: #fff; background-color: #111; } + div#cgit div.content { border-bottom-color: #bbb; } + div#cgit table.list tr { background: black; } + div#cgit table.list tr.logheader { background: #111; } + div#cgit table.list tr:nth-child(even) { background: #080808; } + div#cgit table.list tr:nth-child(odd) { background: black; } + div#cgit table.list tr:hover { background: #111; } + div#cgit table.list tr.nohover { background: black; } + div#cgit table.list tr.nohover:hover { background: black; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #080808; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: black; } + div#cgit table.list td.commitgraph .column1 { color: #f55; } + div#cgit table.list td.commitgraph .column2 { color: #5f5; } + div#cgit table.list td.commitgraph .column3 { color: #ff5; } + div#cgit table.list td.commitgraph .column4 { color: #55f; } + div#cgit table.list td.commitgraph .column5 { color: #f5f; } + div#cgit table.list td.commitgraph .column6 { color: #5ff; } + div#cgit table.list td a { color: white; } + div#cgit table.list td a.ls-dir { color: #66f; } + div#cgit table.list td a:hover { color: #66f; } + div#cgit table#downloads { border-color: #888; } + div#cgit table#downloads th { background-color: #333; } + div#cgit div#blob { border-color: white; } + div#cgit table.blob { border-top-color: white; } + div#cgit table.blob td.hashes, + div#cgit table.blob td.lines { color: white; } + div#cgit table.blob td.linenumbers { border-right-color: gray; } + div#cgit table.blob td.linenumbers a, + div#cgit table.ssdiff td.lineno a { color: gray; } + div#cgit table.blob td.linenumbers a:hover, + div#cgit table.ssdiff td.lineno a:hover { color: white; } + div#cgit table.blame div.alt:nth-child(even) { background: #111; } + div#cgit table.blame div.alt:nth-child(odd) { background: black; } + div#cgit table.bin-blob { border-color: white; } + div#cgit table.bin-blob th { border-color: #888; } + div#cgit table.bin-blob td { border-left-color: #888; } + div#cgit div.cgit-panel table { border-color: #555; background-color: #111; } + div#cgit div.notes { border-color: #661; background-color: #220; } + div#cgit table.diffstat { border: #555; background-color: #111; } + div#cgit table.diffstat td span.modechange { color: #c66; } + div#cgit table.diffstat td.add a { color: #6c6; } + div#cgit table.diffstat td.del a { color: #c66; } + div#cgit table.diffstat td.upd a { color: #66c; } + div#cgit table.diffstat td.graph td.add { background-color: #3a3; } + div#cgit table.diffstat td.graph td.rem { background-color: #a33; } + div#cgit div.diffstat-summary { color: #777; } + div#cgit table.diff td div.head { color: white; } + div#cgit table.diff td div.hunk { color: #66f; } + div#cgit table.diff td div.add { color: #6c6; } + div#cgit table.diff td div.del { color: #c66; } + div#cgit table.list td.reposection { color: #777; } + div#cgit ul.pager a { color: #888; } + div#cgit span.age-mins { color: #7f7; } + div#cgit span.age-hours { color: #7f7; } + div#cgit span.age-days { color: #bfb; } + div#cgit span.age-weeks { color: #bbb; } + div#cgit span.age-months { color: #777; } + div#cgit span.age-years { color: #444; } + div#cgit span.insertions { color: #7f7; } + div#cgit span.deletions { color: #f77; } + div#cgit div.footer { color: #333; } + div#cgit div.footer a { color: #333; } + div#cgit a.branch-deco { color: #fff; background-color: #007700; border-color: #88ff88; } + div#cgit a.tag-deco { color: #fff; background-color: #777700; border-color: #ffff88; } + div#cgit a.tag-annotated-deco { color: #fff; background-color: #773300; border-color: #ffff88; } + div#cgit a.remote-deco { color: #fff; background-color: #000033; border-color: #8888ff; } + div#cgit a.deco { color: #fff; background-color: #770000; border-color: #ff8888; } + div#cgit table.stats { border-color: white; } + div#cgit table.stats th { background-color: #111; border-color: white; } + div#cgit table.stats td { border-color: white; } + div#cgit table.stats td.sum { color: #f33; } + div#cgit table.vgraph { border-color: white; } + div#cgit table.vgraph th { background-color: #111; border-color: black; } + div#cgit table.vgraph div.bar { background-color: #111; } + div#cgit table.hgraph { border-color: white; } + div#cgit table.hgraph th { background-color: #111; border-color: white; } + div#cgit table.hgraph div.bar { background-color: #111; } + div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; } + div#cgit table.ssdiff td.add { color: white; background: #030; } + div#cgit table.ssdiff td.add_dark { color: white; background: #353; } + div#cgit table.ssdiff span.add { background: #030; } + div#cgit table.ssdiff td.del { color: white; background: #300; } + div#cgit table.ssdiff td.del_dark { color: white; background: #533; } + div#cgit table.ssdiff span.del { background: #300; } + div#cgit table.ssdiff td.changed { color: white; background: #330; } + div#cgit table.ssdiff td.changed_dark { color: white; background: #553; } + div#cgit table.ssdiff td.lineno { color: white; background: #111; } + div#cgit table.ssdiff td.hunk { color: white; background: #003; border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head div.head { color: white; } + div#cgit table.ssdiff td.foot { border-top-color: #555; } + + /* If you use filters that use colored text, such as a source + highlighter, you will need to add styles for it as well. + + Here is an example, based on the example CSS in the file + filters/syntax-highlighting.sh */ + div#cgit table.blob .num { color:#ff814f; } + div#cgit table.blob .esc { color:#ff00ff; } + div#cgit table.blob .str { color:#fc4040; } + div#cgit table.blob .pps { color:#ffff7f; } + div#cgit table.blob .slc { color:#7f7c7f; } + div#cgit table.blob .com { color:#7e7c7e; } + div#cgit table.blob .ppc { color:#7dff7d; } + div#cgit table.blob .opt { color:#ffffff; } + div#cgit table.blob .lin { color:#aaaaaa; } + div#cgit table.blob .kwa { color:#ffffff; } + div#cgit table.blob .kwb { color:#51a8ff; } + div#cgit table.blob .kwc { color:#ffffff; } + div#cgit table.blob .kwd { color:#7e7efe; } +} -- 2.30.2 From Jason at zx2c4.com Mon Jan 2 00:51:55 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Mon, 2 Jan 2023 01:51:55 +0100 Subject: [PATCH] css: Optional support for dark mode In-Reply-To: <20230101214103.1E52F19A2@badger.kodafritt.se> References: <20230101214103.1E52F19A2@badger.kodafritt.se> Message-ID: Hi Samuel, On Sun, Jan 1, 2023 at 10:41 PM Samuel Lid?n Borell wrote: > > Modern browsers have a "dark mode" preference, which enables alternate > CSS rules on web sites that support this. > > This patch adds an optional dark color scheme, that can be copied into > cgit.css. The color scheme is then auto-detected via a @media query. > > Note that filters that use color (such as source highlighters), and > logotypes, may need to be updated to work with a black background. So > this goes into a separate file, that can be copied into cgit.css for > those who want to enable support for dark mode. Rather, let's just include this in the default cgit.css file, people will just fix whatever source filters being used. That means the ones in-tree should be updated first. Specifically, syntax-highlighting.py and maybe even syntax-highlighting.sh should be updated. Jason From actionmystique at gmail.com Wed Jan 4 14:52:21 2023 From: actionmystique at gmail.com (jean-christophe manciot) Date: Wed, 4 Jan 2023 15:52:21 +0100 Subject: Version branches Message-ID: Hi there, I have recloned the repository from scratch but it seems that all previous git- branches have all disappeared; for instance, there used to be refs/heads/ch/git-2-39. git-cgit$ git clone https://git.zx2c4.com/cgit . Cloning into '.'... remote: Enumerating objects: 7124, done. remote: Counting objects: 100% (1363/1363), done. remote: Compressing objects: 100% (192/192), done. remote: Total 7124 (delta 1308), reused 1176 (delta 1171), pack-reused 5761 Receiving objects: 100% (7124/7124), 8.67 MiB | 11.32 MiB/s, done. Resolving deltas: 100% (5100/5100), done. git-cgit (master)$ git submodule init Submodule 'git' (https://git.kernel.org/pub/scm/git/git.git) registered for path 'git' git-cgit (master)$ git submodule update Cloning into '/media/Shared/home/actionmystique/src/Git/git-cgit/git'... Submodule path 'git': checked out 'c48035d29b4e524aed3a32f0403676f0d9128863' git-cgit (master)$ git branch -r | grep git- git-cgit (master)$ I used those git branches to build cgit for specific git versions. How can we do it now? Regards. -- Jean-Christophe From actionmystique at gmail.com Wed Jan 4 15:08:31 2023 From: actionmystique at gmail.com (jean-christophe manciot) Date: Wed, 4 Jan 2023 16:08:31 +0100 Subject: Version branches In-Reply-To: References: Message-ID: Also, I can't apply some important patches anymore: - ui-tree: add about link in tree view list - Make default pages configurable - ui-commit: show subject in page title For instance: $ git apply --verbose ../0001-about-link-git2.21.0.patch Checking patch ui-shared.c... Hunk #1 succeeded at 346 (offset 1 line). Checking patch ui-shared.h... Checking patch ui-tree.c... error: while searching for: cgit_print_layout_start(); htmlf("blob: %s (", oid_to_hex(oid)); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); if (ctx.repo->enable_blame) { error: patch failed: ui-tree.c:108 error: ui-tree.c: patch does not apply Those patches have been attached. On Wed, Jan 4, 2023 at 3:52 PM jean-christophe manciot wrote: > > Hi there, > I have recloned the repository from scratch but it seems that all > previous git- branches have all disappeared; for > instance, there used to be refs/heads/ch/git-2-39. > > git-cgit$ git clone https://git.zx2c4.com/cgit . > Cloning into '.'... > remote: Enumerating objects: 7124, done. > remote: Counting objects: 100% (1363/1363), done. > remote: Compressing objects: 100% (192/192), done. > remote: Total 7124 (delta 1308), reused 1176 (delta 1171), pack-reused 5761 > Receiving objects: 100% (7124/7124), 8.67 MiB | 11.32 MiB/s, done. > Resolving deltas: 100% (5100/5100), done. > > git-cgit (master)$ git submodule init > Submodule 'git' (https://git.kernel.org/pub/scm/git/git.git) > registered for path 'git' > git-cgit (master)$ git submodule update > Cloning into '/media/Shared/home/actionmystique/src/Git/git-cgit/git'... > Submodule path 'git': checked out 'c48035d29b4e524aed3a32f0403676f0d9128863' > > git-cgit (master)$ git branch -r | grep git- > git-cgit (master)$ > > I used those git branches to build cgit for specific git versions. > How can we do it now? > > Regards. > -- > Jean-Christophe -- Jean-Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-about-link-git2.21.0.patch Type: text/x-patch Size: 1839 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-Make-default-pages-configurable.patch Type: text/x-patch Size: 9649 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0004-show-subject-in-page-title.patch Type: text/x-patch Size: 560 bytes Desc: not available URL: From Jason at zx2c4.com Wed Jan 4 15:10:01 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Wed, 4 Jan 2023 16:10:01 +0100 Subject: Version branches In-Reply-To: References: Message-ID: Those got merged to master, long overdue. From actionmystique at gmail.com Wed Jan 4 16:52:59 2023 From: actionmystique at gmail.com (jean-christophe manciot) Date: Wed, 4 Jan 2023 17:52:59 +0100 Subject: Version branches In-Reply-To: References: Message-ID: It's not the same: with the first patch (combined with another attached patch), when I click on a repo from the first page, I go to the about page. Here, I end up on the summary page. On Wed, Jan 4, 2023 at 4:10 PM Jason A. Donenfeld wrote: > > Those got merged to master, long overdue. -- Jean-Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-about-link-git2.21.0.patch Type: text/x-patch Size: 649 bytes Desc: not available URL: From actionmystique at gmail.com Wed Jan 4 16:57:17 2023 From: actionmystique at gmail.com (jean-christophe manciot) Date: Wed, 4 Jan 2023 17:57:17 +0100 Subject: Version branches In-Reply-To: References: Message-ID: If I apply the second patch, the compilation fails: /usr/bin/ld: ../ui-tree.o: in function `ls_item': git-cgit/git/../ui-tree.c:271: undefined reference to `cgit_about_link' On Wed, Jan 4, 2023 at 5:52 PM jean-christophe manciot wrote: > > It's not the same: with the first patch (combined with another > attached patch), when I click on a repo from the first page, I go to > the about page. > Here, I end up on the summary page. > > On Wed, Jan 4, 2023 at 4:10 PM Jason A. Donenfeld wrote: > > > > Those got merged to master, long overdue. > > > > -- > Jean-Christophe -- Jean-Christophe From list at eworm.de Thu Jan 5 11:52:58 2023 From: list at eworm.de (Christian Hesse) Date: Thu, 5 Jan 2023 12:52:58 +0100 Subject: Version branches In-Reply-To: References: Message-ID: <20230105125258.1c6cf67e@leda.eworm.net> jean-christophe manciot on Wed, 2023/01/04 16:08: > Also, I can't apply some important patches anymore: > - ui-tree: add about link in tree view list See branch 'ch/about-link'.... > - Make default pages configurable ... and 'ch/default-pages'. > - ui-commit: show subject in page title No idea about this one. -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From tmz at pobox.com Thu Jan 5 16:45:32 2023 From: tmz at pobox.com (Todd Zullinger) Date: Thu, 5 Jan 2023 11:45:32 -0500 Subject: Version branches In-Reply-To: <20230105125258.1c6cf67e@leda.eworm.net> References: <20230105125258.1c6cf67e@leda.eworm.net> Message-ID: Christian Hesse wrote: >> - ui-commit: show subject in page title > > No idea about this one. That appears to be: v1 <20200221234518.86715-1-june at causal.agency> v2 <20200223185227.89151-1-june at causal.agency> (w/sign-off) -- Todd -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: From samuel at kodafritt.se Sun Jan 1 21:15:23 2023 From: samuel at kodafritt.se (=?UTF-8?q?Samuel=20Lid=C3=A9n=20Borell?=) Date: Sun, 1 Jan 2023 22:15:23 +0100 Subject: [PATCH RESEND v2] css: Support for dark mode In-Reply-To: References: <20230101214103.1E52F19A2@badger.kodafritt.se> Message-ID: <20230105225343.0264A262C@badger.kodafritt.se> Modern browsers have a "dark mode" preference, which enables alternate styles on web sites that support this. This patch adds a dark color scheme, that is automatically activated via a CSS @media query. Note that filters that use color (such as source highlighters) and logotypes may need to be updated to work with a black background! See the updated files in the filters/ directory. Signed-off-by: Samuel Lid?n Borell --- cgit.css | 103 ++++++++++++++++++++++++++++++++ filters/html-converters/md2html | 28 ++++++++- filters/syntax-highlighting.py | 8 ++- filters/syntax-highlighting.sh | 73 +++++++++++++++------- 4 files changed, 187 insertions(+), 25 deletions(-) diff --git a/cgit.css b/cgit.css index 1b848cf..1d5c6d0 100644 --- a/cgit.css +++ b/cgit.css @@ -897,3 +897,106 @@ div#cgit table.ssdiff td.space { div#cgit table.ssdiff td.space div { min-height: 3em; } + +/* Color overrides for browsers running in dark mode */ +:root { color-scheme: light dark; } + at media (prefers-color-scheme: dark) { + html, div#cgit { color: #ccc; background: black; } + div#cgit a { color: #66f; } + div#cgit table#header td.main a { color: #eee; } + div#cgit table#header td.sub { color: #888; } + div#cgit table.tabs { border-bottom-color: #333; } + div#cgit table.tabs td a { color: #888; } + div#cgit table.tabs td a.active { color: #eee; background-color: #333; } + div#cgit div.path { color: #eee; background-color: #111; } + div#cgit div.content { border-bottom-color: #bbb; } + div#cgit table.list tr { background: black; } + div#cgit table.list tr.logheader { background: #111; } + div#cgit table.list tr:nth-child(even) { background: #080808; } + div#cgit table.list tr:nth-child(odd) { background: black; } + div#cgit table.list tr:hover { background: #111; } + div#cgit table.list tr.nohover { background: black; } + div#cgit table.list tr.nohover:hover { background: black; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #080808; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: black; } + div#cgit table.list td.commitgraph .column1 { color: #f55; } + div#cgit table.list td.commitgraph .column2 { color: #5f5; } + div#cgit table.list td.commitgraph .column3 { color: #ff5; } + div#cgit table.list td.commitgraph .column4 { color: #55f; } + div#cgit table.list td.commitgraph .column5 { color: #f5f; } + div#cgit table.list td.commitgraph .column6 { color: #5ff; } + div#cgit table.list td a { color: #eee; } + div#cgit table.list td a.ls-dir { color: #66f; } + div#cgit table.list td a:hover { color: #66f; } + div#cgit table#downloads { border-color: #888; } + div#cgit table#downloads th { background-color: #333; } + div#cgit div#blob { border-color: #eee; } + div#cgit table.blob { border-top-color: #eee; } + div#cgit table.blob td.hashes, + div#cgit table.blob td.lines { color: #eee; } + div#cgit table.blob td.linenumbers { border-right-color: gray; } + div#cgit table.blob td.linenumbers a, + div#cgit table.ssdiff td.lineno a { color: gray; } + div#cgit table.blob td.linenumbers a:hover, + div#cgit table.ssdiff td.lineno a:hover { color: #eee; } + div#cgit table.blame div.alt:nth-child(even) { background: #111; } + div#cgit table.blame div.alt:nth-child(odd) { background: black; } + div#cgit table.bin-blob { border-color: #eee; } + div#cgit table.bin-blob th { border-color: #888; } + div#cgit table.bin-blob td { border-left-color: #888; } + div#cgit div.cgit-panel table { border-color: #555; background-color: #111; } + div#cgit div.notes { border-color: #661; background-color: #220; } + div#cgit table.diffstat { border: #555; background-color: #111; } + div#cgit table.diffstat td span.modechange { color: #c66; } + div#cgit table.diffstat td.add a { color: #6c6; } + div#cgit table.diffstat td.del a { color: #c66; } + div#cgit table.diffstat td.upd a { color: #66c; } + div#cgit table.diffstat td.graph td.add { background-color: #3a3; } + div#cgit table.diffstat td.graph td.rem { background-color: #a33; } + div#cgit div.diffstat-summary { color: #777; } + div#cgit table.diff td div.head { color: #eee; } + div#cgit table.diff td div.hunk { color: #66f; } + div#cgit table.diff td div.add { color: #6c6; } + div#cgit table.diff td div.del { color: #c66; } + div#cgit table.list td.reposection { color: #777; } + div#cgit ul.pager a { color: #888; } + div#cgit span.age-mins { color: #7f7; } + div#cgit span.age-hours { color: #7f7; } + div#cgit span.age-days { color: #bfb; } + div#cgit span.age-weeks { color: #bbb; } + div#cgit span.age-months { color: #777; } + div#cgit span.age-years { color: #444; } + div#cgit span.insertions { color: #7f7; } + div#cgit span.deletions { color: #f77; } + div#cgit div.footer { color: #333; } + div#cgit div.footer a { color: #333; } + div#cgit a.branch-deco { color: #dfd; background-color: #050; border-color: #6c6; } + div#cgit a.tag-deco { color: #ffd; background-color: #777700; border-color: #ffff88; } + div#cgit a.tag-annotated-deco { color: #fed; background-color: #850; border-color: #fc8; } + div#cgit a.remote-deco { color: #ddf; background-color: #336; border-color: #66f; } + div#cgit a.deco { color: #fdd; background-color: #a33; border-color: #ff8888; } + div#cgit table.stats { border-color: #eee; } + div#cgit table.stats th { background-color: #111; border-color: #eee; } + div#cgit table.stats td { border-color: #eee; } + div#cgit table.stats td.sum { color: #f33; } + div#cgit table.vgraph { border-color: #eee; } + div#cgit table.vgraph th { background-color: #111; border-color: black; } + div#cgit table.vgraph div.bar { background-color: #111; } + div#cgit table.hgraph { border-color: #eee; } + div#cgit table.hgraph th { background-color: #111; border-color: #eee; } + div#cgit table.hgraph div.bar { background-color: #111; } + div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; } + div#cgit table.ssdiff td.add { color: #eee; background: #030; } + div#cgit table.ssdiff td.add_dark { color: #eee; background: #353; } + div#cgit table.ssdiff span.add { background: #030; } + div#cgit table.ssdiff td.del { color: #eee; background: #300; } + div#cgit table.ssdiff td.del_dark { color: #eee; background: #533; } + div#cgit table.ssdiff span.del { background: #300; } + div#cgit table.ssdiff td.changed { color: #eee; background: #330; } + div#cgit table.ssdiff td.changed_dark { color: #eee; background: #553; } + div#cgit table.ssdiff td.lineno { color: #eee; background: #111; } + div#cgit table.ssdiff td.hunk { color: #eee; background: #003; border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head div.head { color: #eee; } + div#cgit table.ssdiff td.foot { border-top-color: #555; } +} diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index 59f43a8..097a5d0 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -4,6 +4,11 @@ import sys import io from pygments.formatters import HtmlFormatter from markdown.extensions.toc import TocExtension + +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' + sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') sys.stdout.write(''' @@ -284,9 +289,28 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div# border: none; } ''') -sys.stdout.write(HtmlFormatter(style='pastie').get_style_defs('.highlight')) +sys.stdout.write(HtmlFormatter(style=light_style).get_style_defs('.highlight')) sys.stdout.write(''' - + at media (prefers-color-scheme: dark) { +.markdown-body a.absent { color: #f33; } +.markdown-body h1 .mini-icon-link, .markdown-body h2 .mini-icon-link, .markdown-body h3 .mini-icon-link, .markdown-body h4 .mini-icon-link, .markdown-body h5 .mini-icon-link, .markdown-body h6 .mini-icon-link { color: #eee; } +div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { color: #eee; } +.markdown-body h1 { color: #eee; } +.markdown-body h2 { border-bottom-color: #333; color: #eee; } +.markdown-body h6 { color: #888; } +.markdown-body hr { border-color: #333; } +.markdown-body blockquote { border-left-color: #222; color: #888; } +.markdown-body table th, .markdown-body table td { border-color: #333; } +.markdown-body table tr { border-top-color: #333; background-color: #111; } +.markdown-body table tr:nth-child(2n) { background-color: #070707; } +.markdown-body span.frame span span { color: #ccc; } +.markdown-body code, .markdown-body tt { border-color: #151515; background-color: #070707; } +.markdown-body .highlight pre, .markdown-body pre { background-color: #070707; border-color: #333; } +''') +sys.stdout.write(HtmlFormatter(style=dark_style, nobackground=True).get_style_defs('.highlight')) +sys.stdout.write('\n}\n') # end of dark mode +sys.stdout.write(''' + ''') sys.stdout.write("
") sys.stdout.flush() diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py index e912594..672201d 100755 --- a/filters/syntax-highlighting.py +++ b/filters/syntax-highlighting.py @@ -29,12 +29,15 @@ from pygments.lexers import guess_lexer from pygments.lexers import guess_lexer_for_filename from pygments.formatters import HtmlFormatter +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') data = sys.stdin.read() filename = sys.argv[1] -formatter = HtmlFormatter(style='pastie', nobackground=True) +formatter = HtmlFormatter(style=light_style, nobackground=True) try: lexer = guess_lexer_for_filename(filename, data) @@ -51,5 +54,8 @@ except TypeError: # printout pygments' css definitions as well sys.stdout.write('') sys.stdout.write(highlight(data, lexer, formatter, outfile=None)) diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 840bc34..7ef01c4 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh @@ -25,6 +25,20 @@ # table.blob .kwb { color:#830000; } # table.blob .kwc { color:#000000; font-weight:bold; } # table.blob .kwd { color:#010181; } +# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# table.blob .num { color:#ff814f; } +# table.blob .esc { color:#ff00ff; } +# table.blob .str { color:#fc4040; } +# table.blob .dstr { color:#ffff7e; } +# table.blob .slc { color:#7f7c7f; } +# table.blob .com { color:#7e7c7e; } +# table.blob .dir { color:#7dff7d; } +# table.blob .sym { color:#eeeeee; } +# table.blob .kwa { color:#eeeeee; } +# table.blob .kwb { color:#51a8ff; } +# table.blob .kwc { color:#eeeeee; } +# table.blob .kwd { color:#7e7efe; } +# } # # # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/ @@ -45,28 +59,26 @@ # .hl.kwb { color:#830000; } # .hl.kwc { color:#000000; font-weight:bold; } # .hl.kwd { color:#010181; } -# -# -# Style definition file generated by highlight 3.8, http://www.andre-simon.de/ -# -# body.hl { background-color:#e0eaee; } -# pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';} -# .hl.num { color:#b07e00; } -# .hl.esc { color:#ff00ff; } -# .hl.str { color:#bf0303; } -# .hl.pps { color:#818100; } -# .hl.slc { color:#838183; font-style:italic; } -# .hl.com { color:#838183; font-style:italic; } -# .hl.ppc { color:#008200; } -# .hl.opt { color:#000000; } -# .hl.lin { color:#555555; } -# .hl.kwa { color:#000000; font-weight:bold; } -# .hl.kwb { color:#0057ae; } -# .hl.kwc { color:#000000; font-weight:bold; } -# .hl.kwd { color:#010181; } -# -# -# Style definition file generated by highlight 3.13, http://www.andre-simon.de/ +# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# pre.hl { color:#eeeeee; background-color:#111; } +# .hl.num { color:#ff814f; } +# .hl.esc { color:#ff00ff; } +# .hl.str { color:#fc4040; } +# .hl.dstr { color:#ffff7e; } +# .hl.slc { color:#7f7c7f; } +# .hl.com { color:#7e7c7e; } +# .hl.dir { color:#7dff7d; } +# .hl.sym { color:#eeeeee; } +# .hl.line { color:#aaaaaa; } +# .hl.mark { background-color:#444400; } +# .hl.kwa { color:#eeeeee; } +# .hl.kwb { color:#51a8ff; } +# .hl.kwc { color:#eeeeee; } +# .hl.kwd { color:#7e7efe; } +# } +# +# +# Style definition file generated by highlight 3.8 / 3.13 / 3.41, http://www.andre-simon.de/ # # body.hl { background-color:#e0eaee; } # pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;} @@ -84,6 +96,23 @@ # .hl.kwb { color:#0057ae; } # .hl.kwc { color:#000000; font-weight:bold; } # .hl.kwd { color:#010181; } +# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# pre.hl { color:#eeeeee; background-color:#111; } +# .hl.num { color:#ff814f; } +# .hl.esc { color:#ff00ff; } +# .hl.str { color:#fc4040; } +# .hl.pps { color:#ffff7f; } +# .hl.slc { color:#7f7c7f; } +# .hl.com { color:#7e7c7e; } +# .hl.ppc { color:#7dff7d; } +# .hl.opt { color:#eeeeee; } +# .hl.ipl { color:#51a8ff; } +# .hl.lin { color:#aaaaaa; } +# .hl.kwa { color:#eeeeee; } +# .hl.kwb { color:#51a8ff; } +# .hl.kwc { color:#eeeeee; } +# .hl.kwd { color:#7e7efe; } +# } # # # The following environment variables can be used to retrieve the configuration -- 2.30.2 From kian at kasad.com Thu Jan 5 23:14:42 2023 From: kian at kasad.com (Kian Kasad) Date: Thu, 05 Jan 2023 15:14:42 -0800 Subject: Follow-up: User-configurable log graph option In-Reply-To: <20211230210820.3ncgngexbbhlpbdq@frisbee.local> References: <20210218223126.yrgfjni73fi4rvw4@frisbee> <20211230210820.3ncgngexbbhlpbdq@frisbee.local> Message-ID: <276a46560391a10194d808f6631b0c8612f0741e.camel@kasad.com> Hello cgit developers, Just over a year ago, I proposed a configurable "graph" option for the log page. The idea was met with positive feedback, but when I proposed my implementation I never heard back. So I'm trying again in hopes that I can get a response. It would be nice if this was merged into the upstream so I don't have to maintain my fork, but if the way I've chosen to go about it isn't desirable, then I understand. But even in the latter case, I need a "no" so I know to stop trying to push this. The original conversation is below. I've also finished the implementation and am using it at https://git.kasad.com if you'd like to test it out. See here for my fork of cgit implementing this change: https://git.kasad.com/cgit/log/?h=feat%2Fgraph-page On Thu, 2021-12-30 at 13:08 -0800, Kian Kasad wrote: > On 21/02/19 12:22PM, John Keeping wrote: > > On Thu, Feb 18, 2021 at 02:31:26PM -0800, Kian Kasad wrote: > > > I'm using cgit on my website and I'm wondering if it's possible > > > to allow > > > the user (i.e. the person visiting the site) to choose whether or > > > not > > > the commit graph is displayed on the log page. > > > > > > If this isn't currently possible, what do you think about adding > > > such > > > functionality? Maybe something like how the diff page lets the > > > user > > > choose between a "unified diff" and "ssdiff". > > > > This sounds like a great new feature! > > > > I think we still want to allow the administrator to turn the > > feature > > on/off but if it is permitted, then it makes sense to allow the end > > user > > to choose whether or not they want it enabled. > > Following up on this as I'm finally getting around to implementing > this > feature. I'm not too familiar with CGit's codebase, so I think it > would > be easier to implement this as a separate "graph" page which is > identical to the log page except that it always displays a graph. > > This graph page would only be shown in the navbar's tab list if the > "enable-commit-graph" option is set to "separate" in the > configuration. > If it is set to "combined" then the graph page will be disabled and > the > commit graph will be displayed on the log page as it currently is > when > the "enable-commit-graph" option is set to "1". > > In order to maintain backwards compatibility, the value "1" could > also > be interpreted as the value "combined" since it has the same > functionality currently. > > The value "none" (or "0" for backwards compatibility) would disable > the > graph page as well as disabling the commit graph on the log page. > > I've already started working on this as I want it for my own CGit > site. > If this is something that the maintainer(s) want to integrate, I'll > send > patches when I'm done. -- Kian Kasad PGP 0x1715EEAA14DAEC1 kian at kasad.com (925) 871-9823 From levi.durfee at gmail.com Fri Jan 6 21:59:27 2023 From: levi.durfee at gmail.com (Levi Durfee) Date: Fri, 6 Jan 2023 16:59:27 -0500 Subject: Go - Serving modules Message-ID: I noticed on git.zx2c4.com that there is the "go-import" meta tag. You can view the source of https://git.zx2c4.com/wireguard-go to see the meta tag. I tried replicating this using the "head-include" config option, but I don't see a way to specify any repository data from a variable. Is there a way to configure my cgit instance to also have the "go-import" meta tag? Or will it require a new function in "ui-shared.c"? Thanks, Levi From dakkar at thenautilus.net Fri Jan 6 22:13:32 2023 From: dakkar at thenautilus.net (Gianni Ceccarelli) Date: Fri, 6 Jan 2023 22:13:32 +0000 Subject: Go - Serving modules In-Reply-To: References: Message-ID: <20230106221332.48de955d@thenautilus.net> On 2023-01-06 Levi Durfee wrote: > I noticed on git.zx2c4.com that there is the "go-import" meta tag. You > can view the source of https://git.zx2c4.com/wireguard-go to see the > meta tag. > > I tried replicating this using the "head-include" config option, but I > don't see a way to specify any repository data from a variable. I guess you could set ``repo.extra-head-content`` for each Go repository (I'm a bit surprised that the two options are named differently?) -- Dakkar - GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88 From samuel at kodafritt.se Sat Jan 7 11:38:04 2023 From: samuel at kodafritt.se (Samuel =?ISO-8859-1?Q?Lid=E9n?= Borell) Date: Sat, 7 Jan 2023 12:38:04 +0100 Subject: [PATCH] config: Make empty js= omit script tag Message-ID: <20230107123804.9b9f0bf1a7f3d6931cbf8e04@kodafritt.se> Hi, Here's a patch to make empty js= values in cgitrc work as documented. I'm sending it gzipped, because the mail server rejects it otherwise due to HTML in the patch. Regards, Samuel -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-config-Make-empty-js-omit-script-tag.patch.gz Type: application/gzip Size: 789 bytes Desc: not available URL: From Jason at zx2c4.com Tue Jan 10 16:50:12 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Tue, 10 Jan 2023 17:50:12 +0100 Subject: [PATCH] config: Make empty js= omit script tag In-Reply-To: <20230107123804.9b9f0bf1a7f3d6931cbf8e04@kodafritt.se> References: <20230107123804.9b9f0bf1a7f3d6931cbf8e04@kodafritt.se> Message-ID: Hi Samuel, This also needs to be done for css. I'll send a v2 and apply it. Jason From Jason at zx2c4.com Tue Jan 10 16:53:40 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Tue, 10 Jan 2023 17:53:40 +0100 Subject: [PATCH v2] config: make empty js= omit script tag In-Reply-To: References: Message-ID: <20230110165340.27837-1-Jason@zx2c4.com> From: Samuel 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 Signed-off-by: Jason A. Donenfeld --- ui-shared.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui-shared.c b/ui-shared.c index 11aed19..baea6f2 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -770,6 +770,10 @@ static void print_rel_vcs_link(const char *url) static int emit_css_link(struct string_list_item *s, void *arg) { + /* Do not emit anything if css= is specified. */ + if (s && *s->string == '\0') + return 0; + html(" References: <20230101214103.1E52F19A2@badger.kodafritt.se> <20230105225343.0264A262C@badger.kodafritt.se> Message-ID: <20230112013305.0b5ccab36a3a81330f91f371@kodafritt.se> Oops. I made a last minute change of the themes, and that broke things. Looks like some theme combinations don't work well. I will send an updated patch with a working theme combo + a comment about this. It could also be solved by also wrapping the light theme in a media query, but then older browsers will not show the highlighting. Regards, Samuel On Wed, 11 Jan 2023 21:56:30 +0100, "Jason A. Donenfeld" wrote: > It looks like the issue is that the string class for the light theme is: > > .highlight .s { > color: #dd2200; > background-color: #fff0f0; > } > > But for the dark theme it's: > > @media (prefers-color-scheme: dark) > .highlight .s { > color: #e6db74; > } > > And so it winds up using the dark color, but with the light > background, because the dark theme doesn't specify a background. From Jason at zx2c4.com Thu Jan 12 00:34:43 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Thu, 12 Jan 2023 01:34:43 +0100 Subject: [PATCH RESEND v2] css: Support for dark mode In-Reply-To: <20230112013305.0b5ccab36a3a81330f91f371@kodafritt.se> References: <20230101214103.1E52F19A2@badger.kodafritt.se> <20230105225343.0264A262C@badger.kodafritt.se> <20230112013305.0b5ccab36a3a81330f91f371@kodafritt.se> Message-ID: On Thu, Jan 12, 2023 at 1:33 AM Samuel Lid?n Borell wrote: > > Oops. I made a last minute change of the themes, and that broke things. Looks like some theme combinations don't work well. > > I will send an updated patch with a working theme combo + a comment about this. > > It could also be solved by also wrapping the light theme in a media query, but then older browsers will not show the highlighting. Heh, we just sent emails at the same time. See the one I just sent you -- it has a diff for your consideration. Jason From Jason at zx2c4.com Thu Jan 12 00:33:50 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Thu, 12 Jan 2023 01:33:50 +0100 Subject: [PATCH RESEND v2] css: Support for dark mode In-Reply-To: References: <20230101214103.1E52F19A2@badger.kodafritt.se> <20230105225343.0264A262C@badger.kodafritt.se> Message-ID: On Wed, Jan 11, 2023 at 09:56:30PM +0100, Jason A. Donenfeld wrote: > It looks like the issue is that the string class for the light theme is: > > .highlight .s { > color: #dd2200; > background-color: #fff0f0; > } > > But for the dark theme it's: > > @media (prefers-color-scheme: dark) > .highlight .s { > color: #e6db74; > } > > And so it winds up using the dark color, but with the light > background, because the dark theme doesn't specify a background. I fixed this with the below diff. It uses an explicit `@media (prefers-color-scheme: light) block`, which MDN says, "indicates that user has notified that they prefer an interface that has a light theme, or has not expressed an active preference." So this seems correct. However, I also order the light *after* the dark for non-media-query understanding browsers. I suspect the same should be done on all the other files. The below diff is now on git.zx2c4.com, so you can use that link earlier to see what it's like. Unfortunately, I think a lot of the rest of the styling is too dark or otherwise clashing. So you might want to give the whole thing a second pass. diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py index 672201d..fafa30e 100755 --- a/filters/syntax-highlighting.py +++ b/filters/syntax-highlighting.py @@ -53,9 +53,11 @@ except TypeError: # highlight! :-) # printout pygments' css definitions as well sys.stdout.write('') sys.stdout.write(highlight(data, lexer, formatter, outfile=None)) From levi.durfee at gmail.com Thu Jan 12 01:50:35 2023 From: levi.durfee at gmail.com (Levi Durfee) Date: Wed, 11 Jan 2023 20:50:35 -0500 Subject: Go - Serving modules In-Reply-To: <20230106221332.48de955d@thenautilus.net> References: <20230106221332.48de955d@thenautilus.net> Message-ID: I'm using scan-path to find the repositories. I'll look through the code some more to see if I can find another way. If not, I'll see if I can create a patch. On Fri, Jan 6, 2023 at 5:14 PM Gianni Ceccarelli wrote: > > On 2023-01-06 Levi Durfee wrote: > > I noticed on git.zx2c4.com that there is the "go-import" meta tag. You > > can view the source of https://git.zx2c4.com/wireguard-go to see the > > meta tag. > > > > I tried replicating this using the "head-include" config option, but I > > don't see a way to specify any repository data from a variable. > > I guess you could set ``repo.extra-head-content`` for each Go > repository (I'm a bit surprised that the two options are named differently?) > > -- > Dakkar - > GPG public key fingerprint = A071 E618 DD2C 5901 9574 > 6FE2 40EA 9883 7519 3F88 > key id = 0x75193F88 > From dakkar at thenautilus.net Thu Jan 12 09:19:54 2023 From: dakkar at thenautilus.net (Gianni Ceccarelli) Date: Thu, 12 Jan 2023 09:19:54 +0000 Subject: Go - Serving modules In-Reply-To: References: <20230106221332.48de955d@thenautilus.net> Message-ID: <20230112091954.12e648b1@exelion> On Wed, 11 Jan 2023 20:50:35 -0500 Levi Durfee wrote: > I'm using scan-path to find the repositories. Then you can set per-repository options inside each repo ``config`` file (I manage those via ``gitolite``, but you can just edit them). So for a repo at ``/var/lib/gitrepos/foo-go.git``, you'd edit ``/var/lib/gitrepos/foo-go.git/config`` and add:: [cgit] extra-head-content = But yes, having a macro-expanded ``head-include`` option would be useful. -- Dakkar - GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88 From levi.durfee at gmail.com Thu Jan 12 16:00:47 2023 From: levi.durfee at gmail.com (Levi Durfee) Date: Thu, 12 Jan 2023 11:00:47 -0500 Subject: Go - Serving modules In-Reply-To: <20230112091954.12e648b1@exelion> References: <20230106221332.48de955d@thenautilus.net> <20230112091954.12e648b1@exelion> Message-ID: Thank you! I had to use a ``cgitrc`` file in the repo directory, but I got it working. On Thu, Jan 12, 2023 at 4:20 AM Gianni Ceccarelli wrote: > > On Wed, 11 Jan 2023 20:50:35 -0500 > Levi Durfee wrote: > > > I'm using scan-path to find the repositories. > > Then you can set per-repository options inside each repo ``config`` > file (I manage those via ``gitolite``, but you can just edit them). > > So for a repo at ``/var/lib/gitrepos/foo-go.git``, you'd edit > ``/var/lib/gitrepos/foo-go.git/config`` and add:: > > [cgit] > extra-head-content = > > But yes, having a macro-expanded ``head-include`` option would be useful. > > -- > Dakkar - > GPG public key fingerprint = A071 E618 DD2C 5901 9574 > 6FE2 40EA 9883 7519 3F88 > key id = 0x75193F88 > From list at eworm.de Wed Jan 18 06:59:43 2023 From: list at eworm.de (Christian Hesse) Date: Wed, 18 Jan 2023 07:59:43 +0100 Subject: [PATCH 1/1] git: update to v2.39.1 Message-ID: <20230118065943.19819-1-list@eworm.de> From: Christian Hesse Update to git version v2.39.1, no additional changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ad825be..7b6065a 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.39.0 +GIT_VER = 2.39.1 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index c48035d..01443f0 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit c48035d29b4e524aed3a32f0403676f0d9128863 +Subproject commit 01443f01b7c6a3c6ef03268b649b119027743115 -- 2.39.1 From samuel at kodafritt.se Sun Jan 22 11:35:09 2023 From: samuel at kodafritt.se (=?UTF-8?q?Samuel=20Lid=C3=A9n=20Borell?=) Date: Sun, 22 Jan 2023 12:35:09 +0100 Subject: [PATCH v3] css: Support for dark mode In-Reply-To: References: Message-ID: <20230122122519.3D50F13F@badger.kodafritt.se> Modern browsers have a "dark mode" preference, which enables alternate styles on web sites that support this. This patch adds a dark color scheme, that is automatically activated via a CSS @media query. Older browsers that do not support color schemes will simply show the light scheme, but possibly without syntax highlighting. Note that filters that use color (such as source highlighters) and logotypes may need to be updated to work with a black background! See the updated files in the filters/ directory. Signed-off-by: Samuel Lid?n Borell --- cgit.css | 113 ++++++++++++++++++++++++++++++++ filters/html-converters/md2html | 30 ++++++++- filters/syntax-highlighting.py | 14 +++- filters/syntax-highlighting.sh | 104 ++++++++++++++++++----------- 4 files changed, 217 insertions(+), 44 deletions(-) diff --git a/cgit.css b/cgit.css index 1b848cf..50a254a 100644 --- a/cgit.css +++ b/cgit.css @@ -897,3 +897,116 @@ div#cgit table.ssdiff td.space { div#cgit table.ssdiff td.space div { min-height: 3em; } + +/* + Color overrides for browsers running in dark mode. + "only all and ..." forces very old browsers to ignore the media query: + https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#improving_compatibility_with_older_browsers +*/ +:root { color-scheme: light dark; } + at media only all and (prefers-color-scheme: dark) { + html, div#cgit { color: #eee; background: #171717; } + div#cgit a { color: #3af; } + div#cgit .diffstat-header a { color: #28d; } + div#cgit table#header td.main a { color: #eee; } + div#cgit table#header td.sub { color: #999; } + div#cgit table.tabs { border-bottom-color: #444; } + div#cgit table.tabs td a { color: #888; } + div#cgit table.tabs td a.active { color: #fff; background-color: #444; } + div#cgit div.path { color: #eee; background-color: #333; } + div#cgit div.content { border-bottom-color: #bbb; } + div#cgit table.list tr { background: #111; } + div#cgit table.list tr.logheader { background: #111; } + div#cgit table.list tr:nth-child(even) { background: #181818; } + div#cgit table.list tr:nth-child(odd) { background: #111; } + div#cgit table.list tr:hover { background: #222; } + div#cgit table.list tr.nohover { background: #111; } + div#cgit table.list tr.nohover:hover { background: #111; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #181818; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: #111; } + div#cgit table.list td.commitgraph .column1 { color: #f55; } + div#cgit table.list td.commitgraph .column2 { color: #5f5; } + div#cgit table.list td.commitgraph .column3 { color: #ff5; } + div#cgit table.list td.commitgraph .column4 { color: #55f; } + div#cgit table.list td.commitgraph .column5 { color: #f5f; } + div#cgit table.list td.commitgraph .column6 { color: #5ff; } + div#cgit table.list td a { color: #eee; } + div#cgit table.list td a.ls-dir { color: #28d; } + div#cgit table.list td a:hover { color: #3af; } + div#cgit table#downloads { border-color: #888; } + div#cgit table#downloads th { background-color: #333; } + div#cgit div#blob { border-color: #eee; } + div#cgit table.blob { border-top-color: #eee; } + div#cgit table.blob td.hashes, + div#cgit table.blob td.lines { color: #eee; } + div#cgit table.blob td.linenumbers { border-right-color: gray; } + div#cgit table.blob td.linenumbers a, + div#cgit table.ssdiff td.lineno a { color: gray; } + div#cgit table.blob td.linenumbers a:hover, + div#cgit table.ssdiff td.lineno a:hover { color: #eee; } + div#cgit table.blame div.alt:nth-child(even) { background: #222; } + div#cgit table.blame div.alt:nth-child(odd) { background: #111; } + div#cgit table.bin-blob { border-color: #eee; } + div#cgit table.bin-blob th { border-color: #888; } + div#cgit table.bin-blob td { border-left-color: #888; } + div#cgit div.cgit-panel table { border-color: #555; background-color: #282828; } + div#cgit div.notes { border-color: #661; background-color: #220; } + div#cgit table.diffstat { border-color: #555; background-color: #282828; } + div#cgit table.diffstat td span.modechange { color: #c66; } + div#cgit table.diffstat td.add a { color: #6c6; } + div#cgit table.diffstat td.del a { color: #c66; } + div#cgit table.diffstat td.upd a { color: #3af; } + div#cgit table.diffstat td.graph td.add { background-color: #3a3; } + div#cgit table.diffstat td.graph td.rem { background-color: #a33; } + div#cgit div.diffstat-summary { color: #777; } + div#cgit table.diff td div.head { color: #eee; } + div#cgit table.diff td div.hunk { color: #28d; } + div#cgit table.diff td div.add { color: #6c6; } + div#cgit table.diff td div.del { color: #c66; } + div#cgit table.list td.reposection { color: #777; } + div#cgit ul.pager a { color: #888; } + div#cgit span.age-mins { color: #7f7; } + div#cgit span.age-hours { color: #7f7; } + div#cgit span.age-days { color: #9d9; } + div#cgit span.age-weeks { color: #bbb; } + div#cgit span.age-months { color: #888; } + div#cgit span.age-years { color: #666; } + div#cgit span.insertions { color: #7f7; } + div#cgit span.deletions { color: #e33; } + div#cgit div.footer { color: #555; } + div#cgit div.footer a { color: #555; } + div#cgit a.branch-deco { color: #fff; background-color: #361; border-color: #3b2; } + div#cgit a.tag-deco { color: #fff; background-color: #650; border-color: #ba3; } + div#cgit a.tag-annotated-deco { color: #fff; background-color: #840; border-color: #b96; } + div#cgit a.remote-deco { color: #fff; background-color: #348; border-color: #67c; } + div#cgit a.deco { color: #fff; background-color: #922; border-color: #d55; } + div#cgit a.branch-deco:hover, div#cgit table.list td a.branch-deco:hover, + div#cgit a.tag-deco:hover, div#cgit table.list td a.tag-deco:hover, + div#cgit a.tag-annotated-deco:hover, div#cgit table.list td a.tag-annotated-deco:hover, + div#cgit a.remote-deco:hover, div#cgit table.list td a.remote-deco:hover, + div#cgit a.deco:hover, div#cgit table.list td a.deco:hover { color: #fff; } + div#cgit table.stats { border-color: #555; } + div#cgit table.stats th { background-color: #333; border-color: #555; } + div#cgit table.stats td { border-color: #555; } + div#cgit table.stats td.sum { color: #5C7E9B; } + div#cgit table.vgraph { border-color: #eee; } + div#cgit table.vgraph th { background-color: #111; border-color: black; } + div#cgit table.vgraph div.bar { background-color: #111; } + div#cgit table.hgraph { border-color: #eee; } + div#cgit table.hgraph th { background-color: #111; border-color: #eee; } + div#cgit table.hgraph div.bar { background-color: #111; } + div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; } + div#cgit table.ssdiff td.add { color: #eee; background: #353; } + div#cgit table.ssdiff td.add_dark { color: #eee; background: #030; } + div#cgit table.ssdiff span.add { background: #030; } + div#cgit table.ssdiff td.del { color: #eee; background: #533; } + div#cgit table.ssdiff td.del_dark { color: #eee; background: #411; } + div#cgit table.ssdiff span.del { background: #300; } + div#cgit table.ssdiff td.changed { color: #eee; background: #553; } + div#cgit table.ssdiff td.changed_dark { color: #eee; background: #330; } + div#cgit table.ssdiff td.lineno { color: #eee; background: #111; } + div#cgit table.ssdiff td.hunk { color: #eee; background: #0D3D64; border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head div.head { color: #eee; } + div#cgit table.ssdiff td.foot { border-top-color: #555; } +} diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index 59f43a8..627808a 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -4,6 +4,11 @@ import sys import io from pygments.formatters import HtmlFormatter from markdown.extensions.toc import TocExtension + +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' + sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') sys.stdout.write(''' @@ -283,10 +288,31 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div# background-color: transparent; border: none; } + at media only all and (prefers-color-scheme: dark) { +.markdown-body a.absent { color: #f33; } +.markdown-body h1 .mini-icon-link, .markdown-body h2 .mini-icon-link, .markdown-body h3 .mini-icon-link, .markdown-body h4 .mini-icon-link, .markdown-body h5 .mini-icon-link, .markdown-body h6 .mini-icon-link { color: #eee; } +div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { color: #eee; } +.markdown-body h1 { color: #eee; } +.markdown-body h2 { border-bottom-color: #333; color: #eee; } +.markdown-body h6 { color: #888; } +.markdown-body hr { border-color: #333; } +.markdown-body blockquote { border-left-color: #222; color: #888; } +.markdown-body table th, .markdown-body table td { border-color: #333; } +.markdown-body table tr { border-top-color: #333; background-color: #111; } +.markdown-body table tr:nth-child(2n) { background-color: #070707; } +.markdown-body span.frame span span { color: #ccc; } +.markdown-body code, .markdown-body tt { border-color: #151515; background-color: #070707; } +.markdown-body .highlight pre, .markdown-body pre { background-color: #070707; border-color: #333; } ''') -sys.stdout.write(HtmlFormatter(style='pastie').get_style_defs('.highlight')) +sys.stdout.write(HtmlFormatter(style=dark_style).get_style_defs('.highlight')) sys.stdout.write(''' - +} + at media (prefers-color-scheme: light) { +''') +sys.stdout.write(HtmlFormatter(style=light_style).get_style_defs('.highlight')) +sys.stdout.write(''' +} + ''') sys.stdout.write("
") sys.stdout.flush() diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py index e912594..f2c0fe1 100755 --- a/filters/syntax-highlighting.py +++ b/filters/syntax-highlighting.py @@ -29,12 +29,16 @@ from pygments.lexers import guess_lexer from pygments.lexers import guess_lexer_for_filename from pygments.formatters import HtmlFormatter +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') data = sys.stdin.read() filename = sys.argv[1] -formatter = HtmlFormatter(style='pastie', nobackground=True) +light_formatter = HtmlFormatter(style=light_style, nobackground=True) +dark_formatter = HtmlFormatter(style=dark_style, nobackground=True) try: lexer = guess_lexer_for_filename(filename, data) @@ -50,6 +54,10 @@ except TypeError: # highlight! :-) # printout pygments' css definitions as well sys.stdout.write('') -sys.stdout.write(highlight(data, lexer, formatter, outfile=None)) +sys.stdout.write(highlight(data, lexer, light_formatter, outfile=None)) diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 840bc34..5d4e7c7 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh @@ -25,6 +25,20 @@ # table.blob .kwb { color:#830000; } # table.blob .kwc { color:#000000; font-weight:bold; } # table.blob .kwd { color:#010181; } +# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# table.blob .num { color:#ff814f; } +# table.blob .esc { color:#f60; } +# table.blob .str { color:#cc0; } +# table.blob .dstr { color:#ffff7e; } +# table.blob .slc { color:#7f7c7f; } +# table.blob .com { color:#7e7c7e; } +# table.blob .dir { color:#7dff7d; } +# table.blob .sym { color:#eeeeee; } +# table.blob .kwa { color:#bb0; } +# table.blob .kwb { color:#0a0; } +# table.blob .kwc { color:#eeeeee; } +# table.blob .kwd { color:#7e7efe; } +# } # # # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/ @@ -45,45 +59,57 @@ # .hl.kwb { color:#830000; } # .hl.kwc { color:#000000; font-weight:bold; } # .hl.kwd { color:#010181; } -# -# -# Style definition file generated by highlight 3.8, http://www.andre-simon.de/ -# -# body.hl { background-color:#e0eaee; } -# pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';} -# .hl.num { color:#b07e00; } -# .hl.esc { color:#ff00ff; } -# .hl.str { color:#bf0303; } -# .hl.pps { color:#818100; } -# .hl.slc { color:#838183; font-style:italic; } -# .hl.com { color:#838183; font-style:italic; } -# .hl.ppc { color:#008200; } -# .hl.opt { color:#000000; } -# .hl.lin { color:#555555; } -# .hl.kwa { color:#000000; font-weight:bold; } -# .hl.kwb { color:#0057ae; } -# .hl.kwc { color:#000000; font-weight:bold; } -# .hl.kwd { color:#010181; } -# -# -# Style definition file generated by highlight 3.13, http://www.andre-simon.de/ -# -# body.hl { background-color:#e0eaee; } -# pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;} -# .hl.num { color:#b07e00; } -# .hl.esc { color:#ff00ff; } -# .hl.str { color:#bf0303; } -# .hl.pps { color:#818100; } -# .hl.slc { color:#838183; font-style:italic; } -# .hl.com { color:#838183; font-style:italic; } -# .hl.ppc { color:#008200; } -# .hl.opt { color:#000000; } -# .hl.ipl { color:#0057ae; } -# .hl.lin { color:#555555; } -# .hl.kwa { color:#000000; font-weight:bold; } -# .hl.kwb { color:#0057ae; } -# .hl.kwc { color:#000000; font-weight:bold; } -# .hl.kwd { color:#010181; } +# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# pre.hl { color:#eeeeee; background-color:#111; } +# .hl.num { color:#ff814f; } +# .hl.esc { color:#f60; } +# .hl.str { color:#cc0; } +# .hl.dstr { color:#ffff7e; } +# .hl.slc { color:#7f7c7f; } +# .hl.com { color:#7e7c7e; } +# .hl.dir { color:#7dff7d; } +# .hl.sym { color:#eeeeee; } +# .hl.line { color:#aaaaaa; } +# .hl.mark { background-color:#444400; } +# .hl.kwa { color:#bb0; } +# .hl.kwb { color:#a0a; } +# .hl.kwc { color:#eeeeee; } +# .hl.kwd { color:#7e7efe; } +# } +# +# +# Style definition file generated by highlight 3.8 / 3.13 / 3.41, http://www.andre-simon.de/ +# +# table.blob .num { color:#b07e00; } +# table.blob .esc { color:#ff00ff; } +# table.blob .str { color:#bf0303; } +# table.blob .pps { color:#818100; } +# table.blob .slc { color:#838183; font-style:italic; } +# table.blob .com { color:#838183; font-style:italic; } +# table.blob .ppc { color:#008200; } +# table.blob .opt { color:#000000; } +# table.blob .ipl { color:#0057ae; } +# table.blob .lin { color:#555555; } +# table.blob .kwa { color:#000000; font-weight:bold; } +# table.blob .kwb { color:#0057ae; } +# table.blob .kwc { color:#000000; font-weight:bold; } +# table.blob .kwd { color:#010181; } +# @media (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# table.blob .num { color:#ff814f; } +# table.blob .esc { color:#f60; } +# table.blob .str { color:#cc0; } +# table.blob .pps { color:#ffff7f; } +# table.blob .slc { color:#7f7c7f; } +# table.blob .com { color:#7e7c7e; } +# table.blob .ppc { color:#8dd; } +# table.blob .opt { color:#eeeeee; } +# table.blob .ipl { color:#51a8ff; } +# table.blob .lin { color:#aaaaaa; } +# table.blob .kwa { color:#bb0; } +# table.blob .kwb { color:#0a0; } +# table.blob .kwc { color:#eeeeee; } +# table.blob .kwd { color:#7e7efe; } +# } # # # The following environment variables can be used to retrieve the configuration -- 2.30.2 From samuel at kodafritt.se Sun Jan 22 13:04:37 2023 From: samuel at kodafritt.se (Samuel =?ISO-8859-1?Q?Lid=E9n?= Borell) Date: Sun, 22 Jan 2023 14:04:37 +0100 Subject: [PATCH v3] css: Support for dark mode In-Reply-To: <20230122122519.3D50F13F@badger.kodafritt.se> References: <20230122122519.3D50F13F@badger.kodafritt.se> Message-ID: <20230122140437.4b530f77458029e4ae43c229@kodafritt.se> On Sun, 22 Jan 2023 12:35:09 +0100, Samuel Lid?n Borell wrote: > Modern browsers have a "dark mode" preference, which enables alternate > styles on web sites that support this. > > This patch adds a dark color scheme, that is automatically activated > via a CSS @media query. > > Older browsers that do not support color schemes will simply show the > light scheme, but possibly without syntax highlighting. > > Note that filters that use color (such as source highlighters) and > logotypes may need to be updated to work with a black background! > See the updated files in the filters/ directory. Just a description of the changes from the previous version of the patch: * Improved the dark color scheme * Fixed white pixels around code blocks in markdown pages * Fixed invisible text in formatters by wrapping even the light CSS in media queries. Unfortunately this disables highlighting on old browsers, which instead show black text. * Fixed CSS for highlight 3 * Added "only all and" to the dark media query, so it gets ignored by (extremely) old browsers. Tested on Firefox 102.7.0 ESR, Firefox 109, Chromium 109 and Netsurf 3.10. Netsurf is a browser that does not support color schemes, and defaults to the light theme. Firefox has a "resist fingerprinting" mode, in which it always uses the light theme. Regards, Samuel From spam at chonkyrabbit.eu Thu Jan 26 17:42:19 2023 From: spam at chonkyrabbit.eu (Spam Receiver) Date: Thu, 26 Jan 2023 18:42:19 +0100 Subject: configuring appearance from within repository Message-ID: <0cb387da2e77641eee1d6ea9f5791faae4bdf0e2.camel@chonkyrabbit.eu> Hey there, I recently found cgit and I'm very happy about it's performance, ease of use and overall simplicity. There is only one thing that I did not manage to set up yet: I want to configure repo-specific settings from within the repo itself. For this I tried to enable the git config parsing from within cgit, and tried to add the following to .git/config [gitweb] owner = test name = test But nothing changed in the web interface. My next attempt involved the cgitrc in the repo folder, where I added name = test But this also did not change anything, even though the manpages indicate that it should: When the option "scan-path" is used to auto-discover git repositories, cgit will try to parse the file "cgitrc" within any found repository. Such a repo- specific config file may contain any of the repo-specific options described above, except "repo.url" and "repo.path". Additionally, the "filter" options are only acknowledged in repo-specific config files when "enable-filter- overrides" is set to "1". The only thing that cgit wanted to scan was the .git/description file. Even removing that did not enable the above options to appear in the repo list. My current setup consists of bare repositories in the scan path. I want to configure cgit from the repos themselves to make the setup easier to maintain using scripts. What did I do wrong here? There is barely any information about cgit on the internet apart from the manpages, so I needed to resort to request help here. If you need anything else, hit me up! I'll be sure to respond as soon as I can! Thanks! From john at keeping.me.uk Thu Jan 26 17:58:00 2023 From: john at keeping.me.uk (John Keeping) Date: Thu, 26 Jan 2023 17:58:00 +0000 Subject: configuring appearance from within repository In-Reply-To: <0cb387da2e77641eee1d6ea9f5791faae4bdf0e2.camel@chonkyrabbit.eu> References: <0cb387da2e77641eee1d6ea9f5791faae4bdf0e2.camel@chonkyrabbit.eu> Message-ID: On Thu, Jan 26, 2023 at 06:42:19PM +0100, Spam Receiver wrote: > Hey there, I recently found cgit and I'm very happy about it's > performance, ease of use and overall simplicity. There is only one > thing that I did not manage to set up yet: > > I want to configure repo-specific settings from within the repo itself. > For this I tried to enable the git config parsing from within cgit, and > tried to add the following to .git/config To confirm, you have "enable-git-config = 1" in the global cgitrc *before* the scan-path directory? > [gitweb] > owner = test name = test There should be a line break between "test" and "name" here, right? > But nothing changed in the web interface. My next attempt involved the > cgitrc in the repo folder, where I added > > name = test There must not be any spaces around "=" in cgitrc files, so this should be: name=test Regards, John From Jason at zx2c4.com Fri Jan 27 20:42:58 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Fri, 27 Jan 2023 14:42:58 -0600 Subject: [PATCH v3] css: Support for dark mode In-Reply-To: <20230122122519.3D50F13F@badger.kodafritt.se> References: <20230122122519.3D50F13F@badger.kodafritt.se> Message-ID: It still feels like the table shading is now way too dark in dark mode. For all those various grays, there might be some transformation to consider where you want the same distance from black that it formerly had from white. From code at mmayer.net Fri Jan 27 23:15:42 2023 From: code at mmayer.net (Markus Mayer) Date: Fri, 27 Jan 2023 15:15:42 -0800 Subject: [PATCH 0/1] cgit for macOS Message-ID: <20230127231543.17977-1-code@mmayer.net> Hi all, I first proposed this change over two and a half years ago.[1] Unfortunately, it never seemed to gain any traction. I figured I'd give it another shot. Adding this open-source implementation of memrchr() allows for CGIT to be built on macOS. This can be very convenient, be it for CGIT development or to have a local CGIT instance that'll work even without network connection. The change seems quite small and well contained (less than 60 lines of code added; no other platform affected), and it enables an additional platform/OS for CGIT. Proof that it actually builds (x86 works too, of course): $ file cgit cgit: Mach-O 64-bit executable arm64 $ otool -L cgit cgit: /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (...) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11) /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0) Regards, -Markus [1] https://www.mail-archive.com/cgit at lists.zx2c4.com/msg03014.html Markus Mayer (1): global: provide memrchr implementation for macOS cgit.h | 4 ++++ cgit.mk | 9 +++++++++ memrchr.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 memrchr.c -- 2.39.0 From code at mmayer.net Fri Jan 27 23:15:43 2023 From: code at mmayer.net (Markus Mayer) Date: Fri, 27 Jan 2023 15:15:43 -0800 Subject: [PATCH 1/1] global: provide memrchr implementation for macOS In-Reply-To: <20230127231543.17977-1-code@mmayer.net> References: <20230127231543.17977-1-code@mmayer.net> Message-ID: <20230127231543.17977-2-code@mmayer.net> macOS doesn't come with a memrchr() of its own, so let's provide an implementation it can use. memrchr.c was taken from Apple's own open source site. https://opensource.apple.com/source/sudo/sudo-87.80.2/sudo/lib/util/memrchr.c It was modified in the following ways: - Removed unnecessary includes (config.h, sudo_compat.h). - Removed unnecessary include guard (HAVE_MEMRCHR). - Removed comment referencing an unrelated project. - Added comment mentioning URL to the original location of the file. Signed-off-by: Markus Mayer --- cgit.h | 4 ++++ cgit.mk | 9 +++++++++ memrchr.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 memrchr.c diff --git a/cgit.h b/cgit.h index ddd2ccba0b88..19f810f22b61 100644 --- a/cgit.h +++ b/cgit.h @@ -397,4 +397,8 @@ extern char *expand_macros(const char *txt); extern char *get_mimetype_for_filename(const char *filename); +#ifdef NEED_MEMRCHR +extern void *memrchr(const void *s, int c, size_t n); +#endif + #endif /* CGIT_H */ diff --git a/cgit.mk b/cgit.mk index 3fcc1ca31440..f85018c38b78 100644 --- a/cgit.mk +++ b/cgit.mk @@ -63,10 +63,19 @@ ifeq ($(uname_S),Linux) HAVE_LINUX_SENDFILE = YesPlease endif +ifeq ($(uname_S),Darwin) + IS_DARWIN = yes +endif + ifdef HAVE_LINUX_SENDFILE CGIT_CFLAGS += -DHAVE_LINUX_SENDFILE endif +ifdef IS_DARWIN + CGIT_CFLAGS += -DNEED_MEMRCHR + CGIT_OBJ_NAMES += memrchr.o +endif + CGIT_OBJ_NAMES += cgit.o CGIT_OBJ_NAMES += cache.o CGIT_OBJ_NAMES += cmd.o diff --git a/memrchr.c b/memrchr.c new file mode 100644 index 000000000000..75c6dcde7432 --- /dev/null +++ b/memrchr.c @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2007, 2010-2014 + * Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Imported into CGIT from + * https://opensource.apple.com/source/sudo/sudo-87.80.2/sudo/lib/util/memrchr.c + */ + +#include + +/* + * Reverse memchr() + * Find the last occurrence of 'c' in the buffer 's' of size 'n'. + */ +void * +memrchr(const void *s, int c, size_t n) +{ + const unsigned char *cp; + + if (n != 0) { + cp = (unsigned char *)s + n; + do { + if (*(--cp) == (unsigned char)c) + return (void *)cp; + } while (--n != 0); + } + return (void *)0; +} -- 2.39.0 From code at mmayer.net Sat Jan 28 00:35:07 2023 From: code at mmayer.net (Markus Mayer) Date: Fri, 27 Jan 2023 16:35:07 -0800 Subject: [PATCH 1/1] global: provide memrchr implementation for macOS In-Reply-To: References: <20230127231543.17977-1-code@mmayer.net> <20230127231543.17977-2-code@mmayer.net> Message-ID: Hi Alex, > This code seems overly complex to me. A do-while seems unintuitive when > you're not performing at least 1 iteration, and having an if that is > basically the same operation as the while condition seems weird. Maybe > I'm missing something, but it looks like it can be written more readable as: I have no objections to changing the code. For my initial submission, I figured I'd use an implementation that comes directly from Apple's own open source server. But if the consensus is to tweak the code to make it smaller / faster / more readable, that's alright by me. I only want CGIT to build on macOS. :-) > void * > memrchr(const void *s, int c, size_t n) > { > unsigned char ch; > const unsigned char *cp; > > ch = c; > > cp = s; > for (cp += n; n != 0; n--) { > cp--; > if (*cp == ch) > return (void *) cp; > } > > return NULL; > } Let me play around with this. > Clang produces similar assembly code for both. GCC however produces > smaller code for the for loop. Thanks for the feedback. Regards, -Markus From samuel at kodafritt.se Sun Jan 29 17:07:50 2023 From: samuel at kodafritt.se (Samuel =?ISO-8859-1?Q?Lid=E9n?= Borell) Date: Sun, 29 Jan 2023 18:07:50 +0100 Subject: [PATCH v3] css: Support for dark mode In-Reply-To: References: <20230122122519.3D50F13F@badger.kodafritt.se> Message-ID: <20230129180750.c20b661a91bb26447422c66c@kodafritt.se> On Fri, 27 Jan 2023 14:42:58 -0600, "Jason A. Donenfeld" wrote: > It still feels like the table shading is now way too dark in dark > mode. For all those various grays, there might be some transformation > to consider where you want the same distance from black that it > formerly had from white. Good point. I've fixed this and I will send v4 shortly. It is the same distance now (in the RGB value). Other improvements: * The .list table background is fixed. * Support for non-media-query-supporting browsers in syntax-highlight.sh also. I agree it would be nice to have an automatic transformation, i.e. darkcolor=f(lightcolor). Unfortunately I don't know how to do that. Color is a quite tricky subject because RGB is non-linear, and some colors (e.g. green #00ff00) are perceived as brigther than others (e.g. blue #0000ff). In fact, v1 of the patch was simply an inversion + re-sorting of the RGB components (to preserve nuance), and the looks of that was sub-optimal. Regards, Samuel From samuel at kodafritt.se Sun Jan 29 16:55:29 2023 From: samuel at kodafritt.se (=?UTF-8?q?Samuel=20Lid=C3=A9n=20Borell?=) Date: Sun, 29 Jan 2023 17:55:29 +0100 Subject: [PATCH v4] css: Support for dark mode In-Reply-To: <20230129180750.c20b661a91bb26447422c66c@kodafritt.se> References: <20230129180750.c20b661a91bb26447422c66c@kodafritt.se> Message-ID: <20230129171057.E6DACF8B@badger.kodafritt.se> Modern browsers have a "dark mode" preference, which enables alternate styles on web sites that support this. This patch adds a dark color scheme, that is automatically activated via a CSS @media query. Older browsers that do not support color schemes will simply show the light scheme, but possibly without syntax highlighting. Note that filters that use color (such as source highlighters) and logotypes may need to be updated to work with a black background! See the updated files in the filters/ directory. Signed-off-by: Samuel Lid?n Borell --- cgit.css | 113 ++++++++++++++++++++++++++++++++ filters/html-converters/md2html | 30 ++++++++- filters/syntax-highlighting.py | 14 +++- filters/syntax-highlighting.sh | 104 ++++++++++++++++++----------- 4 files changed, 217 insertions(+), 44 deletions(-) diff --git a/cgit.css b/cgit.css index 1b848cf..a94ffe4 100644 --- a/cgit.css +++ b/cgit.css @@ -897,3 +897,116 @@ div#cgit table.ssdiff td.space { div#cgit table.ssdiff td.space div { min-height: 3em; } + +/* + Color overrides for browsers running in dark mode. + "only all and ..." forces very old browsers to ignore the media query: + https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#improving_compatibility_with_older_browsers +*/ +:root { color-scheme: light dark; } + at media only all and (prefers-color-scheme: dark) { + html, div#cgit { color: #eee; background: #171717; } + div#cgit a { color: #3af; } + div#cgit .diffstat-header a { color: #28d; } + div#cgit table#header td.main a { color: #eee; } + div#cgit table#header td.sub { color: #999; } + div#cgit table.tabs { border-bottom-color: #444; } + div#cgit table.tabs td a { color: #888; } + div#cgit table.tabs td a.active { color: #fff; background-color: #444; } + div#cgit div.path { color: #eee; background-color: #333; } + div#cgit div.content { border-bottom-color: #bbb; } + div#cgit table.list tr { background: #171717; } + div#cgit table.list tr.logheader { background: #171717; } + div#cgit table.list tr:nth-child(even) { background: #171717; } + div#cgit table.list tr:nth-child(odd) { background: #1f1f1f; } + div#cgit table.list tr:hover { background: #333; } + div#cgit table.list tr.nohover { background: #171717; } + div#cgit table.list tr.nohover:hover { background: #171717; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #171717; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: #1f1f1f; } + div#cgit table.list td.commitgraph .column1 { color: #f55; } + div#cgit table.list td.commitgraph .column2 { color: #5f5; } + div#cgit table.list td.commitgraph .column3 { color: #ff5; } + div#cgit table.list td.commitgraph .column4 { color: #55f; } + div#cgit table.list td.commitgraph .column5 { color: #f5f; } + div#cgit table.list td.commitgraph .column6 { color: #5ff; } + div#cgit table.list td a { color: #eee; } + div#cgit table.list td a.ls-dir { color: #28d; } + div#cgit table.list td a:hover { color: #3af; } + div#cgit table#downloads { border-color: #888; } + div#cgit table#downloads th { background-color: #333; } + div#cgit div#blob { border-color: #eee; } + div#cgit table.blob { border-top-color: #eee; } + div#cgit table.blob td.hashes, + div#cgit table.blob td.lines { color: #eee; } + div#cgit table.blob td.linenumbers { border-right-color: gray; } + div#cgit table.blob td.linenumbers a, + div#cgit table.ssdiff td.lineno a { color: gray; } + div#cgit table.blob td.linenumbers a:hover, + div#cgit table.ssdiff td.lineno a:hover { color: #eee; } + div#cgit table.blame div.alt:nth-child(even) { background: #171717; } + div#cgit table.blame div.alt:nth-child(odd) { background: #1f1f1f; } + div#cgit table.bin-blob { border-color: #eee; } + div#cgit table.bin-blob th { border-color: #888; } + div#cgit table.bin-blob td { border-left-color: #888; } + div#cgit div.cgit-panel table { border-color: #555; background-color: #282828; } + div#cgit div.notes { border-color: #661; background-color: #220; } + div#cgit table.diffstat { border-color: #555; background-color: #282828; } + div#cgit table.diffstat td span.modechange { color: #c66; } + div#cgit table.diffstat td.add a { color: #6c6; } + div#cgit table.diffstat td.del a { color: #c66; } + div#cgit table.diffstat td.upd a { color: #3af; } + div#cgit table.diffstat td.graph td.add { background-color: #3a3; } + div#cgit table.diffstat td.graph td.rem { background-color: #a33; } + div#cgit div.diffstat-summary { color: #777; } + div#cgit table.diff td div.head { color: #eee; } + div#cgit table.diff td div.hunk { color: #28d; } + div#cgit table.diff td div.add { color: #6c6; } + div#cgit table.diff td div.del { color: #c66; } + div#cgit table.list td.reposection { color: #777; } + div#cgit ul.pager a { color: #888; } + div#cgit span.age-mins { color: #7f7; } + div#cgit span.age-hours { color: #7f7; } + div#cgit span.age-days { color: #9d9; } + div#cgit span.age-weeks { color: #bbb; } + div#cgit span.age-months { color: #888; } + div#cgit span.age-years { color: #666; } + div#cgit span.insertions { color: #7f7; } + div#cgit span.deletions { color: #e33; } + div#cgit div.footer { color: #555; } + div#cgit div.footer a { color: #555; } + div#cgit a.branch-deco { color: #fff; background-color: #361; border-color: #3b2; } + div#cgit a.tag-deco { color: #fff; background-color: #650; border-color: #ba3; } + div#cgit a.tag-annotated-deco { color: #fff; background-color: #840; border-color: #b96; } + div#cgit a.remote-deco { color: #fff; background-color: #348; border-color: #67c; } + div#cgit a.deco { color: #fff; background-color: #922; border-color: #d55; } + div#cgit a.branch-deco:hover, div#cgit table.list td a.branch-deco:hover, + div#cgit a.tag-deco:hover, div#cgit table.list td a.tag-deco:hover, + div#cgit a.tag-annotated-deco:hover, div#cgit table.list td a.tag-annotated-deco:hover, + div#cgit a.remote-deco:hover, div#cgit table.list td a.remote-deco:hover, + div#cgit a.deco:hover, div#cgit table.list td a.deco:hover { color: #fff; } + div#cgit table.stats { border-color: #555; } + div#cgit table.stats th { background-color: #333; border-color: #555; } + div#cgit table.stats td { border-color: #555; } + div#cgit table.stats td.sum { color: #5C7E9B; } + div#cgit table.vgraph { border-color: #eee; } + div#cgit table.vgraph th { background-color: #1f1f1f; border-color: black; } + div#cgit table.vgraph div.bar { background-color: #1f1f1f; } + div#cgit table.hgraph { border-color: #eee; } + div#cgit table.hgraph th { background-color: #1f1f1f; border-color: #eee; } + div#cgit table.hgraph div.bar { background-color: #1f1f1f; } + div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; } + div#cgit table.ssdiff td.add { color: #eee; background: #353; } + div#cgit table.ssdiff td.add_dark { color: #eee; background: #030; } + div#cgit table.ssdiff span.add { background: #030; } + div#cgit table.ssdiff td.del { color: #eee; background: #533; } + div#cgit table.ssdiff td.del_dark { color: #eee; background: #411; } + div#cgit table.ssdiff span.del { background: #300; } + div#cgit table.ssdiff td.changed { color: #eee; background: #553; } + div#cgit table.ssdiff td.changed_dark { color: #eee; background: #330; } + div#cgit table.ssdiff td.lineno { color: #eee; background: #1f1f1f; } + div#cgit table.ssdiff td.hunk { color: #eee; background: #0D3D64; border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head div.head { color: #eee; } + div#cgit table.ssdiff td.foot { border-top-color: #555; } +} diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index 59f43a8..627808a 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -4,6 +4,11 @@ import sys import io from pygments.formatters import HtmlFormatter from markdown.extensions.toc import TocExtension + +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' + sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') sys.stdout.write(''' @@ -283,10 +288,31 @@ div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div# background-color: transparent; border: none; } + at media only all and (prefers-color-scheme: dark) { +.markdown-body a.absent { color: #f33; } +.markdown-body h1 .mini-icon-link, .markdown-body h2 .mini-icon-link, .markdown-body h3 .mini-icon-link, .markdown-body h4 .mini-icon-link, .markdown-body h5 .mini-icon-link, .markdown-body h6 .mini-icon-link { color: #eee; } +div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { color: #eee; } +.markdown-body h1 { color: #eee; } +.markdown-body h2 { border-bottom-color: #333; color: #eee; } +.markdown-body h6 { color: #888; } +.markdown-body hr { border-color: #333; } +.markdown-body blockquote { border-left-color: #222; color: #888; } +.markdown-body table th, .markdown-body table td { border-color: #333; } +.markdown-body table tr { border-top-color: #333; background-color: #111; } +.markdown-body table tr:nth-child(2n) { background-color: #070707; } +.markdown-body span.frame span span { color: #ccc; } +.markdown-body code, .markdown-body tt { border-color: #151515; background-color: #070707; } +.markdown-body .highlight pre, .markdown-body pre { background-color: #070707; border-color: #333; } ''') -sys.stdout.write(HtmlFormatter(style='pastie').get_style_defs('.highlight')) +sys.stdout.write(HtmlFormatter(style=dark_style).get_style_defs('.highlight')) sys.stdout.write(''' - +} + at media (prefers-color-scheme: light) { +''') +sys.stdout.write(HtmlFormatter(style=light_style).get_style_defs('.highlight')) +sys.stdout.write(''' +} + ''') sys.stdout.write("
") sys.stdout.flush() diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py index e912594..f2c0fe1 100755 --- a/filters/syntax-highlighting.py +++ b/filters/syntax-highlighting.py @@ -29,12 +29,16 @@ from pygments.lexers import guess_lexer from pygments.lexers import guess_lexer_for_filename from pygments.formatters import HtmlFormatter +# The dark style is automatically selected if the browser is in dark mode +light_style='pastie' +dark_style='monokai' sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') data = sys.stdin.read() filename = sys.argv[1] -formatter = HtmlFormatter(style='pastie', nobackground=True) +light_formatter = HtmlFormatter(style=light_style, nobackground=True) +dark_formatter = HtmlFormatter(style=dark_style, nobackground=True) try: lexer = guess_lexer_for_filename(filename, data) @@ -50,6 +54,10 @@ except TypeError: # highlight! :-) # printout pygments' css definitions as well sys.stdout.write('') -sys.stdout.write(highlight(data, lexer, formatter, outfile=None)) +sys.stdout.write(highlight(data, lexer, light_formatter, outfile=None)) diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 840bc34..0429b0f 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh @@ -25,6 +25,20 @@ # table.blob .kwb { color:#830000; } # table.blob .kwc { color:#000000; font-weight:bold; } # table.blob .kwd { color:#010181; } +# @media only all and (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# table.blob .num { color:#ff814f; } +# table.blob .esc { color:#f60; } +# table.blob .str { color:#cc0; } +# table.blob .dstr { color:#ffff7e; } +# table.blob .slc { color:#7f7c7f; } +# table.blob .com { color:#7e7c7e; } +# table.blob .dir { color:#7dff7d; } +# table.blob .sym { color:#eeeeee; } +# table.blob .kwa { color:#bb0; } +# table.blob .kwb { color:#0a0; } +# table.blob .kwc { color:#eeeeee; } +# table.blob .kwd { color:#7e7efe; } +# } # # # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/ @@ -45,45 +59,57 @@ # .hl.kwb { color:#830000; } # .hl.kwc { color:#000000; font-weight:bold; } # .hl.kwd { color:#010181; } -# -# -# Style definition file generated by highlight 3.8, http://www.andre-simon.de/ -# -# body.hl { background-color:#e0eaee; } -# pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';} -# .hl.num { color:#b07e00; } -# .hl.esc { color:#ff00ff; } -# .hl.str { color:#bf0303; } -# .hl.pps { color:#818100; } -# .hl.slc { color:#838183; font-style:italic; } -# .hl.com { color:#838183; font-style:italic; } -# .hl.ppc { color:#008200; } -# .hl.opt { color:#000000; } -# .hl.lin { color:#555555; } -# .hl.kwa { color:#000000; font-weight:bold; } -# .hl.kwb { color:#0057ae; } -# .hl.kwc { color:#000000; font-weight:bold; } -# .hl.kwd { color:#010181; } -# -# -# Style definition file generated by highlight 3.13, http://www.andre-simon.de/ -# -# body.hl { background-color:#e0eaee; } -# pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;} -# .hl.num { color:#b07e00; } -# .hl.esc { color:#ff00ff; } -# .hl.str { color:#bf0303; } -# .hl.pps { color:#818100; } -# .hl.slc { color:#838183; font-style:italic; } -# .hl.com { color:#838183; font-style:italic; } -# .hl.ppc { color:#008200; } -# .hl.opt { color:#000000; } -# .hl.ipl { color:#0057ae; } -# .hl.lin { color:#555555; } -# .hl.kwa { color:#000000; font-weight:bold; } -# .hl.kwb { color:#0057ae; } -# .hl.kwc { color:#000000; font-weight:bold; } -# .hl.kwd { color:#010181; } +# @media only all and (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# pre.hl { color:#eeeeee; background-color:#111; } +# .hl.num { color:#ff814f; } +# .hl.esc { color:#f60; } +# .hl.str { color:#cc0; } +# .hl.dstr { color:#ffff7e; } +# .hl.slc { color:#7f7c7f; } +# .hl.com { color:#7e7c7e; } +# .hl.dir { color:#7dff7d; } +# .hl.sym { color:#eeeeee; } +# .hl.line { color:#aaaaaa; } +# .hl.mark { background-color:#444400; } +# .hl.kwa { color:#bb0; } +# .hl.kwb { color:#a0a; } +# .hl.kwc { color:#eeeeee; } +# .hl.kwd { color:#7e7efe; } +# } +# +# +# Style definition file generated by highlight 3.8 / 3.13 / 3.41, http://www.andre-simon.de/ +# +# table.blob .num { color:#b07e00; } +# table.blob .esc { color:#ff00ff; } +# table.blob .str { color:#bf0303; } +# table.blob .pps { color:#818100; } +# table.blob .slc { color:#838183; font-style:italic; } +# table.blob .com { color:#838183; font-style:italic; } +# table.blob .ppc { color:#008200; } +# table.blob .opt { color:#000000; } +# table.blob .ipl { color:#0057ae; } +# table.blob .lin { color:#555555; } +# table.blob .kwa { color:#000000; font-weight:bold; } +# table.blob .kwb { color:#0057ae; } +# table.blob .kwc { color:#000000; font-weight:bold; } +# table.blob .kwd { color:#010181; } +# @media only all and (prefers-color-scheme: dark) { /* cgit addition for dark mode */ +# table.blob .num { color:#ff814f; } +# table.blob .esc { color:#f60; } +# table.blob .str { color:#cc0; } +# table.blob .pps { color:#ffff7f; } +# table.blob .slc { color:#7f7c7f; } +# table.blob .com { color:#7e7c7e; } +# table.blob .ppc { color:#8dd; } +# table.blob .opt { color:#eeeeee; } +# table.blob .ipl { color:#51a8ff; } +# table.blob .lin { color:#aaaaaa; } +# table.blob .kwa { color:#bb0; } +# table.blob .kwb { color:#0a0; } +# table.blob .kwc { color:#eeeeee; } +# table.blob .kwd { color:#7e7efe; } +# } # # # The following environment variables can be used to retrieve the configuration -- 2.30.2 From code at mmayer.net Sun Jan 29 21:43:29 2023 From: code at mmayer.net (Markus Mayer) Date: Sun, 29 Jan 2023 13:43:29 -0800 Subject: [PATCH 1/1] global: provide memrchr implementation for macOS In-Reply-To: References: <20230127231543.17977-1-code@mmayer.net> <20230127231543.17977-2-code@mmayer.net> Message-ID: On Fri, 27 Jan 2023 at 17:16, Glenn Strauss wrote: > > Fun! A small exercise for comparison if you like. > Cheers, Glenn > > void * > memrchr(const void *s, int c, size_t n) > { > const unsigned char *cp = (const unsigned char *)s + n; > const unsigned char ch = (unsigned char)c; > while (s != cp) { > if (*(--cp) == ch) > return (void *)cp; > } > return NULL; > } Hi all, As promised, I played around a bit. I ran a few experiments with different memrchr() implementations. Everything I did can be found here: https://github.com/mmayer/cgit/tree/memrchr-compare The test-specific code is in the memrchr_test folder[1] within that repo. The four implementations I tried are: memrchr: the original implementation (from Apple's sudo command) that I submitted as v1 memrchr2: Alejandro's suggestion memrchr3: Glen's suggestion memrchr4: for added fun, musl-libc's implementation[2] I also checked the object and assembly files into the repo, so it's easier to look at them if anybody wants to. They live in the memrchr_test/output folder. Here are the results for ARM and x86, both in assembly/object size and runtime. ARM # Object size of memrchr and memrchr2 is the same -rw-r--r-- 1 mmayer staff 552 29 Jan 09:52 memrchr.o -rw-r--r-- 1 mmayer staff 552 29 Jan 09:52 memrchr2.o -rw-r--r-- 1 mmayer staff 544 29 Jan 09:52 memrchr3.o -rw-r--r-- 1 mmayer staff 544 29 Jan 09:52 memrchr4.o # Assembly source of memrchr2 is larger than memrchr -rw-r--r-- 1 mmayer staff 694 29 Jan 09:52 memrchr2.s -rw-r--r-- 1 mmayer staff 691 29 Jan 09:52 memrchr.s -rw-r--r-- 1 mmayer staff 655 29 Jan 09:52 memrchr3.s -rw-r--r-- 1 mmayer staff 655 29 Jan 09:52 memrchr4.s execution time: 18.61453 seconds execution time: 15.39163 seconds execution time: 13.56957 seconds execution time: 13.55493 seconds x86 -rw-r--r-- 1 mmayer staff 656 29 Jan 10:02 memrchr.o -rw-r--r-- 1 mmayer staff 656 29 Jan 10:02 memrchr2.o -rw-r--r-- 1 mmayer staff 656 29 Jan 10:02 memrchr3.o -rw-r--r-- 1 mmayer staff 648 29 Jan 10:02 memrchr4.o -rw-r--r-- 1 mmayer staff 835 29 Jan 10:02 memrchr.s -rw-r--r-- 1 mmayer staff 835 29 Jan 10:02 memrchr2.s -rw-r--r-- 1 mmayer staff 825 29 Jan 10:02 memrchr3.s -rw-r--r-- 1 mmayer staff 818 29 Jan 10:02 memrchr4.s execution time: 20.29937 seconds execution time: 23.67755 seconds execution time: 12.59514 seconds execution time: 11.38668 seconds As you can see, musl-libc provides the smallest implementation that is also the fastest. This is true for ARM and x86. So, I guess it makes the most sense to pick that (memrchr4.c in my experiments). The code is under a MIT license, which I assume is fine for CGIT. What does everybody think? Regards, -Markus [1] https://github.com/mmayer/cgit/tree/memrchr-compare/memrchr_test [2] https://git.musl-libc.org/cgit/musl/tree/src/string/memrchr.c