git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Stop a git commit by a specific author using pre-commit hook
@ 2012-03-09  1:15 Adrian Cornish
  2012-03-10 19:41 ` Neal Kreitzinger
  0 siblings, 1 reply; 13+ messages in thread
From: Adrian Cornish @ 2012-03-09  1:15 UTC (permalink / raw)
  To: git

Hi All,

My plan is to use git to keep track of changes in /etc but when
committing I want to have the person making the change specify
themselves as author by adding the --author option on the commandline.

So I would like to stop accidental commits as root.

I tried creating this pre-commit hook but it is not working - git var
is still returning root even if I specify the author on commit line.

TIA
Adrian

AUTHOR=`git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/\1/p'`
if [ "$AUTHOR" == "root <root@localhost>" ];
then
   echo "Please commit under your own user name instead of \"$AUTHOR\":"
   echo 'git commit --author="Adrian"'
   echo "or if your name is not already in logs use full ident"
   echo 'git commit --author="Adrian Cornish <a@localhost>"'
   exit 1
fi
exit 0

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-03-12 11:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-09  1:15 Stop a git commit by a specific author using pre-commit hook Adrian Cornish
2012-03-10 19:41 ` Neal Kreitzinger
2012-03-10 21:54   ` Junio C Hamano
2012-03-10 23:03     ` Neal Kreitzinger
2012-03-11 11:05       ` Junio C Hamano
2012-03-11 11:08         ` [PATCH 1/(3/4)] test: does pre-commit-hook learn authorship? Junio C Hamano
2012-03-11 20:30           ` Johannes Sixt
2012-03-11 21:09             ` Junio C Hamano
2012-03-11 11:09         ` [PATCH 2/(3/4)] ident.c: add split_ident_line() to parse formatted ident line Junio C Hamano
2012-03-11 11:11           ` [PATCH 3/3] commit: pass author/committer info to hooks Junio C Hamano
2012-03-12 11:29             ` Jeff King
2012-03-11 11:15           ` [PATCH 3/4] run_hook(): enhance the interface to pass arbitrary environment Junio C Hamano
2012-03-11 11:16           ` [PATCH 4/4] commit: pass author/committer info to hooks Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).