From c32d1dd4fcafad3f9c570adeda580a90d564a3af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 20 Mar 2009 20:40:07 +0100 Subject: [PATCH] hooks/pre-commit.sh: don't wail on detached head for missing .top* files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes a warning fatal: ref HEAD is not a symbolic ref when your HEAD is detached. And branches under refs/top-bases/ don't need these files either. Signed-off-by: Uwe Kleine-König --- hooks/pre-commit.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh index da63185..52d201e 100644 --- a/hooks/pre-commit.sh +++ b/hooks/pre-commit.sh @@ -17,9 +17,19 @@ tg_util ## Generally have fun # Don't do anything on non-topgit branch -git rev-parse --verify "$(git symbolic-ref HEAD | sed 's/heads/top-bases/')" >/dev/null 2>&1 || - exit 0 - +if head_=$(git symbolic-ref -q HEAD); then + case "$head_" in + refs/heads/*) + git rev-parse -q --verify "${head_#refs/heads/#refs/top-bases#}" >/dev/null || exit 0;; + *) + exit 0;; + esac + +else + exit 0; +fi + +# TODO: check the index, not the working copy [ -s "$root_dir/.topdeps" ] || die ".topdeps is missing" [ -s "$root_dir/.topmsg" ] || -- 2.30.2