Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a Git post-commit hook on non-interactive rebase not run?

Given an arbitrary, executable Git post-commit hook it is not run during a non-interactive rebase, neither with rebase --force-rebase nor with rebase --no-ff which is a synonym for the former in non-interactive mode according to the GIT-REBASE(1) Manpage.

But by doing an interactive rebase with rebase --interactive --no-ff the very same Git hook is run on post-commit.

Can someone explain the rationale behind this behavior.

like image 543
Tim Friske Avatar asked Mar 31 '15 14:03

Tim Friske


1 Answers

But by doing an interactive rebase with rebase --interactive --no-ff, the very same Git hook is run on post-commit.

Actually, the post-commit hook is not run on an interactive rebase since Git 2.17+ (Q4 2017)

It is only run again (on git rebase -i) with Git 2.25+ (Q1 2020): "rebase -i" ceased to run the post-commit hook by mistake in an earlier update, which has been corrected.

See commit 4627bc7, commit 49697cb, commit 12bb7a5, commit 6a619ca, commit b2dbacb, commit 88a92b6 (15 Oct 2019) by Phillip Wood (phillipwood).
(Merged by Junio C Hamano -- gitster -- in commit 5c8c0a0, 10 Nov 2019)

sequencer: run post-commit hook

Signed-off-by: Phillip Wood

Prior to commit 356ee4659b ("sequencer: try to commit without forking 'git commit'", 2017-11-24, Git v2.17.0-rc0 -- merge listed in batch #2) 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.

like image 52
VonC Avatar answered Oct 11 '22 10:10

VonC