Subject: Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message

From: Andy Parkins <[email-masked]>
Date: Wed, 20 Dec 2006 15:54:51 +0000

On Wednesday 2006 November 29 11:20, Johannes Schindelin wrote:

> +# . git-sh-setup
> +# git var GIT_AUTHOR_IDENT | \
> +# sed -n "s/^\(.*\) [0-9]\+ [-+][0-9]\+$/Signed-off-by: \1/p" \
> +# > $GIT_DIR/SQUASH_MSG

I've been using this; and very useful it is too.  However, I just noticed that 
I was getting "Not a git repository" errors when I tried to commit in a 
subdirectory.  I traced the problem to my use of this fragment.  It seems 
that calling git-sh-setup inside the pre-commit hook was changing GIT_DIR 
(don't know why).  When I changed this to

git var GIT_AUTHOR_IDENT | \
sed -n "s/^\(.*\) [0-9]\+ [-+][0-9]\+$/Signed-off-by: \1/p" \
 >> $(git-rev-parse --git-dir)/SQUASH_MSG

It worked correctly again.

Andy

-- 
Dr Andy Parkins, M Eng (hons), MIEE