#!/bin/sh
# To be called from loginfo as
# ^dirname	/home/CVSROOT/CVSROOT/tag-logger.sh logdir

if [ ! -d CVS ]; then
  exit
fi
logdir=$1
if [ -z "$logdir" ]; then
  logdir=`cat CVS/Root`/`cat CVS/Repository|cut -d/ -f1`
else
  shift
fi
set -- `echo $*`
if [ -f CVS/Tag ]; then
  tag=`cat CVS/Tag | cut -c2-`
else
  tag="HEAD"
fi
basetag=`echo $tag | sed -e 's%-local.*%%'`

logfile=$logdir/$tag.changelog
(
#echo `date` $basetag
date
read j1 j2 dir
dir=`echo $dir | sed -e 's%/home/CVSROOT/%%'`
read l2
read l3
read l4
echo $l4 in $dir | sed -e 's%:%%'
cat | grep -v "^ *Tag: $basetag" | sed -e 's/^Log Message:$//' | uniq
if [ -f $logfile ]; then
    if head -1 $logfile | grep '^===========' >/dev/null; then
	:
    else
	echo "-----------------------------------------------------------------"
    fi
    echo
    cat $logfile
fi
) >>$logfile.$$
mv -f $logfile.$$ $logfile

