tg.sh: setup_hook even more carefully
commit5d1f582356427ead5c2f8db2b8b0304957ff1b1d
authorKyle J. McKay <mackyle@gmail.com>
Sat, 17 Feb 2018 03:19:46 +0000 (16 19:19 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Sat, 17 Feb 2018 03:19:46 +0000 (16 19:19 -0800)
tree38f96423bf403313f0da93edbf0c101f9c8bfdc6
parent498ed4759ce15d246fb21d6e4502c355a39e46f1
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>
t/t2000-hook-installation.sh
tg.sh