Binary Static

How to Convert Git Log to ChangeLog

Posted in Coding, Linux by Chris on February 18, 2010

Git Logo

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:

# 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
    echo "No git repository present."
    exit 1

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.

Tagged with: , , , ,