From f3e8aea5b8bc91e70ebc49f88ba59f957c5a9a6e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 4 Nov 2026 20:59:41 -1000 Subject: Keep the placeholder out of a cached scan The cached list wrote "[no description]" like any other description, so once read back it no longer counted as the placeholder and became the meta description of every repository without one. Repositories read back from the list are also marked as having had their description file read, since the scan already did, so the index does not open those files again on every request. --- source/cgit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/cgit.c') diff --git a/source/cgit.c b/source/cgit.c index 81f2b14..9ec7df1 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -213,7 +213,9 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.path=%s\n", repo->path); if (repo->owner) fprintf(f, "repo.owner=%s\n", repo->owner); - if (repo->desc) + // Written out, the placeholder would read back as a description of + // its own and describe the repository's pages. + if (repo->desc && repo->desc != cgit_default_repo_desc) fprintf(f, "repo.desc=%s\n", repo->desc); for_each_string_list_item(item, &repo->readme) { if (item->util) @@ -436,7 +438,7 @@ static void process_cached_repolist(const char *path) struct strbuf key = STRBUF_INIT; struct strbuf cached_rc = STRBUF_INIT; time_t age; - int devnull; + int devnull, first, i; build_scan_key(&key, path); strbuf_addf(&cached_rc, "%s/rc-%8lx", ctx.cfg.cache_root, cache_hash_str(key.buf)); @@ -450,7 +452,12 @@ static void process_cached_repolist(const char *path) goto out; } + first = cgit_repolist.count; config_file_parse(cached_rc.buf, apply_config); + // The scan that wrote the list read each description file already, so + // a repository it left without one is not read again on every request. + for (i = first; i < cgit_repolist.count; i++) + cgit_repolist.repos[i].desc_read = 1; // A negative ttl never expires, the same as for a cached page. age = time(NULL) - st.st_mtime; -- cgit 2.12.1