OSSP CVS Repository

ossp - Check-in [5263]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 5263
Date: 2005-Oct-07 12:59:27 (local)
2005-Oct-07 10:59:27 (UTC)
User:rse
Branch:
Comment: Fix diff(3) option fiddling introduced in version 1.0.4
Tickets:
Inspections:
Files:
ossp-pkg/svs/ChangeLog      1.8 -> 1.9     5 inserted, 0 deleted
ossp-pkg/svs/svs.sh      1.9 -> 1.10     17 inserted, 13 deleted

ossp-pkg/svs/ChangeLog 1.8 -> 1.9

--- ChangeLog    2005/10/03 10:33:48     1.8
+++ ChangeLog    2005/10/07 10:59:27     1.9
@@ -8,6 +8,11 @@
 
   ChangeLog
 
+  Changes between 1.0.4 and 1.0.5 (29-Sep-2005 to 07-Oct-2005):
+
+    *) Fix diff(3) option fiddling introduced in version 1.0.4
+       [Ralf S. Engelschall]
+
   Changes between 1.0.3 and 1.0.4 (18-Aug-2005 to 29-Sep-2005):
 
     *) Try diff(3) with options -U3, -u, -C3 and none (in this order)


ossp-pkg/svs/svs.sh 1.9 -> 1.10

--- svs.sh       2005/10/03 10:33:48     1.9
+++ svs.sh       2005/10/07 10:59:27     1.10
@@ -37,6 +37,20 @@
     exit 1
 fi
 
+#   helper function for portable creating a file difference
+do_diff () {
+    diff -U3 $1 $2 2>/dev/null
+    if [ $? -gt 1 ]; then
+        diff -u $1 $2 2>/dev/null
+        if [ $? -gt 1 ]; then
+            diff -C3 $1 $2 2>/dev/null
+            if [ $? -gt 1 ]; then
+                diff $1 $2
+            fi
+        fi
+    fi
+}
+
 #   dispatch into commands
 cmd="$1"
 shift
@@ -117,28 +131,18 @@
             if [ ! -f $edit ]; then
                 #   special case: removed file
                 echo "Index: $edit"
-                ( diff -U3 $orig /dev/null 2>/dev/null ||\
-                  diff -u  $orig /dev/null 2>/dev/null ||\
-                  diff -C3 $orig /dev/null 2>/dev/null ||\
-                  diff     $orig /dev/null
-                ) | sed -e "1s/^--- $orig/--- $edit/"
+                do_diff $orig /dev/null | sed -e "1s/^--- $orig/--- $edit/"
             elif [ ! -r $orig ] && [ ! -s $orig ]; then
                 #   special case: new file
                 echo "Index: $edit"
-                diff -U3 /dev/null $edit 2>/dev/null ||\
-                diff -u  /dev/null $edit 2>/dev/null ||\
-                diff -C3 /dev/null $edit 2>/dev/null ||\
-                diff     /dev/null $edit
+                do_diff /dev/null $edit
             else
                 #   regular case: edited file
                 if cmp $orig $edit >/dev/null 2>&1; then
                     :
                 else
                     echo "Index: $edit"
-                    diff -U3 $orig $edit 2>/dev/null ||\
-                    diff -u  $orig $edit 2>/dev/null ||\
-                    diff -C3 $orig $edit 2>/dev/null ||\
-                    diff     $orig $edit
+                    do_diff $orig $edit
                 fi
             fi
         done

CVSTrac 2.0.1