How to Convert Git Log to ChangeLog
This is quite a useless endeavor, of course. Since every fork from Git contains the whole change history, GNU-style ChangeLogs are pretty obsolete. However, if you want to distribute your source files in a traditional tarball, you might want to add a ChangeLog file – and you might want it to look like the ones in the GNU coding standard. This is where my shell script comes in, which I wrote yesterday while doing some serious procrastination:
#!/bin/sh
# Convert git log to GNU-style ChangeLog file.
# (C) Chris
if test -d ".git"; then
git log --date-order --date=short | \
sed -e '/^commit.*$/d' | \
awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
sed -e 's/^Author: //g' | \
sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > ChangeLog
exit 0
else
echo "No git repository present."
exit 1
fi
This code goes conveniently in a Makefile template for Autotools, so you can create the ChangeLog on the fly, include it in the distribution tarball and have it unlinked afterwards. Again, there’s no need to have a ChangeLog lie around with Git.
Hi. Very nice script but there is two small differences between ChagneLog generated by your script and what is at the GNU coding standard:
1 – Date comes before the author data.
2 – Between date and author data there are two spaces and not a tab.
I changed your script a little so it correct these to minor differences:
sed -e ‘s/\(.*\)>Date: \([0-9]*-[0-9]*-[0-9]*\)/\2 \1>/g’ | \
Hi,
I ended up using this to generate GNU ChangeLog files[1]:
git –no-pager log –format=”%ai %aN %n%n%x09* %s%d%n” > ChangeLog
Regards,
Antonio
[1] http://www.gnu.org/s/libtool/manual/emacs/Format-of-ChangeLog.html