diff options
author | Brad King <brad.king@kitware.com> | 2010-04-28 13:35:19 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-04-28 13:35:19 -0400 |
commit | 7cd6238240d440f0a69a0f4e8eecc3b2a23a1973 (patch) | |
tree | 680c7ae7acc372a0aae4f501acd9042435b51cd6 | |
parent | 0df83855da1e4dcf59bdfe22a939d3f1ddf2a02a (diff) | |
download | cmake-7cd6238240d440f0a69a0f4e8eecc3b2a23a1973.tar.gz |
commit-msg: Exclude diff during "git commit -v"
Stop processing the commit message text at a "diff --git" line. Such
lines occur when the user commits with the "-v" option. We should not
check the patch content; it will be stripped by Git anyway.
-rwxr-xr-x | commit-msg | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/commit-msg b/commit-msg index e47ec0ff00..3953b37f22 100755 --- a/commit-msg +++ b/commit-msg @@ -2,9 +2,11 @@ # # Copy or link this file as ".git/hooks/pre-commit". -# Prepare a backup message without comments. +# Prepare a copy of the message: +# - strip comment lines +# - stop at "diff --git" (git commit -v) commit_msg="$GIT_DIR/COMMIT_MSG" -grep -v '^#' "$1" > "$commit_msg" +sed -n -e '/^#/d' -e '/^diff --git/q' -e 'p;d' "$1" > "$commit_msg" die() { echo 'commit-msg hook failure' 1>&2 |