Commit af4bf8df authored by Jonas Bernoulli's avatar Jonas Bernoulli

git-commit-post-finish-hook: Don't run for unsafe commands

When a command like "git rebase --continue" used `EDITOR' to have the
user provide a commit message and created a commit with the message it
received that way, then it goes on doing other things that may need to
lock the index.

We therefore cannot run `git-commit-post-finish-hook' after the commit
was created because otherwise there would be a race condition between
the subprocesses of "git rebase" and whatever git commands the hook
calls.  Blacklist commands known to keep going after committing.

This was previously done in `magit-wip-maybe-add-commit-hook', but we
need to prevent all of `git-commit-post-finish-hook' to be inhibited.
parent d445a3d3
......@@ -198,7 +198,9 @@ user typing a message into a buffer, then this hook is not run.
This hook is not run until the new commit has been created. If
doing so takes Git longer than one second, then this hook isn't
run at all.
run at all. For certain commands such as `magit-rebase-continue'
this hook is never run because doing so would lead to a race
condition.
Also see `magit-post-commit-hook'."
:group 'git-commit
......@@ -500,7 +502,14 @@ This is only used if Magit is available."
'git-commit-save-message nil t)
(add-hook 'with-editor-pre-cancel-hook
'git-commit-save-message nil t)
(when (fboundp 'magit-rev-parse)
(when (and (fboundp 'magit-rev-parse)
(not (memq last-command
'(magit-sequencer-continue
magit-sequencer-skip
magit-am-continue
magit-am-skip
magit-rebase-continue
magit-rebase-skip))))
(add-hook 'with-editor-post-finish-hook
(apply-partially 'git-commit-run-post-finish-hook
(magit-rev-parse "HEAD"))
......
......@@ -352,14 +352,7 @@ commit message."
(defun magit-wip-maybe-add-commit-hook ()
(when (and magit-wip-merge-branch
(magit-wip-any-enabled-p)
(not (memq last-command
'(magit-sequencer-continue
magit-sequencer-skip
magit-am-continue
magit-am-skip
magit-rebase-continue
magit-rebase-skip))))
(magit-wip-any-enabled-p))
(add-hook 'git-commit-post-finish-hook 'magit-wip-commit nil t)))
(defun magit-wip-any-enabled-p ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment