Got rid of the option to regenerate the proto.h file.
[rsync/rsync-patches.git] / verify-patches
1 #!/bin/sh
2
3 [ -d patches ] && cd patches
4
5 if [ ! -f verify-patches ]; then
6     echo "Please run this script from the root of the rsync dir"
7     echo "or from inside the patches subdir."
8     exit 1
9 fi
10
11 root=`cat ../CVS/Root`
12 tmpdir=,tmp-for-patch-tests
13
14 [ -d $tmpdir ] || mkdir $tmpdir
15 cd $tmpdir || exit 1
16
17 [ -d workdir ] || mkdir workdir
18 echo "Using CVS to update the $tmpdir/cvsdir copy of the source."
19 cvs -d "$root" co -d cvsdir rsync
20
21 cd workdir || exit 1
22
23 if [ -z "$1" ]; then
24     set -- ../../*.diff
25 fi
26
27 for xx in "${@}"; do
28     case "$xx" in
29     *gzip-rsyncable.diff) continue ;;
30     patches/*) xx=`echo $xx | sed 's:patches:../..:'` ;;
31     */*.diff) ;;
32     *.diff) xx=../../$xx ;;
33     *) continue ;;
34     esac
35     apply=y
36     while : ; do
37         echo -e "\n----------- $xx ------------"
38         if [ $apply = y ]; then
39             rsync -a --delete ../cvsdir/ .
40             patch -p0 <$xx | tee ,patch.output
41             new=''
42             for nn in `sed -n 's/^patching file //p' ,patch.output`; do
43                 [ -f ../cvsdir/$nn ] || new="$new $nn"
44             done
45             if grep "^Hunk #[0-9]* FAILED" ,patch.output >/dev/null; then
46                 default=F
47             elif grep "^Hunk #[0-9]* succeeded" ,patch.output >/dev/null; then
48                 default=E
49             else
50                 default=N
51             fi
52             apply=n
53         fi
54         echo -e "\nFix rejects, Edit both diffs, Update patch,"
55         echo -n "Apply patch again, Next, Quit: [$default] "
56         read ans
57         [ -z "$ans" ] && ans=$default
58         case "$ans" in
59         [Ee]*)
60             [ ! -z "$new" ] && cvs add $new
61             new=''
62             rm -f *.rej *.orig
63             sed '/^--- /,$ d' $xx >,new.patch
64             cvs diff -N | egrep -v '^(diff -|===============|RCS file: |retrieving revision |Index: )' >>,new.patch
65             vim -d $xx ,new.patch
66             default=U
67             ;;
68         [Ff]*)
69             vim *.rej
70             default=E
71             ;;
72         [Uu]*)
73             if [ -f ,new.patch ]; then
74                 cp -p ,new.patch $xx
75                 echo -e "\nCopied ,new.patch to $xx"
76                 default=A
77             else
78                 echo -e "\n*** Edit the diffs first. ***"
79                 default=E
80             fi
81             ;;
82         [Aa]*)
83             apply=y
84             ;;
85         [Nn]*)
86             break
87             ;;
88         [Qq]*)
89             exit 0
90             ;;
91         esac
92     done
93 done