* git revert --continue --no-verify
@ 2021-08-03 19:17 Cameron Steffen
2021-08-03 20:50 ` Taylor Blau
0 siblings, 1 reply; 10+ messages in thread
From: Cameron Steffen @ 2021-08-03 19:17 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 19:17 git revert --continue --no-verify Cameron Steffen
@ 2021-08-03 20:50 ` Taylor Blau
2021-08-03 20:56 ` Cameron Steffen
0 siblings, 1 reply; 10+ messages in thread
From: Taylor Blau @ 2021-08-03 20:50 UTC (permalink / raw)
To: Cameron Steffen; +Cc: git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 20:50 ` Taylor Blau
@ 2021-08-03 20:56 ` Cameron Steffen
2021-08-03 20:59 ` Taylor Blau
0 siblings, 1 reply; 10+ messages in thread
From: Cameron Steffen @ 2021-08-03 20:56 UTC (permalink / raw)
To: Taylor Blau; +Cc: git
`--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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 20:56 ` Cameron Steffen
@ 2021-08-03 20:59 ` Taylor Blau
2021-08-03 21:33 ` Cameron Steffen
0 siblings, 1 reply; 10+ messages in thread
From: Taylor Blau @ 2021-08-03 20:59 UTC (permalink / raw)
To: Cameron Steffen; +Cc: Taylor Blau, git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 20:59 ` Taylor Blau
@ 2021-08-03 21:33 ` Cameron Steffen
2021-08-03 22:07 ` Taylor Blau
0 siblings, 1 reply; 10+ messages in thread
From: Cameron Steffen @ 2021-08-03 21:33 UTC (permalink / raw)
To: Taylor Blau; +Cc: git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 21:33 ` Cameron Steffen
@ 2021-08-03 22:07 ` Taylor Blau
2021-08-04 0:38 ` Junio C Hamano
2021-08-04 18:14 ` Phillip Wood
0 siblings, 2 replies; 10+ messages in thread
From: Taylor Blau @ 2021-08-03 22:07 UTC (permalink / raw)
To: Cameron Steffen; +Cc: Taylor Blau, git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 22:07 ` Taylor Blau
@ 2021-08-04 0:38 ` Junio C Hamano
2021-08-04 18:14 ` Phillip Wood
1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2021-08-04 0:38 UTC (permalink / raw)
To: Taylor Blau; +Cc: Cameron Steffen, git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-03 22:07 ` Taylor Blau
2021-08-04 0:38 ` Junio C Hamano
@ 2021-08-04 18:14 ` Phillip Wood
2021-08-05 1:40 ` Taylor Blau
1 sibling, 1 reply; 10+ messages in thread
From: Phillip Wood @ 2021-08-04 18:14 UTC (permalink / raw)
To: Taylor Blau, Cameron Steffen; +Cc: git
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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-04 18:14 ` Phillip Wood
@ 2021-08-05 1:40 ` Taylor Blau
2021-08-05 1:56 ` Cameron Steffen
0 siblings, 1 reply; 10+ messages in thread
From: Taylor Blau @ 2021-08-05 1:40 UTC (permalink / raw)
To: Phillip Wood; +Cc: Taylor Blau, Cameron Steffen, git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: git revert --continue --no-verify
2021-08-05 1:40 ` Taylor Blau
@ 2021-08-05 1:56 ` Cameron Steffen
0 siblings, 0 replies; 10+ messages in thread
From: Cameron Steffen @ 2021-08-05 1:56 UTC (permalink / raw)
To: Taylor Blau; +Cc: Phillip Wood, git
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-08-05 1:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 19:17 git revert --continue --no-verify Cameron Steffen
2021-08-03 20:50 ` Taylor Blau
2021-08-03 20:56 ` Cameron Steffen
2021-08-03 20:59 ` Taylor Blau
2021-08-03 21:33 ` Cameron Steffen
2021-08-03 22:07 ` Taylor Blau
2021-08-04 0:38 ` Junio C Hamano
2021-08-04 18:14 ` Phillip Wood
2021-08-05 1:40 ` Taylor Blau
2021-08-05 1:56 ` Cameron Steffen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.