]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: run post-commit hook
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Tue, 15 Oct 2019 10:25:32 +0000 (10:25 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Oct 2019 01:30:51 +0000 (10:30 +0900)
Prior to commit 356ee4659b ("sequencer: try to commit without forking
'git commit'", 2017-11-24) the sequencer would always run the
post-commit hook after each pick or revert as it forked `git commit` to
create the commit. The conversion to committing without forking `git
commit` omitted to call the post-commit hook after creating the commit.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
t/t3404-rebase-interactive.sh

index cdc0d1dfba77d29db321b1749ce666ead394844e..da2decbd3af47f6320ac64d228e99e4be5204f2a 100644 (file)
@@ -1401,6 +1401,7 @@ static int try_to_commit(struct repository *r,
                goto out;
        }
 
+       run_commit_hook(0, r->index_file, "post-commit", NULL);
        if (flags & AMEND_MSG)
                commit_post_rewrite(r, current_head, oid);
 
index c5d0326825af33cfe2eec327fb5d5f461bfc8aa2..c573c99069b44cb74b5bf1c48cd01a5f40a767c4 100755 (executable)
@@ -1583,6 +1583,25 @@ test_expect_success 'valid author header when author contains single quote' '
        test_cmp expected actual
 '
 
+test_expect_success 'post-commit hook is called' '
+       test_when_finished "rm -f .git/hooks/post-commit" &&
+       >actual &&
+       mkdir -p .git/hooks &&
+       write_script .git/hooks/post-commit <<-\EOS &&
+       git rev-parse HEAD >>actual
+       EOS
+       (
+               set_fake_editor &&
+               FAKE_LINES="edit 4 1 reword 2 fixup 3" git rebase -i A E &&
+               echo x>file3 &&
+               git add file3 &&
+               FAKE_COMMIT_MESSAGE=edited git rebase --continue
+       ) &&
+       git rev-parse HEAD@{5} HEAD@{4} HEAD@{3} HEAD@{2} HEAD@{1} HEAD \
+               >expect &&
+       test_cmp expect actual
+'
+
 # This must be the last test in this file
 test_expect_success '$EDITOR and friends are unchanged' '
        test_editor_unchanged