Subject: Re: git revert --continue --no-verify

From: Junio C Hamano <[email-masked]>
Date: Tue, 03 Aug 2021 17:38:13 -0700

Taylor Blau <[email-masked]> 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