#!/bin/sh
# -l      : do not pack "borrowed" objects
# -d      : remove redundant .packs
# -a (-d) : pack everything into a single .pack
# -A -d   : same as -a -d, but unpack all unreachable objects
find "${1:-.}" -name "*.git" -type d		\
	-exec test -e {}/config \;		\
	-prune					\
	-printf "Packing %p\n"			\
	-exec git -C {} repack -l -d \;		\
	-exec git -C {} pack-refs --all --prune \;
