I wrote a script
#!/bin/bash
commit_msg=$1
echo "Your commit message: $commit_msg"
in hooks/commit-msg
which validates the commit message in
git commit -m "fixed a bug"
But when I run the hook, I have:
Your commit message: .git/COMMIT_EDITMSG
instead of
Your commit message: fixed a bug
How can I capture the commit message into a variable?
I've read How to capture a git commit message and run an action
but it didn't help me because that hook was for post-receive
and I need it for commit-msg
so I don't have my commit message in
git log -1 HEAD --pretty=format:%s
because my hook blocks from doing a commit.