Skip to content

Commit b92ff6e

Browse files
dschogitster
authored andcommitted
sequencer: allow the commit-msg hooks to run during a reword
The `reword` command used to call `git commit` in a manner that asks for the prepare-commit-msg and commit-msg hooks to do their thing. Converting that part of the interactive rebase to C code introduced the regression where those hooks were no longer run. Let's fix this. Note: the flag is called `VERIFY_MSG` instead of the more intuitive `RUN_COMMIT_MSG_HOOKS` to indicate that the flag suppresses the `--no-verify` flag (which may do other things in the future in addition to suppressing the commit message hooks, too). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 789b3ef commit b92ff6e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

sequencer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ N_("you have staged changes in your working tree\n"
606606
#define EDIT_MSG (1<<1)
607607
#define AMEND_MSG (1<<2)
608608
#define CLEANUP_MSG (1<<3)
609+
#define VERIFY_MSG (1<<4)
609610

610611
/*
611612
* If we are cherry-pick, and if the merge did not result in
@@ -642,8 +643,9 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
642643
}
643644

644645
argv_array_push(&cmd.args, "commit");
645-
argv_array_push(&cmd.args, "-n");
646646

647+
if (!(flags & VERIFY_MSG))
648+
argv_array_push(&cmd.args, "-n");
647649
if ((flags & AMEND_MSG))
648650
argv_array_push(&cmd.args, "--amend");
649651
if (opts->gpg_sign)
@@ -996,6 +998,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
996998
if (res || command != TODO_REWORD)
997999
goto leave;
9981000
flags |= EDIT_MSG | AMEND_MSG;
1001+
if (command == TODO_REWORD)
1002+
flags |= VERIFY_MSG;
9991003
msg_file = NULL;
10001004
goto fast_forward_edit;
10011005
}
@@ -1050,7 +1054,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
10501054
}
10511055

10521056
if (command == TODO_REWORD)
1053-
flags |= EDIT_MSG;
1057+
flags |= EDIT_MSG | VERIFY_MSG;
10541058
else if (is_fixup(command)) {
10551059
if (update_squash_messages(command, commit, opts))
10561060
return -1;

t/t7504-commit-msg-hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ chmod +x reword-editor
230230
REWORD_EDITOR="$(pwd)/reword-editor"
231231
export REWORD_EDITOR
232232

233-
test_expect_failure 'hook is called for reword during `rebase -i`' '
233+
test_expect_success 'hook is called for reword during `rebase -i`' '
234234
235235
GIT_SEQUENCE_EDITOR="\"$REWORD_EDITOR\"" git rebase -i HEAD^ &&
236236
commit_msg_is "new message"

0 commit comments

Comments
 (0)