Diff options
| -rw-r--r-- | source/cgit.c | 11 | |
| -rwxr-xr-x | tests/t0003-cache.sh | 12 |
2 files changed, 21 insertions, 2 deletions
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; diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 0504c88..53a6d5b 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -455,6 +455,18 @@ test_expect_success 'a negative cache-scan-ttl never expires the list' ' ! grep "^repo.url=kept$" "cache5/$scanned_rc" ' +# A repository the scan found without a description goes into the list +# without one, so its pages do not describe themselves with the placeholder. +test_expect_success 'a cached scan leaves the description placeholder out' ' + rm -rf cache5 && mkdir cache5 && + cgit_rc scanrc "url=" >/dev/null && + ! grep "^repo.desc=" cache5/rc-* && + cgit_rc scanrc "url=" >tmp && + grep "\[no description\]" tmp && + cgit_rc scanrc "url=one/" >tmp && + ! grep "<meta name=.description." tmp +' + # A cache-size below zero turns the page cache off, and the scan with it, so # the cache directory stays empty. test_expect_success 'a negative cache-size leaves the scan uncached' ' |
