Skip to content

Commit e3b2d26

Browse files
authored
Merge pull request #262 from sysprog21/refine-commit-hook
Display histogram of changed file
2 parents 59b5363 + 1c6b5c4 commit e3b2d26

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/pre-commit.hook

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,16 @@ for FILE in $C_FILES; do
207207
fi
208208
done
209209

210-
if [ ! -z "${FILES[*]}" ]; then
210+
if [ "${#FILES[@]}" -gt 0 ]; then
211211
echo "Following files were changed:"
212-
echo "${FILES[*]}"
212+
for file in "${FILES[@]}"; do
213+
if command -v diffstat >/dev/null 2>&1; then
214+
summary=$(git diff --cached "$file" | diffstat -s | sed -E 's/^[[:space:]]*[0-9]+ files? changed,?[[:space:]]*//')
215+
echo " - $file | $summary"
216+
else
217+
echo " - $file"
218+
fi
219+
done
213220
fi
214221

215222
$SHA1SUM -c scripts/checksums 2>/dev/null >/dev/null

0 commit comments

Comments
 (0)