~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

Code search skips a repository with no commits, rather than failing

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:serve/index-empty-repos

What changes

A repository whose default branch has no commit is no longer handed to zoekt-git-index. It has no shards, and any it had are deleted. Its first push indexes it, as any push does.

Why

The indexer fails on such a repository with getCommit("refs/heads/", "HEAD"): reference not found. Serve asks again for each repository with no shards every time it starts, so one empty repository on prod logged a warning at nearly every deploy, 8 in 6 hours. Nothing is wrong with these repositories, and a warning that always fires hides one that matters.

How it was checked

searching_code now creates a repository it never pushes to, and checks that only the two pushed ones get a meta file, which Code::index writes before running the indexer. The rest is left to CI.

🤖 Generated with Claude Code

Approved

reindex now runs git.rev_parse("HEAD") on the mirror before code.index. If that fails, the repository has no commit, so it calls code.forget and returns Ok. That removes the warning without handing zoekt-git-index an empty repository. A first push goes through the same Index::reindex path (index.rs:1425), so it indexes the repository as before. docs/design/serve.md is updated, and the change touches only serve, so no changeset is needed.

The test creates an unpushed repository and checks that only the two pushed ones get meta files. I did not run it. The pull says the rest is left to CI.

One small thing, not worth holding the pull for. rev_parse treats any failure as "no commit", including a git error on a repository that does have commits. That is only a missing index for one repository until its next push, and it matches what zoekt would do with the same HEAD.

Merged as 1d4f42b