Subject: Re: Syntax check via update hook?

From: Mark Plaksin <[email-masked]>
Date: Wed, 20 May 2009 11:13:09 -0400

Mark Plaksin <[email-masked]> writes:

> Jeff King <[email-masked]> writes:
>
>> On Tue, May 12, 2009 at 03:16:50PM -0400, Mark Plaksin wrote:
>>
>>> >         $ cat <<EOF >.git/hooks/update
>>> >         #!/bin/sh
>>> >         GIT_INDEX_FILE=/path/to/tempdir/index; export GIT_INDEX_FILE
>>> >         cd /path/to/tempdir/tree &&
>>> >         mkdir -p tree &&
>>> >         git read-tree "$3" &&
>>> >         git checkout-index &&
>>> >         your_syntax_check
>>> >         EOF
>>> >         $ chmod +x .git/hooks/update

...

> It does!  You make it seem so easy!  Thanks very much.  I now have an
> update hook which checks syntax just like we want.  Thanks again!

Well, it's oh so close!  If we make changes that don't pass the syntax
check and try to push them the hook rejects the changes.  If we then
make a change that will pass the syntax check, leave the others broken,
and push, 'git diff-tree' doesn't list the previously rejected files so
the hook accepts the push.  Is there any way to get 'git diff-tree' to
list all of the files?

Here's 'git diff-tree' output from our first push attempt:
139ca369a16151faedf78fd86941769ceff289e4
:100644 100644 bfc70383d8e5ab1adb83ce599eac6f4f9dd47f9c 931c8f3acb640606c950ee14b47c92f2b6ad5f51 M      modules/git/files/update_hook
:100644 100644 34cea12e7c32a61f1ad25955c7ee8434652a354a b27af409ca226f9acbd8e7b89ae7ed21785f1ab1 M      modules/git/manifests/init.pp
:100644 100644 598af464c5220f83a6d2342cecf7beace47dd136 033a8b4c897094db050590501c5accef1feb2abc M      modules/git/manifests/server.pp

And here's the output from the second push attempt:
eacdddf85e5d1180f5917a467edd5e0535a61321
:100644 100644 12418bd45df24a7d8cc8c43691c35a62888343e9 65f8137b0887bd734c6adc951eb45ea76a220775 M      modules/git/files/xinetd

Thanks again!