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