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