]> git.ozlabs.org Git - next-scripts/commitdiff
Consolidate error recovery into "execute"
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 4 Jun 2008 01:38:35 +0000 (11:38 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 4 Jun 2008 01:38:35 +0000 (11:38 +1000)
update_trees

index eef12860513d5380eefbadd270e49b3922e37dce..7e5525ce1d684e0e2d32afc395e89c3aed1dd6b9 100755 (executable)
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-set -o pipefail
-
 cp /dev/null ../quilt-import.log
 
 log()
@@ -13,6 +11,11 @@ execute()
 {
        log "$" $@
        "$@" 2>&1 | tee -a ../quilt-import.log
+       [ ${PIPESTATUS[0]} -eq 0 ] || sh -i || {
+               [ -f "$sfile.orig" ] &&
+                       mv -f "$sfile.orig" "$sfile"
+               exit 1
+       }
 }
 
 quilters=$(grep -v '^#' ../real_control | awk -F '     ' '$2=="quilt" { print $3; }')
@@ -54,11 +57,7 @@ for name in $quilters; do
        }
 
        git show-ref --quiet --verify "refs/heads/quilt/$name" ||
-               execute git branch "quilt/$name" "$rbase" || sh -i || {
-                       [ -f "$sfile.orig" ] &&
-                               mv -f "$sfile.orig" "$sfile"
-                       exit 1
-               }
+               execute git branch "quilt/$name" "$rbase"
 
        mv -f "$sfile" "$sfile.tmp"
        sed -e '/^[     ]*$/d' -e '^[   ]*#/d' <"$sfile.tmp" >"$sfile"
@@ -70,23 +69,11 @@ for name in $quilters; do
                continue
        }
 
-       execute git checkout "quilt/$name" || sh -i || {
-               [ -f "$sfile.orig" ] &&
-                       mv -f "$sfile.orig" "$sfile"
-               exit 1
-       }
-       execute git reset --hard "$rbase" || sh -i || {
-               [ -f "$sfile.orig" ] &&
-                       mv -f "$sfile.orig" "$sfile"
-               exit 1
-       }
+       execute git checkout "quilt/$name"
+       execute git reset --hard "$rbase"
 
        author=$(grep -v '^#' ../real_control | awk -F '        ' '$3=="'"$name"'" { printf("%s", $1); }' | sed 's/,.*$//')
-       execute git quiltimport --author "$author" --patches "../quilt/$name" || sh -i || {
-               [ -f "$sfile.orig" ] &&
-                       mv -f "$sfile.orig" "$sfile"
-               exit 1
-       }
+       execute git quiltimport --author "$author" --patches "../quilt/$name"
 
        [ -f "$sfile.orig" ] &&
                mv -f "$sfile.orig" "$sfile"