hooks: truly find ourselves
With hooks possibly running as a result of non-Girocco activity
(e.g. a linked working tree), the possible combinations of GIT_DIR
settings, ".git" being a directory, symlink or "gitdir:" file and
a veritable plethora of possible current working directories create
a truly perverse and potentially hostile hook script environment.
The hook scripts attempt to navigate this maze of possibilities
without requiring any particular Git version while still operating
correctly when executed from within a chroot jail and yet always
ending up with the current directory and GIT_DIR pointing at the
"top" of the "bare" ".git" Girocco repository.
Enhance the logic substantially (at almost no additional cost) to
handle all (hopefully) of the bizarre situations a hook script could
find itself being executed in.
The previous version worked just fine for ordinary Girocco installations
that do not have any linked working trees or non-bare repositories.
This version tolerates much greater perversity while still always
coming out on top.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>