Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Ronald G. Minnich | ff22b6ac | 2018-08-01 07:19:31 -0700 | [diff] [blame] | 2 | files=`git diff --cached --name-only | grep '\.[ch]$'` |
3 | if [ -z "$files" ]; then | ||||
4 | exit 0 | ||||
5 | fi | ||||
6 | # This has to be set here; otherwise a grep error seems to cause | ||||
7 | # us to exit with non-zero status. | ||||
8 | set -e | ||||
9 | clang-format -i $files | ||||
10 | git add $files | ||||
11 | u=`git config user.name` | ||||
12 | m="clang-formatted-by: $u" | ||||
13 | echo $m >> $1 |