extfs/patchfs.in



Hi,

this patch allows to copyout and list patches for files with leading "./" or "../".

See foobar.patch for an example.

Roland
Index: patchfs.in
===================================================================
RCS file: /cvsroot/mc/mc/vfs/extfs/patchfs.in,v
retrieving revision 1.16
diff -u -r1.16 patchfs.in
--- patchfs.in	19 Aug 2004 15:43:09 -0000	1.16
+++ patchfs.in	1 Nov 2004 08:18:25 -0000
@@ -31,6 +31,12 @@
 my $ls_extract_id=qr/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/;
 my $basename=qr|^(.*/)*([^/]+)$|;
 
+sub patchfs_canonicalize_path ($) {
+  my ($fname) = @_;
+  $fname =~ s,/+,/,g;
+  $fname =~ s,(^|/)(?:\.?\./)+,$1,;
+  return $fname;
+}
 
 # output unix date in a mc-readable format
 sub timef
@@ -92,8 +98,9 @@
 # select diff filename conforming with rules found in diff.info
 sub diff_filename
 {
-    my ($fsrc,$fdst)= _;
-
+    my ($fsrc,$fdst)= @_;
+    $fsrc = patchfs_canonicalize_path ($fsrc);
+    $fdst = patchfs_canonicalize_path ($fdst);
     if (!$fdst && !$fsrc) {
 	error 'Index: not yet implemented';
     } elsif (!$fsrc || $fsrc eq '/dev/null') {
@@ -203,6 +210,7 @@
     my ($unified,$context)=(0,0);
 
     $file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/;
+    $file = patchfs_canonicalize_path ($file);
     
     # state==1 means diff contents, state==0 mens comments
     $state=0; $found=0; $buf='';
@@ -223,6 +231,8 @@
 	    $state=1;
 
 	    ($fsrc,$fdst,)=parse_header($unified,$context,\$_);
+	    $fsrc = patchfs_canonicalize_path ($fsrc);
+	    $fdst = patchfs_canonicalize_path ($fdst);
 	    $found=1 if (($fsrc eq $file) || ($fdst eq $file));
 
 	} elsif ($state==1 && (($unified && !/$unified_contents/) || ($context && !/$context_contents/))) {
--- ../foo	2004-11-01 09:01:28.000000000 +0100
+++ ../bar	2004-11-01 09:01:34.000000000 +0100
@@ -1 +1 @@
-foo
+bar


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