[PATCH] new patchfs



On Fri, 25 Oct 2002, Pavel Roskin wrote:

> > On Fri, 25 Oct 2002, Padraig Brady wrote:
> >
> > Personally I think the attached is much better than the origonal
> > (details in comments at top)
>
> Please send a patch against the CVS version, which can be found here:
> http://cvs.gnome.org/lxr/source/mc/vfs/extfs/patchfs?raw=1

Not responding? Instead I did:
cvs -d :pserver:anonymous anoncvs gnome org:/cvs/gnome co mc/vfs/extfs/patchfs

> It seems from your comment that you took the version from 4.5.51 as
> the base.  Version 4.5.51 is years old.  Replacing files is very
> unsafe - it's easy to remove recent changes.

I checked that the replacement was OK. Anyway the patch is attached.

thanks,
Pádraig.
--- patchfs	Sun Mar  4 18:55:17 2001
+++ /usr/lib/mc/extfs/patchfs	Sat Oct 26 14:52:46 2002
@@ -1,7 +1,18 @@
 #! /bin/sh
 
-# Peter Daum <gator cs tu-berlin de> (Jan 1998, mc-4.1.22)
-
+# Peter Daum    <gator cs tu-berlin de> (Jan 1998, mc-4.1.22)
+#
+#    Initial implementation.
+#
+# Padraig Brady <padraig linux ie>      (May 2002)
+#
+#    Added support for unified diffs of files and not just directories,
+#    i.e. when there is no "diff date file1 file2" line. Note patchfs
+#    does not fully support context or "default" format diffs at present,
+#    and will only display a SUMMARY of these type if diffstat is present.
+#    I cleaned things up a lot and added support for viewing the SUMMARY
+#    (previously called FILELIST) using diffstat if present.
+#
 # override any locale for dates. But LANG override LC_TIME (at least in glibc)
 # unset LC_ALL
 # LC_TIME=C
@@ -9,15 +20,6 @@
 LC_ALL=C
 export LC_ALL
 
-# paths to used programs:
-ncat=cat                  # regular cat
-zcat=zcat                 # gunzip to stdout
-bzcat="bzip2 -dc"         # bunzip2 to stdout
-file=file                 # "file" command
-sed=sed
-
-filelist=FILELIST         # names for "special" files
-
 patchfs_list ()
 {
     date=`date +"%b %d %H:%M"`
@@ -27,32 +29,29 @@
     size=00000000
     nlink="  1"
 
-    echo "$perm $nlink $uid $gid $size $date $filelist"
+    echo "$perm $nlink $uid $gid $size $date SUMMARY"
     $cat $1 | 
-    $sed -n "/^diff /{
-	s|^.* \([^ ]*\)$|$perm $nlink $uid $gid $size $date \1|gp
-    }"
+    sed -n "s/^+++ \([^ 	]*\).*/$perm $nlink $uid $gid $size $date \1/gp"
 }
 
 patchfs_copyout ()
 {
-    if [ "$2" = "$filelist" ]; then  # list of all affected files
-	$cat $1 | 
-	$sed -n "/^diff /{
-	    s|^.* \([^ ]*\)$|\1|gp
-	}" > $3
+    if [ "$2" = SUMMARY ]; then  # list of all affected files
+	if diffstat -V >/dev/null 2>&1; then
+            $cat $1 | diffstat 2>/dev/null > $3
+        else
+            sed -n "s/^+++ \([^ 	]*\).*/\1/gp" > $3
+        fi
 	exit 0
-     fi
+    fi
     
-    fn=`echo $2|$sed 's|/|\\\/|g'`   # escape '/' in filename
-    $cat $1 | 
-    $sed -n "/^diff .*$fn/,/^diff /{
-	/^diff ./{
-	    /$fn/p
-	    d
-	}
-	p
-    }" > $3
+    fn=`echo $2 | sed 's|/|\\\/|g'`   # escape '/' in filename
+    $cat $1 |
+    sed -e '/^diff /d' |
+    sed -ne "/^+++ .*$fn/,/^--- /{
+                  /^--- /d
+                  p
+              }" > $3
 }
 
 patchfs_run ()
@@ -60,11 +59,11 @@
     exit 0
 }
 
-type=`$file $2`
+type=`file $2`
 case $type in
-    *bzip*) cat=$bzcat ;;
-    *gzip*) cat=$zcat ;;
-    *text*) cat=$ncat ;;
+    *bzip*) cat="bzip2 -dc" ;;
+    *gzip*) cat="gzip -dc" ;;
+    *text*) cat="cat" ;;
     *) exit 1
 esac
 
@@ -76,5 +75,3 @@
 esac
 
 exit 1
-
-


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]