message: option to format cpp files on check
diff: @@ -9,17 +9,34 @@ if [ "$#" -eq 0 ]; then
  exit 1
  fi
  +fix=false
  +while getopts ":f:" opt; do
  + case $opt in
  + f)
  + fix=true
  + shift
  + ;;
  + \?) echo "Invalid option -$OPTARG" >&2
  + exit
  + ;;
  + esac
  +done
  +
  echo "Checking file format in" "$@"
  unformatted_files=""
  -for f in $(find "$@" -name "*.h" -or -name "*.hpp" -or -name "*.cpp" -or -name "*.c"); do
  +for file in $(find "$@" -name "*.h" -or -name "*.hpp" -or -name "*.cpp" -or -name "*.c"); do
  # Workaround for https://bugs.llvm.org/show_bug.cgi?id=39216
  - d=$(cat "$f" | clang-format-7 -style=file --assume-filename "${f%.*}".cpp | diff "$f" -)
  + d=$(cat "$file" | clang-format-7 -style=file --assume-filename "${file%.*}".cpp | diff "$file" -)
  + if $fix ; then
  + cat "$file" | clang-format-7 -style=file --assume-filename "${file%.*}".cpp > "$file".tmp
  + mv "$file".tmp "$file"
  + fi
  if [ "$d" != "" ]; then
  if [ "$unformatted_files" != "" ]; then
  unformatted_files+=$'\n'
  fi
  - unformatted_files+="$f"
  + unformatted_files+="$file"
  fi
  done
  