chiark
/
gitweb
/
~ian
/
topgit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check for pre-commit hook existence.
[topgit.git]
/
tg.sh
diff --git
a/tg.sh
b/tg.sh
index 68967218640e519141c526b0ac49b8c0ad83377d..c334f70ee420797c3de7b00ea293da5fefedd061 100644
(file)
--- a/
tg.sh
+++ b/
tg.sh
@@
-21,9
+21,11
@@
die()
setup_hook()
{
hook_call="\"\$(tg --hooks-path)\"/$1 \"\$@\""
setup_hook()
{
hook_call="\"\$(tg --hooks-path)\"/$1 \"\$@\""
- if fgrep -q "$hook_call" "$git_dir/hooks/$1"; then
- # Another job well done!
- return
+ if [ -x "$git_dir/hooks/$1" ]; then
+ if fgrep -q "$hook_call" "$git_dir/hooks/$1"; then
+ # Another job well done!
+ return
+ fi
fi
# Prepare incanation
if [ -x "$git_dir/hooks/$1" ]; then
fi
# Prepare incanation
if [ -x "$git_dir/hooks/$1" ]; then
@@
-35,7
+37,7
@@
setup_hook()
{
echo "#!/bin/sh"
echo "$hook_call"
{
echo "#!/bin/sh"
echo "$hook_call"
- cat "$git_dir/hooks/$1"
+
[ -x "$git_dir/hooks/$1" ] &&
cat "$git_dir/hooks/$1"
} >"$git_dir/hooks/$1+"
chmod a+x "$git_dir/hooks/$1+"
mv "$git_dir/hooks/$1+" "$git_dir/hooks/$1"
} >"$git_dir/hooks/$1+"
chmod a+x "$git_dir/hooks/$1+"
mv "$git_dir/hooks/$1+" "$git_dir/hooks/$1"