Commit b519a13119358fc0cde28b070bf8984e814f8c4a
1 parent
df5b157d
Updating clang format pre-commit helper example
[skip ci]
Showing
1 changed file
with
8 additions
and
3 deletions
scripts/clang-format-pre-commit
| ... | ... | @@ -9,9 +9,14 @@ format_file() { |
| 9 | 9 | file="${1}" |
| 10 | 10 | case "$file" in |
| 11 | 11 | *.hpp | *.cpp | .c | *.cc | *.cu | *.h ) |
| 12 | - echo "Fixing: $file" | |
| 13 | - clang-format -i -style=file "${1}" | |
| 14 | - git add "${1}" | |
| 12 | + echo "Formatting: $file" | |
| 13 | + clang-format -i -style=file -sort-includes "${1}" | |
| 14 | + if git diff-file --quiet -- "${1}" ; then | |
| 15 | + git add "${1}" | |
| 16 | + echo "Reformatting file: ${1}" | |
| 17 | + else | |
| 18 | + echo "Already formatted: ${1}" | |
| 19 | + fi; | |
| 15 | 20 | ;; |
| 16 | 21 | *) |
| 17 | 22 | ;; | ... | ... |