1
0

format.sh 398 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. cd "$(dirname "$0")"
  3. if [ -z "${CLANG_FORMAT_CMD}" ]
  4. then
  5. if [ -x "$(which clang-format-4.0 2> /dev/null)" ]
  6. then
  7. CLANG_FORMAT_CMD=clang-format-4.0
  8. else
  9. CLANG_FORMAT_CMD=clang-format
  10. fi
  11. fi
  12. list=`git diff --name-only "HEAD" | grep '\.cpp$\|\.h$'`
  13. for i in ${list}
  14. do
  15. if [ -f "${i}" ]
  16. then
  17. "${CLANG_FORMAT_CMD}" -i -style=file "${i}"
  18. fi
  19. done