git status is substantially slower on Windows than on Linux. I'm working in a repo with ~240 submodules. By default, when you run git status in a repo with submodules, it'll recursively run git status in every submodule as well (sequentially). git diff behaves similarly to git status. Pre-commit appears to run git status once at the beginning (to check if anything needs to be stashed?) and then runs git diff before and after each hook (to detect any changes made by the hook?). These calls quickly add up and make pre-commit unusable in these large repos.
The bottlenecks can be seen clearly in this Process Monitor capture:

Running one hook takes ~35s in this case. Two hooks take ~54s.
If I add --ignore-submodules to this git status call and this git diff call, pre-commit only takes ~1.5s for one hook and ~1.9s for two hooks.
If I understand the use of git status and git diff in pre-commit correctly, it seems like it would be completely safe to ignore submodules in the git status call since submodules can't be stashed to restore later. The git diff case might be more risky because I guess hooks could modify submodules? Perhaps an "ignore submodules" setting could be added to pre-commit?
git statusis substantially slower on Windows than on Linux. I'm working in a repo with ~240 submodules. By default, when you rungit statusin a repo with submodules, it'll recursively rungit statusin every submodule as well (sequentially).git diffbehaves similarly togit status. Pre-commit appears to rungit statusonce at the beginning (to check if anything needs to be stashed?) and then runsgit diffbefore and after each hook (to detect any changes made by the hook?). These calls quickly add up and make pre-commit unusable in these large repos.The bottlenecks can be seen clearly in this Process Monitor capture:
Running one hook takes ~35s in this case. Two hooks take ~54s.
If I add
--ignore-submodulesto thisgit statuscall and thisgit diffcall, pre-commit only takes ~1.5s for one hook and ~1.9s for two hooks.If I understand the use of
git statusandgit diffin pre-commit correctly, it seems like it would be completely safe to ignore submodules in thegit statuscall since submodules can't be stashed to restore later. Thegit diffcase might be more risky because I guess hooks could modify submodules? Perhaps an "ignore submodules" setting could be added to pre-commit?