diff --git a/scripts/clang-format-pre-commit b/scripts/clang-format-pre-commit index 822becb0..d4f64b8d 100755 --- a/scripts/clang-format-pre-commit +++ b/scripts/clang-format-pre-commit @@ -9,9 +9,14 @@ format_file() { file="${1}" case "$file" in *.hpp | *.cpp | .c | *.cc | *.cu | *.h ) - echo "Fixing: $file" - clang-format -i -style=file "${1}" - git add "${1}" + echo "Formatting: $file" + clang-format -i -style=file -sort-includes "${1}" + if git diff-file --quiet -- "${1}" ; then + git add "${1}" + echo "Reformatting file: ${1}" + else + echo "Already formatted: ${1}" + fi; ;; *) ;;