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 14, 2009, 19:52 UTC
Message-ID
<wsd4abfonx.fsf@usg.edu>
In-Reply-To
<20090514065544.GC10411@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> 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
>> 
>> Thanks for helping! :)
>> 
>> Unfortunately we don't quite get it.  Can you flesh out your example a
>> bit and explain the concepts involved?  We're relative git newbies.  We
>> tried reading the man pages to the commands you use to no avail.  One
>> big stumbling block seems to be how we create/set-up tempdir.  Is that
>> supposed to be a pre-created git checkout, or created via git-archive,
>> or .. ?
>
> What I was trying to say earlier is that you have two choices based on
> how efficient you want to make it. The simple way is to use git-archive:
OK, this makes sense now.  Thanks for being patient with us :)
Show 9 quoted lines
> However, all of that being said, if you just want:
>
>> Also, we actually just want to check the syntax of the files that were
>> changed in the commit, not the whole tree.  Will your method give us
>> access to the path names of the files that changed?
>
> That is simpler, especially if you can feed the files to your
> syntax-checker over stdin. You just need to enumerate the files, and
> then ask git to dump each one:
...
> Make sense?

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!

Previous: Jeff KingNext: Mark Plaksin
Message 5 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.