3

Every time I have a second line in a commit message, magit prompts/warns me when commiting...

Is there a way I can turn this off warning?

I've found the following in the docs https://magit.vc/manual/magit.html#Initiating-a-Commit:

Function: git-commit-check-style-conventions Check for violations of certain basic style conventions. For each violation ask the user if she wants to proceed anyway. This makes sure the summary line isn’t too long and that the second line is empty.

Which is a function defined here: https://github.com/magit/magit/blob/4b97f23ace4132b3313a1bca73dcbbcd06bb4b9b/lisp/git-commit.el#L624

Any thoughts how I can override / disable it?

1 Answer 1

9

You can disable it, but you really shouldn't. A near-universal1 git convention is to use blank lines to separate paragraphs, including separating the commit summary from the extended description. This is recommended in the man page and online documentation for git commit:

The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git.

One place you'll notice this is magit-log-current (and the other magit log functions), where all lines up to the first blank line will be included (just like in git log --oneline).

But note that other tools, including GitHub, do not include the additional lines in the summary. Therefore, limiting the summary to one line and leaving the second line blank seems to be the best style.


To answer your question, though, if you really want to turn off the warning, just remove non-empty-second-line from the git-commit-style-convention-checks list.

(setq git-commit-style-convention-checks
      (remove 'non-empty-second-line git-commit-style-convention-checks))

This also works, but potentially clobbers other settings as well:

(setq git-commit-style-convention-checks nil)

1 While I'm not going to go so far as to analyze every commit on GitHub, I'll note that every commit style I found by searching "git commit style" (on both Google and DuckDuckGo includes this recommendation (except for one that only talked about using emoji in the summary and didn't mention the description at all).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.