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

Re: Syntax check via update hook?

From
Mark Plaksin <happy@usg.edu>
Date
May 20, 2009, 15:13 UTC
Message-ID
<ws7i0bu7sq.fsf@usg.edu>
In-Reply-To
<wsd4abfonx.fsf@usg.edu>
Mark Plaksin <happy@usg.edu> writes:
Show 14 quoted lines
> Jeff King <peff@peff.net> 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!
Previous: Mark PlaksinNext: Jeff King
Message 6 of 8 in “Syntax check via update hook?”
  1. Mark PlaksinMay 8, 2009
  2. Jeff KingMay 9, 2009
  3. Mark PlaksinMay 12, 2009
  4. Jeff KingMay 14, 2009
  5. Mark PlaksinMay 14, 2009
  6. Mark PlaksinMay 20, 2009
  7. Jeff KingMay 20, 2009
  8. Mark PlaksinMay 20, 2009

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.