Skip to content

Instantly share code, notes, and snippets.

@apathyboy
Created August 31, 2010 00:55
Show Gist options
  • Save apathyboy/558331 to your computer and use it in GitHub Desktop.
Save apathyboy/558331 to your computer and use it in GitHub Desktop.
#!/bin/sh
function format_cpp {
file="${1}";
echo "${file}" | grep -ie "^.*\.cpp$" > /dev/null
if [ "$?" -eq 0 ]; then
if [ -f "${file}" ]; then
set -e
astyle -Q -z1 "${file}"
rm -f "${file}.orig"
git add "${file}"
set +e
fi
fi
}
for file in `git diff-index --cached --name-only HEAD`; do
format_cpp "${file}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment