Skip to content

Scan: ask git once per repo instead of once per folder #4

Closed

Description

@devloop01

Problem

During a scan, keepAll in internal/sweep/git.go runs git ls-files (and git check-ignore for dist / build / out / target) once per folder that contains targets. #3 batches targets that share a parent folder, but a monorepo with thousands of packages still forks thousands of git processes, which dominates scan time.

At delete time, Vet asks git again for every candidate. That re-check is deliberate (the tree can change between the scan and the delete) and should stay.

Idea

Ask each repo once per scan, for example one git ls-files -z per repo top level, then answer "does this folder hold tracked files?" from that list. Possibly one long-lived git check-ignore --stdin per repo as well.

Why it wasn't done in #3

It changes how the keep-or-delete question is put to git, and a wrong answer deletes tracked files. Things to get right first:

  • Path comparison on APFS. Paths from readdir and paths from git's index can differ in Unicode normalization (core.precomposeunicode) and in case (core.ignorecase). A mismatch makes a tracked folder look untracked.
  • Which repo answers. Nested repos, submodules and worktrees must each be asked about their own folders.
  • Streaming. The interactive list fills in as folders are found, so the answer can't wait for the whole walk.
  • Fail safe. Any git error must still mean "keep".

This needs to be developed and tested on macOS.

Activity

  1. added a commit that references this issue on Nov 13, 2026
    5abe807
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions