Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / xcvs / dist / contrib / sandbox_status.sh
blob7bc073114dae6be6da82568dc22098e86a19afb8
1 #! /bin/sh
3 # Copyright (C) 1995-2005 The Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # sandbox_status - identify files added, changed, or removed
16 # in CVS working directory
18 # Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
20 # This program should be run in a working directory that has been
21 # checked out using CVS. It identifies files that have been added,
22 # changed, or removed in the working directory, but not "cvs
23 # committed". It also determines whether the files have been "cvs
24 # added" or "cvs removed". For directories, it is only practical to
25 # determine whether they have been added.
27 name=sandbox_status
28 changes=0
30 # If we can't run CVS commands in this directory
31 cvs status . > /dev/null 2>&1
32 if [ $? != 0 ] ; then
34 # Bail out
35 echo "$name: there is no version here; bailing out" 1>&2
36 exit 1
39 # Identify files added to working directory
40 for file in .* * ; do
42 # Skip '.' and '..'
43 if [ $file = '.' -o $file = '..' ] ; then
44 continue
47 # If a regular file
48 if [ -f $file ] ; then
49 if cvs status $file | grep -s '^From:[ ]*New file' ; then
50 echo "file added: $file - not CVS committed"
51 changes=`expr $changes + 1`
52 elif cvs status $file | grep -s '^From:[ ]*no entry for' ; then
53 echo "file added: $file - not CVS added, not CVS committed"
54 changes=`expr $changes + 1`
57 # Else if a directory
58 elif [ -d $file -a $file != CVS.adm ] ; then
60 # Move into it
61 cd $file
63 # If CVS commands don't work inside
64 cvs status . > /dev/null 2>&1
65 if [ $? != 0 ] ; then
66 echo "directory added: $file - not CVS added"
67 changes=`expr $changes + 1`
70 # Move back up
71 cd ..
73 done
75 # Identify changed files
76 changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
77 for file in $changedfiles ; do
78 echo "file changed: $file - not CVS committed"
79 changes=`expr $changes + 1`
80 done
82 # Identify files removed from working directory
83 removedfiles=`cvs status | egrep '^File:[ ]*no file' | awk '{print $4}'`
85 # Determine whether each file has been cvs removed
86 for file in $removedfiles ; do
87 if cvs status $file | grep -s '^From:[ ]*-' ; then
88 echo "file removed: $file - not CVS committed"
89 else
90 echo "file removed: $file - not CVS removed, not CVS committed"
92 changes=`expr $changes + 1`
93 done
95 exit $changes