`stage_fixed`: `Couldn't stage fixed files:fork/exec C:\Program Files\Git\mingw64\bin\git.exe: The filename or extension is too long.` on Windows
ValentinGurkov opened this issue · comments
🔧 Summary
When I have a lot of staged files that got changed and must be re-added, the list of files git add
seems to be too long and results in the error:
Couldn't stage fixed files:fork/exec C:\Program Files\Git\mingw64\bin\git.exe: The filename or extension is too long.
For reference, the command I am running is:
prettier:
glob: '*.{yml,md,gql,hbs,ts,js,json}'
run: pnpm prettier --write {staged_files}
stage_fixed: true
With around 452 files, the length of the git add ...
command is 33852
characters long in my use case, which triggers the error,
I gradually removed some files and at around 435 files, the git add ...
command was 32549
characters long in my use case and the command executed successfully.
Lefthook version
1.6.8 96d2b329e43a04c9ea3f7fb138f1606e8c33cb41
Steps to reproduce
Have a lot of staged files that get changed during hook execution and have stage_fixed: true
set for the command that will execute.
With around 452 files, the length of the git add ...
command is 33852
characters long in my use case, which triggers the error.
Expected results
git add
during stage_fixed
should work regardless of the amount of staged files.
Actual results
git add
can become too long and will not be executed.
Possible Solution
I imagine like with #666 for the command length, git add
can also be chunked.
However, I cannot determine whether there will be any impact when tasks are run in parallel, hopefully, somebody else knows better.
Logs / Screenshots
Thank you for creating this issue. I will try to figure out how to split the git add
command in chunks
Please, check 1.6.9 release. I've added batching to implicit git commands. If it doesn't work, please, write back or create a new issue.