It is actually not only the commit-msg, but also the prepare-commit-msg
hook...

Changes since v1:

- changed `int flags` to `unsigned int flags`

- uncuddled the if...else if... construct to not mix the "goto leave"
  logic with the one adding the VERIFY_MSG flag


Johannes Schindelin (3):
  t7504: document regression: reword no longer calls commit-msg
  sequencer: make commit options more extensible
  sequencer: allow the commit-msg hooks to run during a `reword`

 sequencer.c                | 54 ++++++++++++++++++++++++++--------------------
 t/t7504-commit-msg-hook.sh | 17 +++++++++++++++
 2 files changed, 48 insertions(+), 23 deletions(-)


base-commit: afd6726309f57f532b4b989a75c1392359c611cc
Published-As: 
https://github.com/dscho/git/releases/tag/reword-commit-msg-hook-v2
Fetch-It-Via: git fetch https://github.com/dscho/git reword-commit-msg-hook-v2

Interdiff vs v1:

 diff --git a/sequencer.c b/sequencer.c
 index 377af91c475..bc2fe48e65c 100644
 --- a/sequencer.c
 +++ b/sequencer.c
 @@ -621,7 +621,7 @@ N_("you have staged changes in your working tree\n"
   * author metadata.
   */
  static int run_git_commit(const char *defmsg, struct replay_opts *opts,
 -                        int flags)
 +                        unsigned int flags)
  {
        struct child_process cmd = CHILD_PROCESS_INIT;
        const char *value;
 @@ -932,7 +932,7 @@ static void record_in_rewritten(struct object_id *oid,
  static int do_pick_commit(enum todo_command command, struct commit *commit,
                struct replay_opts *opts, int final_fixup)
  {
 -      int flags = opts->edit ? EDIT_MSG : 0, allow = 0;
 +      unsigned int flags = opts->edit ? EDIT_MSG : 0, allow = 0;
        const char *msg_file = opts->edit ? NULL : git_path_merge_msg();
        unsigned char head[20];
        struct commit *base, *next, *parent;
 @@ -995,13 +995,11 @@ static int do_pick_commit(enum todo_command command, 
struct commit *commit,
                        write_author_script(msg.message);
                res = fast_forward_to(commit->object.oid.hash, head, unborn,
                        opts);
 -              if (res)
 -                      goto leave;
 -              else if (command == TODO_REWORD)
 -                      flags |= VERIFY_MSG;
 -              else
 +              if (res || command != TODO_REWORD)
                        goto leave;
                flags |= EDIT_MSG | AMEND_MSG;
 +              if (command == TODO_REWORD)
 +                      flags |= VERIFY_MSG;
                msg_file = NULL;
                goto fast_forward_edit;
        }
 @@ -2164,7 +2162,7 @@ static int continue_single_pick(void)
  
  static int commit_staged_changes(struct replay_opts *opts)
  {
 -      int flags = ALLOW_EMPTY | EDIT_MSG;
 +      unsigned int flags = ALLOW_EMPTY | EDIT_MSG;
  
        if (has_unstaged_changes(1))
                return error(_("cannot rebase: You have unstaged changes."));

-- 
2.12.1.windows.1

Reply via email to