We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4e9afac commit 08d8b2dCopy full SHA for 08d8b2d
tools/git-pre-commit-cppcheck
@@ -36,11 +36,11 @@ else
36
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
37
fi
38
39
-# We should not pass non-C/C++ files to cppcheck. Filter filenames with pattern.
40
-pattern='\.(c|cpp|cc|cxx|h|hpp)$'
41
-changed_files=$(git diff-index --cached --name-only $against | grep -E $pattern)
+# We should pass only added or modified C/C++ source files to cppcheck.
+changed_files=$(git diff-index --cached $against | \
+ grep -E '[MA] .*\.(c|cpp|cc|cxx)$' | cut -d' ' -f 2)
42
43
if [ -n "$changed_files" ]; then
44
- cppcheck --error-exitcode=1 $changed_files
45
- exit $?
+ cppcheck --error-exitcode=1 $changed_files
+ exit $?
46
0 commit comments