From c489b189df39c75195f85ab26afe08cd44ad7f2e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 1 Mar 2011 20:17:59 -0500 Subject: [ticket/9824] Handle empty commit messages in commit-msg hook. Git already handles the case of commit message being empty by aborting the commit and displaying a reasonably helpful message. If there is no commit message, the hook will exit with success exit code to let git do its thing. PHPBB3-9824 --- git-tools/hooks/commit-msg | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'git-tools') diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index a6777ff9c9..1d33995162 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -55,6 +55,17 @@ quit() fi } +# Check for empty commit message +if ! grep -qv '^#' "$1" +then + # Commit message is empty (or contains only comments). + # Let git handle this. + # It will abort with a message like so: + # + # Aborting commit due to empty commit message. + exit 0 +fi + msg=$(grep -nE '.{81,}' "$1"); if [ $? -eq 0 ] -- cgit v1.2.1