diff options
| -rw-r--r-- | source/ui-repolist.c | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0303-robustness.sh | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 16 insertions, 0 deletions
diff --git a/source/ui-repolist.c b/source/ui-repolist.c index 99474c1..24d5479 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -89,6 +89,12 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) *mtime = repo->mtime; return 1; } + // A repository configured without a path has nothing on disk to date. + if (!repo->path) { + *mtime = 0; + writable->mtime = 0; + return 0; + } strbuf_addf(&path, "%s/%s", repo->path, ctx.cfg.agefile); if (stat(path.buf, &st) == 0) { *mtime = read_agefile(path.buf); diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index d2bf79f..cbb4cdc 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -37,6 +37,16 @@ test_expect_success 'a repository without a path answers 404' ' done ' +# The index dates a repository from files under its path, and one without a +# path has none, whatever sits in the working directory. +test_expect_success 'a repository without a path has no age on the index' ' + mkdir -p "(null)/refs/heads" && + >"(null)/refs/heads/master" && + CGIT_CONFIG="$PWD/nopathrc" QUERY_STRING="url=" cgit >tmp && + grep "</html>" tmp && + ! grep "<time " tmp +' + test_expect_success 'a repository with an empty url is skipped with a warning' ' { echo "virtual-root=/" && |
