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