#!/bin/sh

collation_file=changelogs.txt
logfiles="$(git diff --name-only | grep ChangeLog)"

[ -f $collation_file ] && rm -f $collation_file

for f in $logfiles; do
    git diff -- $f | grep ^+ | cut -b 2- | awk '/^++/ {getline;} /^2/ {getline; getline;} {print;}'
done | tee > $collation_file

echo
echo OK to commit with these logs\?
read

for f in $logfiles; do
    git checkout -- $f
done

git commit -F $collation_file -e "$@"
