Skip to content

Running pre-commit hooks before editing commit log #449

dudebout opened this Issue Jul 19, 2012 · 2 comments

3 participants

Magit member

This issue was raised on stackoverflow. I copy the question for convenience.

With git on the command line, you see the result of your pre-commit hooks before entering the commit's log message. If your pre-commit hook makes the commit fail, you are warnt and don't write anything.

But with magit, you are asked to enter your log comment and then it evaluates your hook, and if it fails you don't see why. You just read :

git exited abnormally with code 1. I understand this is normal because it is when you are finished editing the log message that magit runs the git command.

So, how would you make magit to evaluate your hook before asking for the log ? How can you make magit display the result of the hook ?

And a related question would be, how do you give arguments to you pre-commit hook in order to run it for the stashed files only, instead of all the files in the repository ?

I use pre-commit hooks mainly to check if I didn't forget debugging stuff, like a remaining 'ipdb', and some personal traces.

@vanicat vanicat added a commit to vanicat/magit that referenced this issue Jul 24, 2012
@vanicat vanicat Call pre-commit hook before creating the log-edit buffer
Fix #449
ocrete commented Jan 26, 2013

Or another way to work around this would be to save the commit message on failure, so it can be recalled later.

vanicat commented Jan 30, 2013

Commit message are always saved, and can be recalled using M-n and M-p

@dudebout dudebout closed this Apr 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.