Skip to content

Commit 4627bc7

Browse files
phillipwoodgitster
authored andcommitted
sequencer: run post-commit hook
Prior to commit 356ee46 ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 49697cb commit 4627bc7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

sequencer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ static int try_to_commit(struct repository *r,
14011401
goto out;
14021402
}
14031403

1404+
run_commit_hook(0, r->index_file, "post-commit", NULL);
14041405
if (flags & AMEND_MSG)
14051406
commit_post_rewrite(r, current_head, oid);
14061407

t/t3404-rebase-interactive.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,25 @@ test_expect_success 'valid author header when author contains single quote' '
15831583
test_cmp expected actual
15841584
'
15851585

1586+
test_expect_success 'post-commit hook is called' '
1587+
test_when_finished "rm -f .git/hooks/post-commit" &&
1588+
>actual &&
1589+
mkdir -p .git/hooks &&
1590+
write_script .git/hooks/post-commit <<-\EOS &&
1591+
git rev-parse HEAD >>actual
1592+
EOS
1593+
(
1594+
set_fake_editor &&
1595+
FAKE_LINES="edit 4 1 reword 2 fixup 3" git rebase -i A E &&
1596+
echo x>file3 &&
1597+
git add file3 &&
1598+
FAKE_COMMIT_MESSAGE=edited git rebase --continue
1599+
) &&
1600+
git rev-parse HEAD@{5} HEAD@{4} HEAD@{3} HEAD@{2} HEAD@{1} HEAD \
1601+
>expect &&
1602+
test_cmp expect actual
1603+
'
1604+
15861605
# This must be the last test in this file
15871606
test_expect_success '$EDITOR and friends are unchanged' '
15881607
test_editor_unchanged

0 commit comments

Comments
 (0)