tg.sh: implement .git/tg-cache to speed things up
The results of various operations on tg branches are cached
along with the hash values that produced the result. If the
same values are requested, the cached version is used, otherwise
the cached version is updated.
Additionally, a faster rev_parse is implemented by caching the
output of git for-each-ref during operations where the output
will not be changing.
Together these make for a significant speed up.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>