2024-01-20 13:36:30 +03:00
|
|
|
#!/bin/zsh
|
|
|
|
|
|
|
|
git-dir-usage() {
|
|
|
|
local d x p
|
|
|
|
d=$(__z_git rev-parse --git-dir) || return $?
|
|
|
|
x=$(__z_git rev-parse --path-format=absolute 2>/dev/null)
|
|
|
|
if [ -n "$x" ] ; then
|
|
|
|
## older git version which does not support "--path-format=absolute"
|
|
|
|
:
|
|
|
|
else
|
|
|
|
d=$(__z_git rev-parse --path-format=absolute --git-dir)
|
|
|
|
fi
|
2024-01-27 00:10:58 +03:00
|
|
|
|
2024-01-20 13:36:30 +03:00
|
|
|
case "$d" in
|
2024-01-27 00:10:58 +03:00
|
|
|
*/* ) p=${d%/*} ; d=${d:t} ;;
|
2024-01-20 13:36:30 +03:00
|
|
|
esac
|
2024-01-27 00:10:58 +03:00
|
|
|
|
|
|
|
## ${p:+ env -C "$p" } du -d2 "$d"
|
2024-01-20 13:36:30 +03:00
|
|
|
if [ -n "$p" ] ; then
|
2024-01-27 00:10:58 +03:00
|
|
|
env -C "$p" du -d2 "$d"
|
2024-01-20 13:36:30 +03:00
|
|
|
else
|
2024-01-27 00:10:58 +03:00
|
|
|
du -d2 "$d"
|
2024-01-20 13:36:30 +03:00
|
|
|
fi | grep -Ev '^[0-9]\s' | sort -Vk2
|
|
|
|
}
|
|
|
|
|
|
|
|
git-gc() {
|
|
|
|
git-dir-usage || return $?
|
|
|
|
echo
|
|
|
|
idle git gc "$@"
|
|
|
|
echo
|
|
|
|
git-dir-usage
|
|
|
|
}
|
|
|
|
|
|
|
|
git-gc-force() {
|
|
|
|
git-gc --aggressive --force
|
|
|
|
}
|