view cds-diff @ 43:7fc785a79615

renamed penis to churn
author Josef "Jeff" Sipek <jsipek@cs.sunysb.edu>
date Sat, 05 May 2007 15:53:53 -0400
parents 4d05c2bbd525
children
line wrap: on
line source

#!/bin/bash

cvs -n update 2> /dev/null | while read changed
do
	STATE=`echo $changed | awk '{print $1}'`
	FILE=`echo $changed | sed -e 's/. //'`

	count=0
	
	if [ $# -ne 0 ] ; then
		# arguments passed, make sure that we diff only files in the list
		for x in "$@"
		do
			if [ "$x" = "$FILE" ] ; then
				# in the list
				let count=$count+1
			fi
		done
	else
		# no args passed, so just fake the flag of being in the list
		count=1
	fi
				
	if [ $count -ne 1 ] ; then
		# skip this file
		continue
	fi

	if [ "$STATE" = "?" ] ; then
		# file not tracked
		continue
	fi

	if [ "$STATE" = "A" ] ; then
		# new file, CVS doesn't know about it, so we make it look like
		# as if it did
		echo "Index: $FILE"
		echo "==================================================================="
		echo "new file"
		echo diff -u -p /dev/null $FILE
		diff -u -p /dev/null "$FILE"
	else
		if [ "$STATE" = "R" ] ; then
			# removed file, CVS likes to ignore these in diff, so
			# we make it look like as if it did not
			echo "Index: $FILE"
			echo "==================================================================="
			echo "removed file"
			echo diff -u -p $FILE /dev/null
			diff -u -p "$FILE" /dev/null
		else
			if [ "$STATE" = "M" ] ; then
				# let CVS diff this for us
				cvs diff -u -p "$FILE" 2> /dev/null
			fi
		fi
	fi
done