]>
git.saurik.com Git - bison.git/blob - etc/clcommit
   3 # clcommit version 0.9.5 
   5 # Copyright (C) 1999, 2000, Free Software Foundation 
   7 # This script is Free Software, and it can be copied, distributed and 
   8 # modified as defined in the GNU General Public License.  A copy of 
   9 # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html 
  11 # Originally by Gary V. Vaughan <gvaughan@oranda.demon.co.uk> 
  12 # Pretty much rewritten by Alexandre Oliva <aoliva@redhat.com> 
  14 # This scripts eases checking in changes to CVS-maintained projects 
  15 # with ChangeLog files.  It will check that there have been no 
  16 # conflicting commits in the CVS repository and print which files it 
  17 # is going to commit to stderr.  A list of files to compare and to 
  18 # check in can be given in the command line.  If it is not given, all 
  19 # files in the current directory (and below, unless `-l' is given) are 
  20 # considered for check in. 
  22 # The commit message will be extracted from the differences between a 
  23 # file named ChangeLog* in the commit list, or named after -C, and the 
  24 # one in the repository (unless a message was specified with `-m' or 
  25 # `-F').  An empty message is not accepted (but a blank line is).  If 
  26 # the message is acceptable, it will be presented for verification 
  27 # (and possible edition) using the $PAGER environment variable (or 
  28 # `more', if it is not set, or `cat', if the `-f' switch is given). 
  29 # If $PAGER exits successfully, the modified files (at that moment) 
  30 # are checked in, unless `-n' was specified, in which case nothing is 
  33 # usage: clcommit [-v] [-h] [-f] [-l] [-n] [-q] [-z N] [-C ChangeLog_file] 
  34 #                 [-m msg|-F msg_file|-1] [--] [file|dir ...] 
  36 # -f      --force       don't check (unless *followed* by -n), and just 
  37 #                       display commit message instead of running $PAGER 
  38 # -l      --local       don't descend into subdirectories 
  39 # -m msg  --message=msg set commit message 
  40 #         --msg=msg     same as -m 
  41 # -F file --file=file   read commit message from file 
  42 # -1      --first       extract first entry from ChangeLog, no cvs diff 
  43 # -C file --changelog=file extract commit message from specified ChangeLog 
  44 #         --fast        same as --force --first 
  45 # -n      --dry-run     don't commit anything 
  46 # -q      --quiet       run cvs in quiet mode 
  47 # -zN     --compress=N  set compression level (0-9, 0=none, 9=max) 
  48 # -v      --version     print version information 
  49 # -h,-?   --help        print short or long help message 
  59 log_file
="${TMPDIR-/tmp}/commitlog.$$" 
  63 trap 'rm -f "$log_file"; exit 1' 1 2 15 
  65 # this just eases exit handling 
  67 while $main_repeat; do 
  69 repeat
="test $# -gt 0" 
  74         set fnord 
--force --first ${1+"$@"} 
  83         updateopt
="$updateopt -l" 
  84         commitopt
="$commitopt -l" 
  89             echo "$name: missing argument for $1" >&2 
  92         if $first || test -f "$log_file"; then 
  93             echo "$name: you can have at most one of -m, -F and -1" >&2 
  97         echo "$1" > "$log_file" 
 101         if $first || test -f "$log_file"; then 
 102             echo "$name: you can have at most one of -m, -F and -1" >&2 
 106             echo "$name: missing argument for $1" >&2 
 110         if cat < "$1" > "$log_file"; then :; else 
 116         if test -f "$log_File"; then 
 117             echo "$name: you can have at most one of -m, -F and -1" >&2 
 123     -C|--[cC
]hange
[lL
]og
) 
 125             echo "$name: missing argument for $1" >&2 
 129         if test ! -f "$1"; then 
 130             echo "$name: ChangeLog file \`$1' does not exist" >&2 
 151             echo "$name: missing argument for $1" >&2 
 156         *)  echo "$name: invalid argument for $1" >&2 
 160         cvsopt
="$cvsopt -z$2" 
 166         opt
=`echo "$1" | sed '1s/^\(..\).*$/\1/;q'` 
 167         arg
=`echo "$1" | sed '1s/^-[a-zA-Z0-9]//'` 
 169         set -- "$opt" "$arg" ${1+"$@"} 
 171     --message=*|--msg=*|--file=*|--[Cc
]hange
[Ll
]og
=*|--compress=*) 
 172         opt
=`echo "$1" | sed '1s/^\(--[^=]*\)=.*/\1/;q'` 
 173         arg
=`echo "$1" | sed '1s/^--[^=]*=//'` 
 175         set -- "$opt" "$arg" ${1+"$@"} 
 179         sed '/^# '$name' version /,/^# Heavily modified by/ { s/^# //; p; }; d' < $0 
 183         sed '/^# usage:/,/# -h/ { s/^# //; p; }; d' < $0 && 
 185         echo "run \`$name --help | more' for full usage" 
 189         sed '/^# '$name' version /,/^[^#]/ { /^[^#]/ d; s/^# //; p; }; d' < $0 
 197         echo "$name: invalid flag $1" >&2 
 205 # might have used break 2 within the previous loop, but so what 
 209 if echo "$name: checking for conflicts..." >&2 
 210    ($CVS $cvsopt -q -n update 
$updateopt ${1+"$@"} 2>/dev
/null \
 
 211     | while read line
; do 
 214       done | grep '^C') 3>&1 >/dev
/null
; then 
 215   echo "$name: some conflicts were found, aborting..." >&2 
 219 if test ! -f "$log_file"; then 
 220   if test -z "$ChangeLog"; then 
 221     for f 
in ${1+"$@"}; do 
 223       ChangeLog
* | */ChangeLog
*) 
 224         if test -z "$ChangeLog"; then 
 227             echo "$name: multiple ChangeLog files: $ChangeLog and $f" >&2 
 235   echo "$name: checking commit message..." >&2 
 238     sed 's,^,+,' < ${ChangeLog-ChangeLog} | 
 241       "+2"*) if $skipping; then skipping
=false
; else break; fi;; 
 243         echo "$name: *** Warning: lines should start with tabs, not spaces; ignoring line:" >&2 
 244         echo "$line" | sed 's/^.//' >&2;; 
 246         $skipping || echo "$line" ;; 
 249     sed 's,^\+  ,,' > "$log_file" || break 
 251     $CVS $cvsopt diff -u ${ChangeLog-ChangeLog} | 
 256         echo "$name: *** Warning: the following line in ChangeLog diff is suspicious:" >&2 
 257         echo "$line" | sed 's/^.//' >&2;; 
 259         echo "$name: *** Warning: lines should start with tabs, not spaces; ignoring line:" >&2 
 260         echo "$line" | sed 's/^.//' >&2;; 
 262       "+        "*) echo "$line";; 
 265     sed -e 's,\+        ,,' -e '/./p' -e '/./d' -e '1d' -e '$d' > "$log_file" \
 
 268 # The sed script above removes "+TAB" from the beginning of a line, then 
 269 # deletes the first and/or the last line, when they happen to be empty 
 272 if grep '[^     ]' < "$log_file" > /dev
/null
; then :; else 
 273   echo "$name: empty commit message, aborting" >&2 
 277 if grep '^$' < "$log_file" > /dev
/null
; then 
 278   echo "$name: *** Warning: blank lines should not appear within commit messages." >&2 
 279   echo "$name: *** They should be used to separate distinct commits." >&2 
 282 ${PAGER-more} "$log_file" || break 
 284 sleep 1 # give the user some time for a ^C 
 286 # Do not check for empty $log_file again, even though the user might have 
 287 # zeroed it out.  If s/he did, it was probably intentional. 
 290   $CVS $cvsopt commit 
$commitopt -F $log_file ${1+"$@"} || break 
 298 # if main_repeat was not set to `false', we failed 
 299 $main_repeat && exit 1