fix: cap status file shortcuts to not exceed OS ARG_MAX#144
Conversation
When a git repo has thousands of untracked files (e.g. node_modules), the tab-delimited file list output by the Go binary can exceed the OS ARG_MAX limit when the shell function tries to process it. Cap the number of files that receive numeric shortcuts to 250 in both the parse data output and the display rendering. When truncated, a warning line is shown with the total count. Adds unit tests with golden files for a 260-file truncation scenario. Fixes #119 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where git repositories with thousands of untracked files (e.g., node_modules) would cause "Argument list too long" errors when the tab-delimited file list exceeded OS ARG_MAX limits. The fix caps the number of files that receive numeric shortcuts to 250, preventing the argument list from growing too large while still providing shortcuts for a reasonable number of files.
Changes:
- Added a constant
maxShortcutFiles = 250to limit the number of files with shortcuts - Modified display rendering to truncate output at 250 files and show a warning message
- Modified parse data formatting to only include the first 250 files in the tab-delimited output
- Added comprehensive test coverage with a 260-file scenario to verify truncation behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/cmd/status/render.go | Implements the core truncation logic for both display and parse data output, capping at 250 files |
| internal/cmd/status/render_test.go | Adds test case with 260 files to verify truncation behavior |
| internal/cmd/status/testdata/statuslist-truncated.parsedata.txt.golden | Golden file showing parse data output limited to 250 files |
| internal/cmd/status/testdata/statuslist-truncated.display.ansi.golden | Golden file showing display output with 250 files and truncation warning |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@Tobbe does this seem like a reasonable workaround to the issue you were hitting? |
|
Yes, absolutely. Could even have gone with a smaller number if you wanted. I wonder if it might be good to give the last file a number though. And some special treatment, so you could still do things like 'ga 1 5 10-last', but not exceed the MAX limit. I mean, if that's possible. Maybe by batching out something |
|
But of course, just leaving it at 250 and doing nothing else is fine too! I can manually batch the one or two times in my life I'll have more than 250 files I actually want to work with 😃 |
|
Thanks for confirming! I think keeping it simple is the right call for now. |

When a git repo has thousands of untracked files (e.g. node_modules), the tab-delimited file list output by the Go binary can exceed the OS ARG_MAX limit when the shell function tries to process it.
Cap the number of files that receive numeric shortcuts to 250 in both the parse data output and the display rendering. When truncated, a warning line is shown with the total count.
Adds unit tests with golden files for a 260-file truncation scenario.
Fixes #119