Skip to content

hooks: introduce 'hooks.allowNoVerify' configuration - #2215

Open
kairosci wants to merge 1 commit into
gitgitgadget:masterfrom
kairosci:hooks-allownoverify
Open

hooks: introduce 'hooks.allowNoVerify' configuration#2215
kairosci wants to merge 1 commit into
gitgitgadget:masterfrom
kairosci:hooks-allownoverify

Conversation

@kairosci

@kairosci kairosci commented Sep 2, 2026

Copy link
Copy Markdown

Introduce 'hooks.allowNoVerify' as an opt-in workflow guardrail (default: true) to prevent accidental bypass of hooks via '--no-verify'.
This setting is intended for workflows and managed environments to avoid inadvertent bypasses, without altering Git's server-side security model.

cc: "brian m. carlson" sandals@crustytoothpaste.net

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

Welcome to GitGitGadget

Hi @kairosci, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that either:

  • Your Pull Request has a good description, if it consists of multiple commits, as it will be used as cover letter.
  • Your Pull Request description is empty, if it consists of a single commit, as the commit message should be descriptive enough by itself.

You can CC potential reviewers by adding a footer to the PR description with the following syntax:

CC: Revi Ewer <revi.ewer@example.com>, Ill Takalook <ill.takalook@example.net>

NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description,
because it will result in a malformed CC list on the mailing list. See
example.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "revisions:" to state which subsystem the change is about, and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the Libera Chat IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

If you want to see what email(s) would be sent for a /submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this. Note that any reviewers CC'd via the list in the PR description will not actually be sent emails.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail).

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the (raw) link), then import it into your mail program. If you use GMail, you can do this via:

curl -g --user "<EMailAddress>:<Password>" \
    --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):

Changes since v1:
- Fixed a typo in the commit message (found by ...)
- Added a code comment to ... as suggested by ...
...

To send a new iteration, just add another PR comment with the contents: /submit.

Need help?

New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join.

You may also be able to find help in real time in the developer IRC channel, #git-devel on Libera Chat. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@gitgitgadget gitgitgadget Bot added the new user label Sep 2, 2026
@kairosci
kairosci force-pushed the hooks-allownoverify branch 3 times, most recently from ce6969e to 853636d Compare September 2, 2026 10:41
@dscho

dscho commented Sep 2, 2026

Copy link
Copy Markdown
Member

/allow

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

User kairosci is now allowed to use GitGitGadget.

@kairosci

kairosci commented Sep 2, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

Submitted as pull.2215.git.1788365862670.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2215/kairosci/hooks-allownoverify-v1

To fetch this version to local tag pr-2215/kairosci/hooks-allownoverify-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2215/kairosci/hooks-allownoverify-v1

@kairosci
kairosci force-pushed the hooks-allownoverify branch from 853636d to 4e59456 Compare September 2, 2026 16:33
@kairosci

kairosci commented Sep 2, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

Submitted as pull.2215.v2.git.1788366925041.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2215/kairosci/hooks-allownoverify-v2

To fetch this version to local tag pr-2215/kairosci/hooks-allownoverify-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2215/kairosci/hooks-allownoverify-v2

@kairosci
kairosci force-pushed the hooks-allownoverify branch 3 times, most recently from c9557f4 to fdf4546 Compare September 2, 2026 17:08
@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

There is an issue in commit fdf4546:
hooks: introduce 'hooks.allowNoVerify' configuration

  • Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
    Indented lines, and lines without whitespace, are exempt

@kairosci
kairosci force-pushed the hooks-allownoverify branch from fdf4546 to cc98af8 Compare September 2, 2026 17:11
@kairosci

kairosci commented Sep 2, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

Submitted as pull.2215.v3.git.1788369794965.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2215/kairosci/hooks-allownoverify-v3

To fetch this version to local tag pr-2215/kairosci/hooks-allownoverify-v3:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2215/kairosci/hooks-allownoverify-v3

@kairosci
kairosci force-pushed the hooks-allownoverify branch from cc98af8 to a9f7541 Compare September 2, 2026 17:29
@kairosci

kairosci commented Sep 2, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

Submitted as pull.2215.v4.git.1788371123325.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2215/kairosci/hooks-allownoverify-v4

To fetch this version to local tag pr-2215/kairosci/hooks-allownoverify-v4:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2215/kairosci/hooks-allownoverify-v4

@kairosci
kairosci force-pushed the hooks-allownoverify branch from a9f7541 to 992ec60 Compare September 2, 2026 17:46
Introduce the 'hook.allowNoVerify' configuration variable to control
whether the '--no-verify' (or '-n') command-line option is permitted
during operations executing client-side hooks (commit, push, merge,
rebase, am).

Client-side hooks execute in the user's local repository and cannot serve
as an authoritative security boundary; authoritative policy enforcement
belongs on the server (such as via pre-receive hooks). However,
developers often invoke '--no-verify' out of habit or muscle memory,
inadvertently skipping local checks.

To address concerns regarding false senses of security without breaking
legitimate emergency escape hatches, allow configuring the variable to
'true' (the default), 'warn', or 'false'. In 'warn' mode, Git permits
the bypass while emitting a warning to standard error, ensuring
visibility without interrupting urgent workflows.

When set to 'false', Git aborts execution and provides actionable advice
explaining that the setting is an ergonomic workflow guardrail. To avoid
trapping developers during broken hook scripts or critical hotfixes,
the guardrail can be overridden by passing '-c hook.allowNoVerify=true'
or by setting the 'GIT_ALLOW_NO_VERIFY=1' environment variable. This
prevents developers from having to resort to destructive workarounds
such as removing hook files or clearing execute permissions.

In automated or non-interactive environments such as CI/CD runners,
'warn' mode avoids pipeline failures while preserving audit visibility,
and 'GIT_ALLOW_NO_VERIFY=1' provides a clean override without modifying
configuration files.

Follow the canonical 'hook.*' configuration namespace established by
modern Git hook commands, while accepting 'hooks.allowNoVerify' as a
backward-compatible fallback. Centralize the option verification logic
across all affected commands into validate_no_verify() in hook.c.

Signed-off-by: Alessio Attilio <alessio.attilio@protonmail.com>
@kairosci
kairosci force-pushed the hooks-allownoverify branch from 992ec60 to 9344d71 Compare September 2, 2026 17:59
@dscho

dscho commented Sep 2, 2026

Copy link
Copy Markdown
Member

@kairosci quick word of warning: The Git maintainer usually gets pretty angry when people submit patch series in quick succession; As a rule of thumb, I'd suggest to leave a day or so between sending iterations.

@kairosci

kairosci commented Sep 2, 2026

Copy link
Copy Markdown
Author

I apologize. I will follow your advice moving forward.

@gitgitgadget

gitgitgadget Bot commented Sep 2, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Alessio Attilio <alessio.attilio@protonmail.com>
>
> Introduce 'hooks.allowNoVerify' as an opt-in workflow guardrail to
> prevent accidental bypass of hooks with '--no-verify' when set to false.
> Authoritative enforcement remains server-side.

Accidental

	$ git foo --no-verify

may be prevented by setting this configuration variable, but then
would we need another layer of protection to prevent accidental

	$ git -c hooks.allownoverify foo --no-verify

by introducing another configuration variable to forbid
hooks.allownoverify to be overriden?

I do not think we want to go into this slipperly slope.  Thanks for
sending a patch, but I am personally not interested.

Besides, verifications that users may be tempted to bypass, but want
to instill discipline to prevent bypassing, may not be implemented
as hooks, and the way they are bypassed may not be "--[no-]verify"
command line option.  When one wants a way to prevent such
verifications from getting disabled, the mechanism should also allow
forbidding verification that is built into the system from getting
disabled.  Limiting a settings to hooks is probably not a good idea,
and introducing a new "hooks." hierarchy for this setting is not
something we want to see.

@gitgitgadget

gitgitgadget Bot commented Sep 3, 2026

Copy link
Copy Markdown

"brian m. carlson" wrote on the Git mailing list (how to reply to this email):

On 2026-09-02 at 17:23:14, Alessio Attilio via GitGitGadget wrote:
> From: Alessio Attilio <alessio.attilio@protonmail.com>
> 
> Introduce the 'hooks.allowNoVerify' configuration variable to control
> whether the '--no-verify' (or '-n') command-line option is permitted
> during operations executing client-side hooks (commit, push, merge,
> rebase, am).
> 
> Client-side hooks execute in the user's local repository and cannot serve
> as an authoritative security boundary; authoritative policy enforcement
> belongs on the server (such as via pre-receive hooks). However,
> developers often invoke '--no-verify' out of habit or muscle memory,
> inadvertently skipping local checks.

I agree with Junio that this doesn't seem like a good idea.  It's up to
the user whether they want to install or use hooks and they are free to
disable them or override them as they see fit.  If the user doesn't want
to use local hooks on an individual case basis, then `--no-verify` is
the right option.

In my case, I use hooks for Git LFS when I use that software, but I
never use repository owner-provided hooks, although I may use my own. As
a result, I almost never use `--no-verify`.

If in your environment you are trying to force developers to use local
hooks, the Git FAQ mentions that this is not an effective control and
you should stop trying to do that.  In fact, I would even argue that you
should simply not install hooks by default for repositories using your
scripts or build tools because it's up to users whether those are useful
for them.  The Git FAQ mentions reasons why forced installation of hooks
is harmful for many workflows and I don't think we should be hassling
users like that.

In any event, it's trivial to simply bypass all hooks by setting
`core.hooksPath` to `/dev/null` using a variety of different techniques.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

@gitgitgadget

gitgitgadget Bot commented Sep 3, 2026

Copy link
Copy Markdown

User "brian m. carlson" <sandals@crustytoothpaste.net> has been added to the cc: list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants