Skip to content

Project root lookup accepts any .git, including an empty directory git rejects #120

Done

Description

@doublegate

Problem

project_root (crates/icx-adapters/src/workspace.rs:120) takes the nearest ancestor where
<dir>/.git exists. It does not check that the .git is a repository git would accept, so an
empty or partial .git directory captures every directory beneath it into one icx workspace.

Found on PR #119: a stray, empty /tmp/.git (owner unknown) made git say "not a git repository"
for everything under /tmp, while icx resolved every test project under /tmp to /tmp. As a
result proxy_routes_each_project_into_its_own_workspace (crates/icx-cli/tests/proxy_projects.rs:244)
failed on unmodified main (fb7029e): project A's workspace gained a second artifact between its
first and fourth requests, so its folded history was no longer byte-identical. With TMPDIR
outside /tmp it passed; after rmdir /tmp/.git the original run also passes. CI did not see it.

Effects outside tests: a .git left in a parent directory (an aborted clone, a planted or empty
directory in a shared location) merges unrelated projects' recall, folded outputs and proxy cache
ledgers into one workspace, which is the cross-project boundary #117 established.

Proposed fix

Accept .git only when it matches git's own discovery rules:

  • a directory with HEAD, an objects directory and a refs directory (git's is_git_directory);
  • a file whose gitdir: line names such a directory, which keeps the existing linked-worktree
    check in worktree_main_root.

Skip a .git that fails the check and continue to the next ancestor, matching git. Add a test
with an empty .git directory above a real repository, and one above a plain directory.

Optional: make proxy_projects.rs independent of the host /tmp by giving each test project its
own git init, so a stray ancestor cannot change which workspace it resolves to.

Activity

  1. added this to the v1.6.0 milestone on Nov 28, 2026
  2. doublegate commented on Nov 28, 2026

    @doublegate
    OwnerAuthor

    Fixed in #119 (squash acdcbb5): project root lookup follows git's discovery rules, with bounded non-blocking control-file reads; regression tests assert each case against git rev-parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions