Repository navigation
fix(commit): collapse and cap the auto-staging untracked listing - #4152
Conversation
Since `-uall` expanded untracked directories (#4111), auto-staging a directory of 300 new files printed all 300 paths before the commit ran. The warning still counts every path, but the listing now stops at ten rows: past ten paths it lists nine and a hint counts the rest (`… and 291 other paths`), so the hint never replaces a path it could have shown. The cap comes from @Duang777's #4112. Co-authored-by: DDL <duanjialing.777@bytedance.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`wt step commit` and `wt step squash` each ran the same `git status --porcelain -z -uall` before calling the warning, one through `WorkingTree` and one through `Repository`; #4111 had to change both. The warning now takes the `WorkingTree` it describes and reads the status itself, so the `-uall` rationale lives once and both callers run it with the worktree-scoped environment their `git add -A` uses. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The cap itself is right, and the nine-plus-hint arithmetic checks out (over the cap the hint always stands for at least two paths, so the plural is never wrong). One consequence of where the cut lands is worth a decision.
git status -uall emits paths in sorted order, so a single untracked directory with ten or more files fills every row on its own and the rest of the worktree is never named:
$ git status --porcelain -uall
?? apples/1.txt
?? apples/10.txt
... (apples/11, 12, 2..9)
?? secrets/key.pem
That renders as nine apples/* rows and … and 4 other paths. secrets/key.pem is about to be staged by git add -A and the user is not told. Before #4111 the same worktree listed two rows — apples/ and secrets/ — because git's default untracked mode collapses directories; #4111 switched the read to -uall for the count, and the cap now spends the whole listing on whichever directory sorts first. The count line covers the "300 paths, something is wrong" case on its own, but in the moderate case (say 15 paths across three directories) it is the which areas detail that makes the warning actionable, and that is the part the cap drops.
A shape that keeps both: count with -uall as now, and build the capped listing from the collapsed entries, so every untracked directory gets a row and the cap only bites past nine distinct areas.
Raising this for a decision rather than blocking — it is a judgment call about what the warning is for, and capping is an improvement over printing 300 rows either way.
`-uall` expands every untracked directory into its files, and git sorts them, so a directory of generated files filled all nine rows of the capped listing and pushed a separate new file, the one the warning exists to surface, into the "other paths" count. The warning now reads git's `normal` untracked mode, which still overrides `status.showUntrackedFiles=no` but names a wholly untracked directory once as `dir/`. The per-file magnitude stays visible in the commit progress line that follows (`(310 files)`). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#4111 switched the status read behind the auto-staging warning to
-uall, so the warning sees untracked files thatstatus.showUntrackedFiles=nohides. That flag also expands every untracked directory into its files, sowt step commit,wt step squash, andwt mergelisted 300 paths for a directory of 300 new files before committing.The warning now reads git's
normaluntracked mode instead. It still overridesstatus.showUntrackedFiles=no, but names a wholly untracked directory once asdir/, so a directory of generated files takes one row and can't push a separate new file out of view. The file count stays visible in the commit progress line that follows.The listing also stops at ten rows. Past ten paths it lists nine and a hint counts the rest, so the hint always stands for at least two paths:
The status read also moves into the warning itself. Commit and squash each built that command before calling the warning, one through
WorkingTreeand one throughRepository; both now go through theWorkingTreethey stage.Thanks to @Duang777, whose #4112 proposed the cap. They're credited as co-author.
🤖 Generated with Claude Code