Skip to content

Commit c2ed1b0

Browse files
committed
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.
1 parent 05ed179 commit c2ed1b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ repos:
2121
language: system
2222
- id: formatting
2323
name: Formatting
24-
entry: sh -c "git diff --staged --name-only | xargs python3 tools/codeformat.py"
24+
entry: sh -c "git diff --staged --name-only | xargs -r python3 tools/codeformat.py"
2525
types_or: [c, python]
2626
language: system

0 commit comments

Comments
 (0)