#!/bin/bash
#
# Update the reference test data to match what is actually produced
# This should only be executed after manually verifying that the
# differences are indeed intentional.
#
# Diomidis Spinellis. August 2008.
#
#

# Remove elements that do not affect the structure of a file
remove_trivia()
{
	grep -v 'Generated by' "$@"
}

for i in dot umldoc
do
	git ls-files testdata/*-ref |
	sed "s/\(testdata\/$i-\)ref\(.*\)/\1ref\2 \1out\2/" |
	while read refname outname
	do
		if [ -r "$outname" -a -r "$outname" ] && \
		  ! diff <(remove_trivia $refname) <(remove_trivia $outname) >/dev/null
		then
			cp $outname $refname
		fi
	done
done
