I am using pre-commit (version 2.20.0) for my C++ project with this hook:
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
I just staged a few lines each from a few different .cpp/.h/cmakelists files. When I try to commit those changes, I get the following error from pre-commit:
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to C:\Users\tyler.shellberg\.cache\pre-commit\patch1665600217-21836.
clang-format.............................................................Failed
- hook id: clang-format
- files were modified by this hook
[WARNING] Stashed changes conflicted with hook auto-fixes... Rolling back fixes...
[INFO] Restored changes from C:\Users\tyler.shellberg\.cache\pre-commit\patch1665600217-21836.
I am confused by this. Does pre-commit not allow me to partially commit files, or to have unstaged changes at all when committing?
All the files, both staged and un-staged, have been formatted by clang-format. I've manually double-checked this.
Edit for clarity:
If I run pre-commit run --files [filename]
on each file (staged and unstaged) all report back either "Passed" or "Skipped" (for the non-cpp files). If all files pass, why is there a problem?