Skip to content

fix: cap status file shortcuts to not exceed OS ARG_MAX#144

Merged
mroth merged 1 commit intomainfrom
fix-shortcut-cap
Feb 21, 2026
Merged

fix: cap status file shortcuts to not exceed OS ARG_MAX#144
mroth merged 1 commit intomainfrom
fix-shortcut-cap

Conversation

@mroth
Copy link
Owner

@mroth mroth commented Feb 21, 2026

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

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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = 250 to 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.

@mroth
Copy link
Owner Author

mroth commented Feb 21, 2026

@Tobbe does this seem like a reasonable workaround to the issue you were hitting?

@Tobbe
Copy link

Tobbe commented Feb 21, 2026

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

@Tobbe
Copy link

Tobbe commented Feb 21, 2026

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 😃

@mroth
Copy link
Owner Author

mroth commented Feb 21, 2026

Thanks for confirming! I think keeping it simple is the right call for now.

@mroth mroth merged commit aaf8e52 into main Feb 21, 2026
19 checks passed
@mroth mroth deleted the fix-shortcut-cap branch February 21, 2026 21:05
@Tobbe
Copy link

Tobbe commented Feb 21, 2026

image

167 files I actually wanted to work with. Could easily have been a few more. 250 was a good call!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Argument list too long

3 participants