Set a better default command based on what just happened.
authorWayne Davison <wayned@samba.org>
Sat, 24 Apr 2004 07:57:19 +0000 (07:57 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 24 Apr 2004 07:57:19 +0000 (07:57 +0000)
verify-patches

index e620619..849034c 100755 (executable)
@@ -42,11 +42,19 @@ for xx in "${@}"; do
            for nn in `sed -n 's/^patching file //p' ,patch.output`; do
                [ -f ../,cvsdir/$nn ] || new="$new $nn"
            done
+           if grep "^Hunk #[0-9]* FAILED" ,patch.output >/dev/null; then
+               default=F
+           elif grep "^Hunk #[0-9]* succeeded at [0-9]* (offset" ,patch.output >/dev/null; then
+               default=E
+           else
+               default=N
+           fi
            apply=n
        fi
        echo -e "\nFix rejects, Make proto, Edit both diffs, Update patch,"
-       echo -n "Apply patch again, Next, Quit: [n] "
+       echo -n "Apply patch again, Next, Quit: [$default] "
        read ans
+       [ -z "$ans" ] && ans=$default
        case "$ans" in
        [Ee]*)
            [ ! -z "$new" ] && cvs add $new
@@ -59,26 +67,31 @@ for xx in "${@}"; do
                grep -v '^RCS file: ' |
                grep -v '^retrieving revision ' >>,new.patch
            vim -d $xx ,new.patch
+           default=U
            ;;
        [Ff]*)
            vim *.rej
+           default=E
            ;;
        [Mm]*)
            cat *.c lib/compat.c | awk -f mkproto.awk >proto.h
            echo -e "\nRegenerated proto.h"
+           default=E
            ;;
        [Uu]*)
            if [ -f ,new.patch ]; then
                cp -p ,new.patch $xx
                echo -e "\nCopied ,new.patch to $xx"
+               default=A
            else
                echo -e "\n*** Edit the diffs first. ***"
+               default=E
            fi
            ;;
        [Aa]*)
            apply=y
            ;;
-       [Nn]*|'')
+       [Nn]*)
            break
            ;;
        [Qq]*)