threads / discuss / 52054

Commits with --no-verify option

Subject: Commits with --no-verify option

## tl;dr

2 messages between Oct 17, 2019 and Oct 18, 2019.

replies: 1people: 2as markdown or json

Manoj Sterex· Oct 17, 2019, 08:56 UTC · lore
Hi all,

Currently, AFAIK, there is no way to know if a commit was done with or without using the '--no-verify' option. That is, git does not track if hooks were skipped when the commit happened.

Is there some way to track this in the log?

Regards, Manoj

brian m. carlson· Oct 18, 2019, 00:19 UTC · re: Manoj Sterex · lore

Re: Commits with --no-verify option

On 2019-10-17 at 08:56:34, Manoj Sterex wrote:
Show 7 quoted lines
> Hi all,
> 
> Currently, AFAIK, there is no way to know if a commit was done with or
> without using the '--no-verify' option. That is, git does not track if
> hooks were skipped when the commit happened.
> 
> Is there some way to track this in the log?

No, there isn't, and even if there were, it would be trivial to bypass (such as by using git commit-tree, which does not run hooks).

You haven't elaborated on why you want this, but typically the reason people ask for this is that they do some sort of data checking (testing or linting) in the pre-commit hook. Since that code runs on the author's system and is trivially bypassed (by simply deleting the hook), it isn't a good way to enforce policy; usually that should be done in a test or CI infrastructure.

In addition, it's common for advanced users to make a series of temporary commits to save state and then squash them later. It wouldn't be reasonable for a pre-commit hook to enforce certain policies, such as a commit message syntax policy, in such a case, so --no-verify exists for users who know what they're doing and would like to bypass standard checking.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

← back to recent threads