/contrib/cvs/contrib/cvscheck.sh

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 95 lines · 44 code · 14 blank · 37 comment · 12 complexity · 62708758e82ec41b88fdc7178e0cc90c MD5 · raw file

  1. #! /bin/sh
  2. #
  3. # Copyright (C) 1995-2005 The Free Software Foundation, Inc.
  4. #
  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.
  9. #
  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.
  14. #
  15. # cvscheck - identify files added, changed, or removed
  16. # in CVS working directory
  17. #
  18. # Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
  19. #
  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.
  26. name=cvscheck
  27. changes=0
  28. # If we can't run CVS commands in this directory
  29. cvs status . > /dev/null 2>&1
  30. if [ $? != 0 ] ; then
  31. # Bail out
  32. echo "$name: there is no version here; bailing out" 1>&2
  33. exit 1
  34. fi
  35. # Identify files added to working directory
  36. for file in .* * ; do
  37. # Skip '.' and '..'
  38. if [ $file = '.' -o $file = '..' ] ; then
  39. continue
  40. fi
  41. # If a regular file
  42. if [ -f $file ] ; then
  43. if cvs status $file | grep -s '^From:[ ]*New file' ; then
  44. echo "file added: $file - not CVS committed"
  45. changes=`expr $changes + 1`
  46. elif cvs status $file | grep -s '^From:[ ]*no entry for' ; then
  47. echo "file added: $file - not CVS added, not CVS committed"
  48. changes=`expr $changes + 1`
  49. fi
  50. # Else if a directory
  51. elif [ -d $file -a $file != CVS.adm ] ; then
  52. # Move into it
  53. cd $file
  54. # If CVS commands don't work inside
  55. cvs status . > /dev/null 2>&1
  56. if [ $? != 0 ] ; then
  57. echo "directory added: $file - not CVS added"
  58. changes=`expr $changes + 1`
  59. fi
  60. # Move back up
  61. cd ..
  62. fi
  63. done
  64. # Identify changed files
  65. changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
  66. for file in $changedfiles ; do
  67. echo "file changed: $file - not CVS committed"
  68. changes=`expr $changes + 1`
  69. done
  70. # Identify files removed from working directory
  71. removedfiles=`cvs status | egrep '^File:[ ]*no file' | awk '{print $4}'`
  72. # Determine whether each file has been cvs removed
  73. for file in $removedfiles ; do
  74. if cvs status $file | grep -s '^From:[ ]*-' ; then
  75. echo "file removed: $file - not CVS committed"
  76. else
  77. echo "file removed: $file - not CVS removed, not CVS committed"
  78. fi
  79. changes=`expr $changes + 1`
  80. done
  81. exit $changes