$ mkdir ~/.git-hooks
Place commit-msg
and pre-commit
hooks into that dir and make them executable:
$ chmod +x ~/.git-hooks/commit-msg
$ chmod +x ~/.git-hooks/pre-commit
Make git
use the hooks:
$ git config --global core.hooksPath ~/.git-hooks
After that, you will not be able to commit any files that contain QQQQQ:
substring unless you also include wip
word (any case) in the first line of your commit message.
So, if you have written comments and debug print like this
// QQQQQ: remove this!!!
...
printf("QQQQQ: foo=%s\n", foo);
and forgot about them, an attempt to git commit
your changes will remind you unless you're making a wip
commit.
NOTE: ${firstline,,}
downcase construct doesn't work with bash
3.2, so on Mac, you need to have newer bash
installed somewhere in your path. That's what #!/usr/bin/env bash
instead of #/bin/bash
is for.
If you need this to work with bash
3.2, use $(echo firstline | tr A-Z a-z)
or firstline=$(head -n1 "$1"| tr A-Z a-z)
instead.