Join GitHub today
Git discard changes fails for large changesets with "ENAMETOOLONG" Fix for #65693 #66095
Chunk clean, checkout and update submodule commands within repository.ts to ensure the length of the files passed to the repository are less than 30k characters to avoid ENAMETOOLONG failures on Windows when working with very large changesets.
The problem is there is a limitation to the maximum size of the command line arguments passed to ChildProcess spawn, and the code was calling git commands with all full file paths listed which may exceed the maximum allowable length for arguments. This would cause a git failure, and the discard would not happen.
This change chunks the clean, checkout and submodule update commands to length of the joined file paths being passed to git is less than 30k characters.
Lots of cleanup here:
Overall, great work and thanks for the PR!