From: "J. Bakshi" <joydeep@infoservices.in>
To: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: pre-commit not working at server side push
Date: Wed, 20 Jul 2011 13:15:33 +0530 [thread overview]
Message-ID: <20110720131533.7bbba0c5@shiva.selfip.org> (raw)
In-Reply-To: <20110720073017.GA10465@LK-Perkele-VI.localdomain>
On Wed, 20 Jul 2011 10:30:17 +0300
Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:
> On Wed, Jul 20, 2011 at 12:45:38PM +0530, J. Bakshi wrote:
> > On Wed, 20 Jul 2011 12:13:56 +0530
> > "J. Bakshi" <joydeep@infoservices.in> wrote:
> >
> > > Hello list,
> > >
> > > I have this bash script to check php syntax error and prevent the commit if there is any
> > >
> > > ```````````````````
> > > #!/bin/sh
> > >
> > > ##php_syntax_check
> > >
> > > for i in $(git diff-index --name-only --cached HEAD -- | grep -E '\.(php|engine|theme|install|inc>
> > > if [ -f $i ]; then
> > > output=$(/usr/bin/php5 -l $i)
> > > if [ "$output" == "No syntax errors detected in $i" ];
> > > then
> > > echo "PHP syntax check for $i: OK"
> > > else
> > > echo "=====================================================================>
> > > echo "Pause $i for the commit due to PHP parse errors:"
> > > echo "$output"
> > > exit 1
> > > fi
> > > fi
> > > done
> > >
> > > ```````````````````
>
> > seems it should be pre-receive hook at the server. So done accordingly but still not working
>
> Pre-receive runs after objects have been received but before branches are updated. So
> it can inspect the newly arrived commits but the branches retain their old values.
>
> - Firstly, the server does not have index, so diff-index does not do anything sane.
> - Secondly, HEAD does not point to anything newly arrived (the hook gets list of update
> instructions via stdin).
> - Thirdly, this hook must be prepared for multiple commits in multiple branches appearing at
> once.
>
> I think githooks(5) documents what these hooks receive and what they do.
>
> -Ilari
Thanks for your clarification. As a newbie I am interested to know any such pre-receive hook which can check php syntax before php.
next prev parent reply other threads:[~2011-07-20 7:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 6:43 pre-commit not working at server side push J. Bakshi
2011-07-20 7:15 ` J. Bakshi
2011-07-20 7:30 ` Ilari Liusvaara
2011-07-20 7:45 ` J. Bakshi [this message]
2011-07-20 9:03 ` J. Bakshi
2011-07-20 7:18 ` Ilari Liusvaara
2011-07-20 7:21 ` J. Bakshi
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=20110720131533.7bbba0c5@shiva.selfip.org \
--to=joydeep@infoservices.in \
--cc=git@vger.kernel.org \
--cc=ilari.liusvaara@elisanet.fi \
/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;
as well as URLs for NNTP newsgroup(s).