1#!/usr/bin/env bash 2files=`git diff --cached --name-only | grep '\.[ch]$'` 3if [ -z "$files" ]; then 4 exit 0 5fi 6# This has to be set here; otherwise a grep error seems to cause 7# us to exit with non-zero status. 8set -e 9clang-format -i $files 10git add $files 11u=`git config user.name` 12m="clang-formatted-by: $u" 13echo $m >> $1 14