From: Russell Steicke <russellsteicke@gmail.com>
To: Petr Baudis <pasky@suse.cz>
Cc: git@vger.kernel.org
Subject: [PATCH] [TopGit] Check for pre-commit hook existence.
Date: Sun, 3 Aug 2008 22:14:01 +0800 [thread overview]
Message-ID: <20080803141030.GC11179@maggie.localnet> (raw)
In-Reply-To: <20080803031424.GV32184@machine.or.cz>
Running tg in a repo without an active pre-commit hook fails
saying
grep: .git/hooks/pre-commit: No such file or directory
cat: .git/hooks/pre-commit: No such file or directory
Even "tg help" does this! So add extra checks for existence
of the pre-commit hook.
---
tg.sh | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/tg.sh b/tg.sh
index 56c5709..15005db 100644
--- a/tg.sh
+++ b/tg.sh
@@ -21,9 +21,11 @@ die()
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
@@ -35,7 +37,7 @@ setup_hook()
{
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"
--
1.6.0.rc1
--
Russell Steicke
-- Fortune says:
I got the bill for my surgery. Now I know what those doctors were
wearing masks for.
-- James Boren
next prev parent reply other threads:[~2008-08-03 14:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-03 3:14 [ANNOUNCE] TopGit - A different patch queue manager Petr Baudis
2008-08-03 7:27 ` Miklos Vajna
2008-08-03 12:02 ` Petr Baudis
2008-08-03 14:14 ` Russell Steicke [this message]
2008-08-03 14:26 ` [PATCH] [TopGit] Check for pre-commit hook existence Petr Baudis
2008-08-03 14:45 ` [ANNOUNCE] TopGit - A different patch queue manager Jon Smirl
2008-08-04 13:22 ` Karl Hasselström
2008-08-07 17:56 ` linearising TopGit forests into patch series (was: [ANNOUNCE] TopGit - A different patch queue manager) martin f krafft
2008-08-07 19:58 ` Bert Wesarg
2008-08-08 17:06 ` martin f krafft
2008-08-08 17:14 ` Bert Wesarg
2008-08-09 2:09 ` Sam Vilain
2008-08-09 1:08 ` Petr Baudis
2008-08-10 20:54 ` Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080803141030.GC11179@maggie.localnet \
--to=russellsteicke@gmail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox