rset=UTF-8
Content-Disposition: inline; filename="c366bd6fa88fb7dbe1e42c84d56e2bda0b1682c5..521e10c884055c800078e6dada97ccf6c5193aad.patch"
Last-Modified: Sat, 04 Jan 2025 00:48:56 GMT
Expires: Sat, 04 Jan 2025 04:48:56 GMT

From 521e10c884055c800078e6dada97ccf6c5193aad Mon Sep 17 00:00:00 2001
From: Jason A. Donenfeld
Date: Tue, 9 Oct 2012 06:56:14 -0400
Subject: scan-tree: Unify gitweb.* and cgit.* settings into one config option.

After some back and forth with Jamie and René, it looks like the git
config semantics are going to be like this:

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

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

The order of operations is as follows:

- git config settings are applied in the order that they exist in
  the git config file
- if the owner is not set from git config, get the owner using the
  usual getpwuid call
- if the description is not set from git config, look inside the
  static $path/description file
- if section-from-path=1, override whatever previous settings were
  inside of git config using the section-from-path logic
- parse $path/cgitrc for local repo.* settings, that override all
  previous settings
---
 cgit.c       | 10 +++-------
 cgit.h       |  5 ++---
 cgitrc.5.txt | 28 ++++++++++------------------
 scan-tree.c  | 48 +++++++++++++++++++-----------------------------
 shared.c     |  3 ++-
 5 files changed, 36 insertions(+), 58 deletions(-)

diff --git a/cgit.c b/cgit.c
index a8dda23..d699cb6 100644
--- a/cgit.c
+++ b/cgit.c
@@ -163,10 +163,6 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
 	else if (!strcmp(name, "enable-filter-overrides"))
 		ctx.cfg.enable_filter_overrides = atoi(value);
-	else if (!strcmp(name, "enable-gitweb-desc"))
-		ctx.cfg.enable_gitweb_desc = atoi(value);
-	else if (!strcmp(name, "enable-gitweb-owner"))
-		ctx.cfg.enable_gitweb_owner = atoi(value);
 	else if (!strcmp(name, "enable-http-clone"))
 		ctx.cfg.enable_http_clone = atoi(value);
 	else if (!strcmp(name, "enable-index-links"))
@@ -183,6 +179,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.enable_subject_links = atoi(value);
 	else if (!strcmp(name, "enable-tree-linenumbers"))
 		ctx.cfg.enable_tree_linenumbers = atoi(value);
+	else if (!strcmp(name, "enable-git-config"))
+		ctx.cfg.enable_git_config = atoi(value);
 	else if (!strcmp(name, "max-stats"))
 		ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
 	else if (!strcmp(name, "cache-size"))
@@ -343,11 +341,9 @@ static void prepare_context(struct cgit_context *ctx)
 	ctx->cfg.css = "/cgit.css";
 	ctx->cfg.logo = "/cgit.png";
 	ctx->cfg.local_time = 0;
-	ctx->cfg.enable_gitweb_desc = 1;
-	ctx->cfg.enable_gitweb_owner = 1;
-	ctx->cfg.enable_gitweb_section = 1;
 	ctx->cfg.enable_http_clone = 1;
 	ctx->cfg.enable_tree_linenumbers = 1;
+	ctx->cfg.enable_git_config = 0;
 	ctx->cfg.max_repo_count = 50;
 	ctx->cfg.max_commit_count = 50;
 	ctx->cfg.max_lock_attempts = 5;
diff --git a/cgit.h b/cgit.h
index 8846e88..2742058 100644
--- a/cgit.h
+++ b/cgit.h
@@ -200,9 +200,6 @@ struct cgit_config {
 	int case_sensitive_sort;
 	int embedded;
 	int enable_filter_overrides;
-	int enable_gitweb_owner;
-	int enable_gitweb_desc;
-	int enable_gitweb_section;
 	int enable_http_clone;
 	int enable_index_links;
 	int enable_commit_graph;
@@ -211,6 +208,7 @@ struct cgit_config {
 	int enable_remote_branches;
 	int enable_subject_links;
 	int enable_tree_linenumbers;
+	int enable_git_config;
 	int local_time;
 	int max_atom_items;
 	int max_repo_count;
@@ -285,6 +283,7 @@ extern struct cgit_repolist cgit_repolist;
 extern struct cgit_context ctx;
 extern const struct cgit_snapshot_format cgit_snapshot_formats[];
 
+extern char *cgit_default_repo_desc;
 extern struct cgit_repo *cgit_add_repo(const char *url);
 extern struct cgit_repo *cgit_get_repoinfo(const char *url);
 extern void cgit_repo_config_cb(const char *name, const char *value);
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 7e1a93a..278de90 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -110,24 +110,6 @@ <style>pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="ch">#!/bin/sh</span>
<span class="c1"># This script can be used to implement syntax highlighting in the cgit</span>
<span class="c1"># tree-view by refering to this file with the source-filter or repo.source-</span>
<span class="c1"># filter options in cgitrc.</span>
<span class="c1">#</span>
<span class="c1"># This script requires a shell supporting the ${var##pattern} syntax.</span>
<span class="c1"># It is supported by at least dash and bash, however busybox environments</span>
<span class="c1"># might have to use an external call to sed instead.</span>
<span class="c1">#</span>
<span class="c1"># Note: the highlight command (http://www.andre-simon.de/) uses css for syntax</span>
<span class="c1"># highlighting, so you&#39;ll probably want something like the following included</span>
<span class="c1"># in your css file (generated by highlight 2.4.8 and adapted for cgit):</span>
<span class="c1">#</span>
<span class="c1"># table.blob .num  { color:#2928ff; }</span>
<span class="c1"># table.blob .esc  { color:#ff00ff; }</span>
<span class="c1"># table.blob .str  { color:#ff0000; }</span>
<span class="c1"># table.blob .dstr { color:#818100; }</span>
<span class="c1"># table.blob .slc  { color:#838183; font-style:italic; }</span>
<span class="c1"># table.blob .com  { color:#838183; font-style:italic; }</span>
<span class="c1"># table.blob .dir  { color:#008200; }</span>
<span class="c1"># table.blob .sym  { color:#000000; }</span>
<span class="c1"># table.blob .kwa  { color:#000000; font-weight:bold; }</span>
<span class="c1"># table.blob .kwb  { color:#830000; }</span>
<span class="c1"># table.blob .kwc  { color:#000000; font-weight:bold; }</span>
<span class="c1"># table.blob .kwd  { color:#010181; }</span>

<span class="c1"># store filename and extension in local vars</span>
<span class="nv">BASENAME</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$1</span><span class="s2">&quot;</span>
<span class="nv">EXTENSION</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">BASENAME</span><span class="p">##*.</span><span class="si">}</span><span class="s2">&quot;</span>

<span class="c1"># map Makefile and Makefile.* to .mk</span>
<span class="o">[</span><span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">BASENAME</span><span class="p">%%.*</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s2">&quot;Makefile&quot;</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="nv">EXTENSION</span><span class="o">=</span>mk

<span class="nb">exec</span><span class="w"> </span>highlight<span class="w"> </span>--force<span class="w"> </span>-f<span class="w"> </span>-I<span class="w"> </span>-X<span class="w"> </span>-S<span class="w"> </span><span class="nv">$EXTENSION</span><span class="w"> </span><span class="m">2</span>&gt;/dev/null
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3-54-g00ecf</a> (<a href='https://git-scm.com/'>git 2.39.0</a>) at 2025-01-04 00:48:57 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
