tg.sh: setup_hook even more carefully
Historically tg.sh used to blindly presume a preexisting pre-commit
hook could be edited to insert a call to tg's own pre-commit hook.
That was overly presumptuous and tended to corrupt preexisting
pre-commit hooks that were not POSIX shell scripts.
A change was made to only edit a preexisting pre-commit hook if it
used the same shell interpreter TopGit was expecting AND it was not
a symbolic link. Otherwise it would be renamed and a new pre-commit
hook written that would then chain to it.
This corrected most all of the issues.
But there are still some corner cases that could be handled better
such as a preexisting pre-commit hook that's not executable or
readable or writable or has a link count other than one or is a
dead symbolic link.
Now handle these cases too by forcing them to rename and chain and
add some more tests for them to verify correctness.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>