Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c6b5c4

Browse files
committedMar 13, 2025·
Display histogram of changed file
The git pre-commit hook reads 'git diff' and displays a histogram of the insertions, deletions, and modifications per-file. Change-Id: Ic47d188edbe6f28263c03a20d8c7b7db4823babd
1 parent 59b5363 commit 1c6b5c4

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)
Please sign in to comment.