1
0

zsh: improve git snippets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Konstantin Demin 2024-07-23 23:08:35 +03:00
parent e6678b1a31
commit 6c0ac78b6e
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0

View File

@ -16,29 +16,39 @@ git-dir-usage() {
esac
local -a subdirs
subdirs+="${gitdir}/logs/refs"
subdirs+="${gitdir}/objects/info"
subdirs+="${gitdir}/objects/pack"
for x ( logs/refs objects/info objects/pack ) ; do
[ -d "${gitdir}/$x" ] || continue
subdirs+="${gitdir}/$x"
done
if [ -n "${topdir}" ] ; then
env -C "${topdir}" du -d1 "${gitdir}"
env -C "${topdir}" du -d1 "${subdirs[@]}"
else
du -d1 "${gitdir}"
(
[ -n "${topdir}" ] && cd "${topdir}/"
if [ ${#subdirs} -gt 0 ] ; then
du -d1 "${subdirs[@]}"
fi | grep -Ev '^[0-9]\s' | sort -Vk2
fi
du -d1 "${gitdir}"
) | grep -Ev '^[0-9]K?\s' | sort -Vk2
}
git-gc() {
git-dir-usage || return $?
echo
idle git gc "$@"
echo "# git gc $*" >&2
z-time idle git gc "$@"
echo
git-dir-usage
}
git-gc-force() {
git-gc --aggressive --force
git-dir-usage || return $?
echo
echo "# git gc --aggressive --force $*" >&2
z-time idle git gc --aggressive --force "$@"
echo
echo "# git repack -Ad" >&2
z-time idle git repack -Ad
echo
git-dir-usage
}
git-archive-ref() {