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

Re: Git Hooks

From
Jeff King <peff@peff.net>
Date
Dec 16, 2017, 09:53 UTC
Message-ID
<20171216095357.GB32706@sigill.intra.peff.net>
In-Reply-To
<CAMZug26A0e=AunMOjZNC_xH2E5uqHe46mt6=jawWe7ozF=Jn0Q@mail.gmail.com>
On Fri, Dec 15, 2017 at 12:48:07PM -0800, Satyakiran Duggina wrote:
Show 12 quoted lines
> To give the code pullers a chance to review, can we not have a
> `trusted-hooks: default` and `trusted-SHA: <some sha>` field in .git/.
> I'm assuming githooks/ are source tracked here.
> 
> When developer tries to execute `git commit`, git can ask developer to
> change `trusted-hooks` field to true or false. Let's say developer
> sets it to true, git can record the SHA. If any latest pull has the
> hooks changed, git can revert the `trusted-hook` to default.
> 
> This way there is not much hassle for developers to manually copy
> hooks all the time. And at the same time, they are not running scripts
> that they haven't reviewed.

We've talked about doing something like this (though more for config than for hooks). But what the discussion always come down to is that carrying a script like "import-hooks.sh" in the repository ends up being the exact same amount of work for the developer as any git-blessed "OK, trust these hooks" command.

And it's a lot more flexible. The writer of that script can touch hooks, config, etc. They can base decisions about what values to use based on data that Git otherwise wouldn't care about (e.g., uname). And they only have to handle cases that the project cares about, whereas anything Git does has to work everywhere.

-Peff
Previous: Satyakiran DugginaNext: Ævar Arnfjörð Bjarmason
Message 4 of 5 in “Git Hooks”
  1. Satyakiran DugginaDec 15, 2017
  2. Bryan TurnerDec 15, 2017
  3. Satyakiran DugginaDec 15, 2017
  4. Jeff KingDec 16, 2017
  5. Allowing remote git repos to set config & hook configurationÆvar Arnfjörð Bjarmason, Dec 19, 2017

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.