The GCC checkin policy requires a ChangeLog entry for each change, and that entry is usually also used as the commit message. I used to use a fairly crappy, homemade vim plugin to extract the first entry from a ChangeLog file into the editor buffer to use as the svn commit message. I decided to replace that vim plugin with a Git prepate-commit-msg hook that automatically prepares the commit message for me by extracting the first entry from each ChangeLog that is part of the commit.
As a cursory web search didn't find anything similar, I'm posting it here in case it's useful to anyone else.
$ cat .git/hooks/prepare-commit-msg
#!/bin/bash
#
# Hook script to prepare the commit log message from the first
# entry in each modified ChangeLog being committed.
set -e
[[ "$2,$3" == 'merge,' ]] && exit
tmpf=$(mktemp)
awk -f $0.awk $(git status -s | awk '/^M .*ChangeLog/{print $NF}') > $tmpf
sed 1d $1 >> $tmpf
mv $tmpf $1
$ cat .git/hooks/prepare-commit-msg.awk
# When there is more than one ChangeLog in the commit, precede
# the entry by the directory name.
FNR == 1 && ARGC > 2 {
printf "%s:\n\n", gensub("/ChangeLog$", "", "", FILENAME)
}
# Save the first line until we know if we want to print it.
FNR == 1 {
line1=$0
}
# If second line is blank there is only one patch author, omit it.
FNR == 2 && /^$/ {
}
# If second line is not blank there are multiple authors, print them.
FNR == 2 && /^./ {
print line1
}
# Stop processing the file at the next entry.
FNR > 3 && /^20[1-9][0-9]-[0-1][1-9]-[0-3][0-9] / {
nextfile
}
# Otherwise, just print the line.
FNR > 2 {
}