git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: pre-commit not working at server side push

From
JBJ. Bakshi <joydeep@infoservices.in>
Date
Jul 20, 2011, 07:45 UTC
Message-ID
<20110720131533.7bbba0c5@shiva.selfip.org>
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:

Show 44 quoted lines
> 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.
Previous: Ilari LiusvaaraNext: J. Bakshi
Message 4 of 7 in “pre-commit not working at server side push”
  1. J. BakshiJul 20, 2011
  2. J. BakshiJul 20, 2011
  3. Ilari LiusvaaraJul 20, 2011
  4. J. BakshiJul 20, 2011
  5. J. BakshiJul 20, 2011
  6. Ilari LiusvaaraJul 20, 2011
  7. J. BakshiJul 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.