aboutsummaryrefslogtreecommitdiffstats
path: root/git-tools
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-03-01 20:17:59 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-03-01 20:59:04 -0500
commitc489b189df39c75195f85ab26afe08cd44ad7f2e (patch)
treeb64b2009dccf56c5d5ebf1b5a6a973f9ffc7ec4d /git-tools
parent9bed2b119c9d3214b7869cecb416a231878aad66 (diff)
downloadforums-c489b189df39c75195f85ab26afe08cd44ad7f2e.tar
forums-c489b189df39c75195f85ab26afe08cd44ad7f2e.tar.gz
forums-c489b189df39c75195f85ab26afe08cd44ad7f2e.tar.bz2
forums-c489b189df39c75195f85ab26afe08cd44ad7f2e.tar.xz
forums-c489b189df39c75195f85ab26afe08cd44ad7f2e.zip
[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
Diffstat (limited to 'git-tools')
-rwxr-xr-xgit-tools/hooks/commit-msg11
1 files changed, 11 insertions, 0 deletions
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 ]