Commit b519a13119358fc0cde28b070bf8984e814f8c4a

Authored by Henry Fredrick Schreiner
1 parent df5b157d

Updating clang format pre-commit helper example

[skip ci]
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 ;;
... ...