# git revert --continue --no-verify

10 messages from 2021-08-03 to 2021-08-05. Participants: Cameron Steffen, Taylor Blau, Junio C Hamano, Phillip Wood.
Thread: https://gitlist.dev/t/56208

## Cameron Steffen, 2021-08-03 19:17

Subject: git revert --continue --no-verify
Message-ID: <CAAVFnNkW6Bc4bBDeea2v-VFydvEC0dBw+QXVA0-6OnmF8km3ZA@mail.gmail.com>
URL: https://gitlist.dev/e/CAAVFnNkW6Bc4bBDeea2v-VFydvEC0dBw%2BQXVA0-6OnmF8km3ZA%40mail.gmail.com

```
Today I tried to run this command and I just got a help screen. I am
using 2.32.0.

git revert --continue --no-verify

```

## Taylor Blau, 2021-08-03 20:50

Subject: Re: git revert --continue --no-verify
Message-ID: <YQmsJUe6hAMy/QGA@nand.local>
URL: https://gitlist.dev/e/YQmsJUe6hAMy%2FQGA%40nand.local
In-Reply-To: <CAAVFnNkW6Bc4bBDeea2v-VFydvEC0dBw+QXVA0-6OnmF8km3ZA@mail.gmail.com>

```
Hi Cameron,

On Tue, Aug 03, 2021 at 02:17:07PM -0500, Cameron Steffen wrote:
> Today I tried to run this command and I just got a help screen. I am
> using 2.32.0.
>
> git revert --continue --no-verify

I can't think of any sequencer commands that support a `--[no-]verify`
argument. Did you mistake `--no-verify` for something else, like
`--no-edit` or `--no-commit`?

Thanks,
Taylor

```

## Cameron Steffen, 2021-08-03 20:56

Subject: Re: git revert --continue --no-verify
Message-ID: <CAAVFnN=W27rdE1EH-joscyJEooAsDrdtPropVVaBYwhte=cPJA@mail.gmail.com>
URL: https://gitlist.dev/e/CAAVFnN%3DW27rdE1EH-joscyJEooAsDrdtPropVVaBYwhte%3DcPJA%40mail.gmail.com
In-Reply-To: <YQmsJUe6hAMy/QGA@nand.local>

```
`--no-verify` is an argument typically used with `git commit` in order
to skip the pre-commit hook. Since the pre-commit hook also runs on
`git revert --continue`, I expected to be able to use `--no-verify`.

On Tue, Aug 3, 2021 at 3:50 PM Taylor Blau <me@ttaylorr.com> wrote:
>
> Hi Cameron,
>
> On Tue, Aug 03, 2021 at 02:17:07PM -0500, Cameron Steffen wrote:
> > Today I tried to run this command and I just got a help screen. I am
> > using 2.32.0.
> >
> > git revert --continue --no-verify
>
> I can't think of any sequencer commands that support a `--[no-]verify`
> argument. Did you mistake `--no-verify` for something else, like
> `--no-edit` or `--no-commit`?
>
> Thanks,
> Taylor

```

## Taylor Blau, 2021-08-03 20:59

Subject: Re: git revert --continue --no-verify
Message-ID: <YQmuT2ZYe1mzHBjI@nand.local>
URL: https://gitlist.dev/e/YQmuT2ZYe1mzHBjI%40nand.local
In-Reply-To: <CAAVFnN=W27rdE1EH-joscyJEooAsDrdtPropVVaBYwhte=cPJA@mail.gmail.com>

```
On Tue, Aug 03, 2021 at 03:56:49PM -0500, Cameron Steffen wrote:
> `--no-verify` is an argument typically used with `git commit` in order
> to skip the pre-commit hook. Since the pre-commit hook also runs on
> `git revert --continue`, I expected to be able to use `--no-verify`.

No, `git revert` doesn't pass unknown options down to `git commit`.

Thanks,
Taylor

```

## Cameron Steffen, 2021-08-03 21:33

Subject: Re: git revert --continue --no-verify
Message-ID: <CAAVFnNmitHeimogaGUUwWGWhve+wbF6CXcSNUonGCWAgOSKzjA@mail.gmail.com>
URL: https://gitlist.dev/e/CAAVFnNmitHeimogaGUUwWGWhve%2BwbF6CXcSNUonGCWAgOSKzjA%40mail.gmail.com
In-Reply-To: <YQmuT2ZYe1mzHBjI@nand.local>

```
Perhaps the issue then is that the pre-commit hook should not run for
`git revert --continue`? It does not run for `git revert`.

On Tue, Aug 3, 2021 at 4:00 PM Taylor Blau <me@ttaylorr.com> wrote:
>
> On Tue, Aug 03, 2021 at 03:56:49PM -0500, Cameron Steffen wrote:
> > `--no-verify` is an argument typically used with `git commit` in order
> > to skip the pre-commit hook. Since the pre-commit hook also runs on
> > `git revert --continue`, I expected to be able to use `--no-verify`.
>
> No, `git revert` doesn't pass unknown options down to `git commit`.
>
> Thanks,
> Taylor

```

## Taylor Blau, 2021-08-03 22:07

Subject: Re: git revert --continue --no-verify
Message-ID: <YQm+PWAtc3rixqsw@nand.local>
URL: https://gitlist.dev/e/YQm%2BPWAtc3rixqsw%40nand.local
In-Reply-To: <CAAVFnNmitHeimogaGUUwWGWhve+wbF6CXcSNUonGCWAgOSKzjA@mail.gmail.com>

```
On Tue, Aug 03, 2021 at 04:33:09PM -0500, Cameron Steffen wrote:
> Perhaps the issue then is that the pre-commit hook should not run for
> `git revert --continue`? It does not run for `git revert`.

This does look like an oversight to me, but you'll have to bear with me
since I am relatively unfamiliar with the sequencer code.

Ultimately `git revert` calls do_pick_commit() which either calls
do_commit() or run_git_commit(). A couple of curiosities there:

  - do_commit() does fall back to run_git_commit() if it has the
    VERIFY_MSG bit set in `flags`.
  - run_git_commit() passes `-n` only when VERIFY_MSG *isn't* set, so
    the VERIFY_MSG bit does imply that the pre-commit hook would be run
    there.
  - when do_pick_commit() does have to fall back to run_git_commit(), it
    sets the VERIFY_MSG bit in flags.

But we never end up calling run_git_commit() (except in the case of
errors) because do_pick_commit() special-cases `command == TODO_REVERT`
(which is the case for `git revert`) and calls `do_commit()`.

But it gets weirder: do_commit() calls run_git_commit() itself, but
before the caller in do_pick_commit() has had a chance to add VERIFY_MSG
to the flags.

So I suspect that this is an oversight, but perhaps somebody more
familiar with this code could confirm my thinking.

Thanks,
Taylor

```

## Junio C Hamano, 2021-08-04 00:38

Subject: Re: git revert --continue --no-verify
Message-ID: <xmqq4kc6rqmi.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq4kc6rqmi.fsf%40gitster.g
In-Reply-To: <YQm+PWAtc3rixqsw@nand.local>

```
Taylor Blau <me@ttaylorr.com> writes:

> On Tue, Aug 03, 2021 at 04:33:09PM -0500, Cameron Steffen wrote:
>> Perhaps the issue then is that the pre-commit hook should not run for
>> `git revert --continue`? It does not run for `git revert`.
>
> This does look like an oversight to me, but you'll have to bear with me
> since I am relatively unfamiliar with the sequencer code.
>
> Ultimately `git revert` calls do_pick_commit() which either calls
> do_commit() or run_git_commit(). A couple of curiosities there:
>
>   - do_commit() does fall back to run_git_commit() if it has the
>     VERIFY_MSG bit set in `flags`.
>   - run_git_commit() passes `-n` only when VERIFY_MSG *isn't* set, so
>     the VERIFY_MSG bit does imply that the pre-commit hook would be run
>     there.
>   - when do_pick_commit() does have to fall back to run_git_commit(), it
>     sets the VERIFY_MSG bit in flags.
>
> But we never end up calling run_git_commit() (except in the case of
> errors) because do_pick_commit() special-cases `command == TODO_REVERT`
> (which is the case for `git revert`) and calls `do_commit()`.
>
> But it gets weirder: do_commit() calls run_git_commit() itself, but
> before the caller in do_pick_commit() has had a chance to add VERIFY_MSG
> to the flags.
>
> So I suspect that this is an oversight, but perhaps somebody more
> familiar with this code could confirm my thinking.

IIRC, the "--continue" option that creates a commit came much later
for lazy folks; the norm was to conclude your conflict resolution
with "git commit" so that the HEAD and the index and the working
tree matches before running "--continue".  Wouldn't that work in
this case?  That is

    $ git <some sequencing command> A..B
    ...
    ... stops with conflict
    $ edit
    $ git add ...
    $ git commit --no-verify
    $ git <that sequencing command> --continue


    

```

## Phillip Wood, 2021-08-04 18:14

Subject: Re: git revert --continue --no-verify
Message-ID: <74443c64-efe9-ea47-e918-d62b8c976abc@gmail.com>
URL: https://gitlist.dev/e/74443c64-efe9-ea47-e918-d62b8c976abc%40gmail.com
In-Reply-To: <YQm+PWAtc3rixqsw@nand.local>

```
Hi Cameron and Taylor

On 03/08/2021 23:07, Taylor Blau wrote:
> On Tue, Aug 03, 2021 at 04:33:09PM -0500, Cameron Steffen wrote:
>> Perhaps the issue then is that the pre-commit hook should not run for
>> `git revert --continue`? It does not run for `git revert`.

The general rule for cherry-pick, revert and rebase is that if the 
commit message is edited then the commit is made with --verify and if 
the commit message is not being edited then the commit is made with 
--no-verify. I think the reasoning for this is that if the user has 
altered the commit message or contents and they have a pre-commit hook 
set then it is reasonable to check the new commit is acceptable to the 
hook. There are some exceptions to this which are oversights (for 
example I think we always pass --no-verify when committing a conflict 
resolution with 'git rebase --continue' even though the editor opens 
when committing in that case - I should try and fix that)

For 'git revert --continue' the commit is made when sequencer_continue() 
calls continue_single_pick() which looks like

static int continue_single_pick(struct repository *r, struct replay_opts 
*opts)
{
	struct strvec argv = STRVEC_INIT;
	int ret;

	if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
	    !refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD"))
		return error(_("no cherry-pick or revert in progress"));

	strvec_push(&argv, "commit");

	/*
	 * continue_single_pick() handles the case of recovering from a
	 * conflict.  should_edit() doesn't handle that case; for a conflict,
	 * we want to edit if the user asked for it, or if they didn't specify
	 * and stdin is a tty.
	 */
	if (!opts->edit || (opts->edit < 0 && !isatty(0)))
		/*
		 * Include --cleanup=strip as well because we don't want the
		 * "# Conflicts:" messages.
		 */
		strvec_pushl(&argv, "--no-edit", "--cleanup=strip", NULL);

	ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
	strvec_clear(&argv);
	return ret;
}

It runs git commit directly and never passes --no-verify. I wouldn't be 
opposed to someone adding support for --no-verify (and --no-edit) to 
"cherry-pick/revert/rebase --continue" on the understanding that it only 
applied when committing the conflict resolution. There is a possible 
confusion for users though who might expect that the options passed with 
'--continue' applied to all the commits made by the command.

> This does look like an oversight to me, but you'll have to bear with me
> since I am relatively unfamiliar with the sequencer code.
> 
> Ultimately `git revert` calls do_pick_commit()

This is what happens when we are picking commits, the commit made with 
'--continue' uses a different code path

> which either calls
> do_commit() or run_git_commit(). A couple of curiosities there:
> 
>    - do_commit() does fall back to run_git_commit() if it has the
>      VERIFY_MSG bit set in `flags`.
>    - run_git_commit() passes `-n` only when VERIFY_MSG *isn't* set, so
>      the VERIFY_MSG bit does imply that the pre-commit hook would be run
>      there.
>    - when do_pick_commit() does have to fall back to run_git_commit(), it
>      sets the VERIFY_MSG bit in flags.

Calling run_git_commit() there is not a fallback it, that call is used 
to reword commits once they have been picked (see 450efe2d53 ("rebase 
-i: always update HEAD before rewording", 2019-08-19) for the reasoning 
behind this) . Because the message is being edited there is no point in 
going through do_commit().

> But we never end up calling run_git_commit() (except in the case of
> errors) because do_pick_commit() special-cases `command == TODO_REVERT`
> (which is the case for `git revert`) and calls `do_commit()`.
> 
> But it gets weirder: do_commit() calls run_git_commit() itself, but
> before the caller in do_pick_commit() has had a chance to add VERIFY_MSG
> to the flags.

do_commit() does not change the flags that it is called with - callers 
that want VERIFY_MSG will set that before they call do_commit(). 
do_commit() is there to commit simple picks without forking 'git commit'

> So I suspect that this is an oversight, but perhaps somebody more
> familiar with this code could confirm my thinking.

I hope the above helps - basically the idea is "if the commit has been 
edited use VERIFY_MSG" and --continue unhelpfully uses a completely 
different code-path to the main commit picking/reverting loop.

Best Wishes

Phillip

> Thanks,
> Taylor
> 


```

## Taylor Blau, 2021-08-05 01:40

Subject: Re: git revert --continue --no-verify
Message-ID: <YQtBezRE3l09cILa@nand.local>
URL: https://gitlist.dev/e/YQtBezRE3l09cILa%40nand.local
In-Reply-To: <74443c64-efe9-ea47-e918-d62b8c976abc@gmail.com>

```
On Wed, Aug 04, 2021 at 07:14:34PM +0100, Phillip Wood wrote:
> [...] I wouldn't be opposed to someone adding support for --no-verify
> (and --no-edit) to "cherry-pick/revert/rebase --continue" on the
> understanding that it only applied when committing the conflict
> resolution. There is a possible confusion for users though who might
> expect that the options passed with '--continue' applied to all the
> commits made by the command.

Yeah, that feels like we are just trying to confuse the user ;). So I
agree that I'd rather not go any further along that direction.

> do_commit() does not change the flags that it is called with - callers that
> want VERIFY_MSG will set that before they call do_commit(). do_commit() is
> there to commit simple picks without forking 'git commit'
>
> > So I suspect that this is an oversight, but perhaps somebody more
> > familiar with this code could confirm my thinking.
>
> I hope the above helps - basically the idea is "if the commit has been
> edited use VERIFY_MSG" and --continue unhelpfully uses a completely
> different code-path to the main commit picking/reverting loop.

Makes sense, thanks.

Taylor

```

## Cameron Steffen, 2021-08-05 01:56

Subject: Re: git revert --continue --no-verify
Message-ID: <CAAVFnN=ynj8sa-5YPmU7=s2OcXzy8a_gsxRxVxFD_9LgWQOBtg@mail.gmail.com>
URL: https://gitlist.dev/e/CAAVFnN%3Dynj8sa-5YPmU7%3Ds2OcXzy8a_gsxRxVxFD_9LgWQOBtg%40mail.gmail.com
In-Reply-To: <YQtBezRE3l09cILa@nand.local>

```
I've updated my mental model to include "--continue is a shortcut for
`git commit && ..`". That is a big help and resolves the issue for me
since I know I can always fall back to running `git commit` manually.
Thanks for all the replies!

Cameron

```
