aboutsummaryrefslogtreecommitdiff
path: root/cgit.c
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <saya.andy@posteo.com> 2026-07-30 12:23:33 +0700
committerGravatar Saya Andy <saya.andy@posteo.com> 2026-07-30 12:23:33 +0700
commit26fbed3bc58600adc092ab41e094e0fcae60f3b2 (patch)
tree057b66b3fdad46810ef21e243ce50d18dbc81e9c /cgit.c
parent8c1df01ecea5b684dd420bcd5b4e4e25e56c3af8 (diff)
downloadcgitext-26fbed3bc58600adc092ab41e094e0fcae60f3b2.tar.gz
cgitext-26fbed3bc58600adc092ab41e094e0fcae60f3b2.zip
cgit: don't initialize notes when there is no repository
prepare_repo_env() calls load_display_notes() unconditionally, even when setup_git_directory_gently() has just reported that repo.path is not a repository. init_notes() then resolves the default notes ref and dereferences the repository's hash algorithm, which is still NULL: EXC_BAD_ACCESS (code=1, address=0x18) get_oid_basic(str="refs/notes/commits", len=18) at object-name.c:688 -> if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) { A typo in repo.path therefore took out the request. On Linux this segfaults; on macOS nothing consumes the Mach exception, so the faulting instruction is retried forever and the worker process spins at 100% CPU instead of dying. Only load the notes once a repository has been opened. prepare_repo_cmd() reports the failure immediately afterwards, so such a request now renders "Failed to open <repo>: No such file or directory". Signed-off-by: Saya Andy <saya.andy@posteo.com>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index ca318e8..5bf52f8 100644
--- a/cgit.c
+++ b/cgit.c
@@ -587,9 +587,12 @@ static void prepare_repo_env(int *nongit)
/* Setup the git directory and initialize the notes system. Both of these
* load local configuration from the git repository, so we do them both while
- * the HOME variables are unset. */
+ * the HOME variables are unset. Initializing the notes system requires an
+ * actual repository, as it would otherwise dereference the not yet known
+ * hash algorithm. */
setup_git_directory_gently(nongit);
- load_display_notes(NULL);
+ if (!*nongit)
+ load_display_notes(NULL);
}
static int prepare_repo_cmd(int nongit)