| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
if git rev-parse --verify HEAD >/dev/null 2>&1; then |
| 4 |
against=HEAD |
| 5 |
else |
| 6 |
# Initial commit: diff against an empty tree object |
| 7 |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
| 8 |
fi |
| 9 |
|
| 10 |
# fail if we add any new lines to C or Scheme source containing a tab |
| 11 |
if git diff --name-only "$against" | egrep -q '\.(cpp|h|scm|sld|stub)$' &&\ |
| 12 |
git diff --name-only "$against" |\ |
| 13 |
egrep '\.(cpp|h|scm|sld|stub)$' |\ |
| 14 |
xargs -d'\n' git diff -U0 --no-color "$against" -- |\ |
| 15 |
grep -q $'^+ *\t'; then |
| 16 |
echo "Error: Attempting to add a source file using tabs for indentation." |
| 17 |
echo |
| 18 |
echo -n " " |
| 19 |
git diff --name-only "$against" |\ |
| 20 |
egrep '\.(cpp|h|scm|sld|stub)$' |\ |
| 21 |
xargs -d'\n' git diff -U0 "$against" -- |\ |
| 22 |
grep $'^+ *\t' | head -1 |
| 23 |
echo |
| 24 |
cat <<EOF |
| 25 |
It's important for arguments to line up vertically to a precise column. |
| 26 |
Since there is no standard tab width, using tabs for indentation makes |
| 27 |
this impossible in general. Please use spaces. |
| 28 |
EOF |
| 29 |
exit 1 |
| 30 |
fi |