tg.sh: work around broken git rev-parse --git-common-dir
If the current working directory is not set to the top level
directory of a normal, non-bare git checkout then the result of
the `git rev-parse --git-common-dir` command may well be a
nonsensical, nonexistent directory string.
Compensate for this by first doing a cd to the top-level of
the current working tree (if there is one) before using the
rev-parse --git-common-dir operation and then using pwd to
get an absolute path.
And since the $git_common_dir variable is now always an
absolute path, make sure the $git_dir variable is too.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>