Repository navigation
Ask git once per repo, cut scan memory, stop the scan on quit, ctrl+c quits from the key list - #8
Merged
Merged
Conversation
…y helper The exported At let any caller build a Candidate that Remove accepts without Scan's checks, such as the one for a volume mounted inside a target. It is now a helper in the package's tests that fails on a folder it can't read. Tests ask Vet directly about each trap, and a new one checks that a candidate not from Scan is refused even when its path passes Vet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D9oJWw4k81eBvUNWWQjoMK
…aller bugs Could delete the wrong thing: - An empty DIR (a script's unset variable) was read as the current folder. - git was run with the inherited GIT_DIR / GIT_INDEX_FILE, so from a hook or a dotfiles shell it answered for another repo and tracked folders looked disposable. - A target with its own .git (a nested clone, a worktree) in an ignored build/ was treated as build output. - A volume mounted inside a listed folder after the scan was emptied. Smaller: - /dev/null counted as a terminal, so sweep > /dev/null opened the screen. - A build whose version is a bare commit hash was told to upgrade on every run, and sweep upgrade replaced it. - A target that vanished during the scan was listed as a 0.0 KB row that could never be deleted. - The scan status line could be cut inside the … on a very narrow terminal. Faster: targets in one folder are put to git together, so a project's node_modules, .next and dist cost two git runs instead of five. The re-check before each delete still asks per folder. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D9oJWw4k81eBvUNWWQjoMK
…trl+c quits from the key list Scan: each repository is asked once which target folders hold tracked files, and one git check-ignore stays running per repository for the ignore rules. A 500-package repo took 1000 git runs; now 2. Remove still asks git about each folder on its own before deleting it, so these answers only decide what is listed. Paths that aren't plain ASCII are still asked per folder: git may spell them differently from the disk. Scan: hard-linked files are kept in a sorted slice per target (16 bytes a file, where the map took about 55) and attributed with one sorted list at the end instead of a second map. Progress.Stop ends a running scan; the screen calls it on quit, so a scan no longer runs on while sweep waits for deletions to finish. ctrl+c and ctrl+d now quit from the key list at the first press. q there still only closes it, as "Press any key to close" says. Closes #4, closes #5, closes #6, closes #7. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D9oJWw4k81eBvUNWWQjoMK
…anges) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D9oJWw4k81eBvUNWWQjoMK
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the four follow-ups left open after #3.
Closes #4, closes #5, closes #6, closes #7.
#4 — Ask git once per repo
During a scan, each repository is now asked once which target folders hold tracked files (
git ls-files -zfrom the repo top), and onegit check-ignore --stdinstays running per repository to answer ignore questions path by path.Measured on a repo with 500 packages, each with
node_modules,distand.turbo(Linux, 4 workers):Safety:
Removestill callsVet, which asks git about each folder on its own, exactly as before. The new answers only decide what the scan lists, so a wrong one shows a folder that is then refused, never a deleted tracked folder.check-ignoredies or stops answering, sweep falls back to asking per folder.core.precomposeunicode).TestScanAnswersLikeKeepchecks that the scan's answer equalskeep's for about 130 folders across tracked, ignored,!-rule, nested-repo and non-ASCII cases, and again after killing the running git.#5 — Hard-link memory
measurekept amap[inode]int64per target (about 55 bytes per file), andScanbuilt a second map to attribute shared files. Both are replaced by sorted slices: 16 bytes per file during the scan, plus a 24-byte-per-file list while sizes are attributed at the end. The attribution rule is unchanged: a file linked into several targets is charged to the first one in path order.#7 — Stop the scan on quit
Progress.Stop()makes a runningScanreturn soon with the folders it measured to the end. The screen calls it once the user quits, so the scan no longer runs on while sweep waits for deletions to finish.#6 — Quit keys in the key list
I picked option 2 from the issue:
ctrl+candctrl+dnow quit at the first press from anywhere, including the?key list.qthere still only closes it, as "Press any key to close" says. Say if you'd prefer one of the other options.Testing
GOOS=darwin GOARCH=arm64 go vet ./...passes.-raceon Linux in a copy with the build tags and ioctl constants swapped (the two delete-failure tests need a non-root user, as onmain).testworkflow runs onmacos-latest, so CI on this PR is the macOS run. The parts that depend on macOS are the case-insensitive disk and Apple's git answeringcheck-ignore --stdinpath by path;TestScanAnswersLikeKeepfails if the latter doesn't hold.The branch also carries a merge of its earlier history (already in
mainas #3) with no file changes.Generated by Claude Code