1*1e72d8d2Sderaadt#! /bin/sh 2*1e72d8d2Sderaadt# 3*1e72d8d2Sderaadt# cvscheck - identify files added, changed, or removed 4*1e72d8d2Sderaadt# in CVS working directory 5*1e72d8d2Sderaadt# 6*1e72d8d2Sderaadt# Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net> 7*1e72d8d2Sderaadt# 8*1e72d8d2Sderaadt# This program should be run in a working directory that has been 9*1e72d8d2Sderaadt# checked out using CVS. It identifies files that have been added, 10*1e72d8d2Sderaadt# changed, or removed in the working directory, but not "cvs 11*1e72d8d2Sderaadt# committed". It also determines whether the files have been "cvs 12*1e72d8d2Sderaadt# added" or "cvs removed". For directories, it is only practical to 13*1e72d8d2Sderaadt# determine whether they have been added. 14*1e72d8d2Sderaadt 15*1e72d8d2Sderaadtname=cvscheck 16*1e72d8d2Sderaadtchanges=0 17*1e72d8d2Sderaadt 18*1e72d8d2Sderaadt# If we can't run CVS commands in this directory 19*1e72d8d2Sderaadtcvs status . > /dev/null 2>&1 20*1e72d8d2Sderaadtif [ $? != 0 ] ; then 21*1e72d8d2Sderaadt 22*1e72d8d2Sderaadt # Bail out 23*1e72d8d2Sderaadt echo "$name: there is no version here; bailing out" 1>&2 24*1e72d8d2Sderaadt exit 1 25*1e72d8d2Sderaadtfi 26*1e72d8d2Sderaadt 27*1e72d8d2Sderaadt# Identify files added to working directory 28*1e72d8d2Sderaadtfor file in .* * ; do 29*1e72d8d2Sderaadt 30*1e72d8d2Sderaadt # Skip '.' and '..' 31*1e72d8d2Sderaadt if [ $file = '.' -o $file = '..' ] ; then 32*1e72d8d2Sderaadt continue 33*1e72d8d2Sderaadt fi 34*1e72d8d2Sderaadt 35*1e72d8d2Sderaadt # If a regular file 36*1e72d8d2Sderaadt if [ -f $file ] ; then 37*1e72d8d2Sderaadt if cvs status $file | grep -s '^From:[ ]*New file' ; then 38*1e72d8d2Sderaadt echo "file added: $file - not CVS committed" 39*1e72d8d2Sderaadt changes=`expr $changes + 1` 40*1e72d8d2Sderaadt elif cvs status $file | grep -s '^From:[ ]*no entry for' ; then 41*1e72d8d2Sderaadt echo "file added: $file - not CVS added, not CVS committed" 42*1e72d8d2Sderaadt changes=`expr $changes + 1` 43*1e72d8d2Sderaadt fi 44*1e72d8d2Sderaadt 45*1e72d8d2Sderaadt # Else if a directory 46*1e72d8d2Sderaadt elif [ -d $file -a $file != CVS.adm ] ; then 47*1e72d8d2Sderaadt 48*1e72d8d2Sderaadt # Move into it 49*1e72d8d2Sderaadt cd $file 50*1e72d8d2Sderaadt 51*1e72d8d2Sderaadt # If CVS commands don't work inside 52*1e72d8d2Sderaadt cvs status . > /dev/null 2>&1 53*1e72d8d2Sderaadt if [ $? != 0 ] ; then 54*1e72d8d2Sderaadt echo "directory added: $file - not CVS added" 55*1e72d8d2Sderaadt changes=`expr $changes + 1` 56*1e72d8d2Sderaadt fi 57*1e72d8d2Sderaadt 58*1e72d8d2Sderaadt # Move back up 59*1e72d8d2Sderaadt cd .. 60*1e72d8d2Sderaadt fi 61*1e72d8d2Sderaadtdone 62*1e72d8d2Sderaadt 63*1e72d8d2Sderaadt# Identify changed files 64*1e72d8d2Sderaadtchangedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'` 65*1e72d8d2Sderaadtfor file in $changedfiles ; do 66*1e72d8d2Sderaadt echo "file changed: $file - not CVS committed" 67*1e72d8d2Sderaadt changes=`expr $changes + 1` 68*1e72d8d2Sderaadtdone 69*1e72d8d2Sderaadt 70*1e72d8d2Sderaadt# Identify files removed from working directory 71*1e72d8d2Sderaadtremovedfiles=`cvs status | egrep '^File:[ ]*no file' | awk '{print $4}'` 72*1e72d8d2Sderaadt 73*1e72d8d2Sderaadt# Determine whether each file has been cvs removed 74*1e72d8d2Sderaadtfor file in $removedfiles ; do 75*1e72d8d2Sderaadt if cvs status $file | grep -s '^From:[ ]*-' ; then 76*1e72d8d2Sderaadt echo "file removed: $file - not CVS committed" 77*1e72d8d2Sderaadt else 78*1e72d8d2Sderaadt echo "file removed: $file - not CVS removed, not CVS committed" 79*1e72d8d2Sderaadt fi 80*1e72d8d2Sderaadt changes=`expr $changes + 1` 81*1e72d8d2Sderaadtdone 82*1e72d8d2Sderaadt 83*1e72d8d2Sderaadtexit $changes 84