pre-commit: only run uncrustify if changed files are detected

This adds the "no-run-if-empty" flag to the xargs invocation.  Otherwise,
if git diff names no files, the command is run once with no agument
specified which leads to running on a default list of files that appears
to include ignored files and files in submodules.

I am uneasy about how this works (it means that `pre-commit run --all`
doesn't actually check all files) but that's a separate issue.
This commit is contained in:
Jeff Epler 2021-03-15 15:13:10 -05:00
parent 05ed179e11
commit c2ed1b0942
1 changed files with 1 additions and 1 deletions

View File

@ -21,6 +21,6 @@ repos:
language: system
- id: formatting
name: Formatting
entry: sh -c "git diff --staged --name-only | xargs python3 tools/codeformat.py"
entry: sh -c "git diff --staged --name-only | xargs -r python3 tools/codeformat.py"
types_or: [c, python]
language: system