SIGN IN SIGN UP

fix(init): index the requested path when the parent index does not cover it

`colgrep init <dir>` resolves `<dir>` up to an enclosing indexed project and
reuses that index. It does so whenever a parent index exists for the same model,
without checking that the parent actually holds any file under `<dir>` — so a
directory the parent's walk skipped is treated as already indexed:

    $ git init repo && echo 'corpus/' > repo/.gitignore
    $ colgrep init repo                 # Indexed .../repo (added: 1, ...)
    $ colgrep init repo/corpus          # Index is up to date for .../repo (1 files)
    $ colgrep search "..." repo/corpus  # No indexed code units in subdirectory: corpus

Nothing under `corpus/` is ever indexed, `init` exits 0, and the failure only
surfaces later as a search that finds nothing. A gitignored directory is the
common case (dataset corpora, build outputs, vendored trees), but any path the
parent walk excludes behaves the same way.

Gate the reuse on coverage: keep the parent only when its `IndexState` holds at
least one file under the target subdirectory, otherwise index the target as its
own project. Reading the state is a JSON load, so this costs no model work and
does not change the covered case — a subdirectory of an indexed project still
shares the parent index, and no second index is built for it.
R
raphaelsty committed
a7b0a6eeaffbfbbd4233555cad2218ccaac3d6ab
Parent: 76092e1