From 125a6409775a14b7caa916f820f86ddad05b56af Mon Sep 17 00:00:00 2001 From: David Sterba Date: Sun, 10 Jul 2011 14:27:41 +0000 Subject: [PATCH] Ticket #2573 (patchfs enchancement) 1. do follow: diff -BurpN file1.c file.c > my.patch; diff -BurpN file2.c file.c >> my.patch; 2. we see two file.c.diff entries within patchfs. after apply commit, we have one combined patch-file. Signed-off-by: Ilia Maslakov --- src/vfs/extfs/helpers/patchfs.in | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/vfs/extfs/helpers/patchfs.in b/src/vfs/extfs/helpers/patchfs.in index 908c9f37c..264e8572d 100644 --- a/src/vfs/extfs/helpers/patchfs.in +++ b/src/vfs/extfs/helpers/patchfs.in @@ -125,7 +125,7 @@ sub diff_filename } elsif (!$fdst || $fdst eq '/dev/null') { return ($fsrc,'PATCH-REMOVE/'); } elsif (($fdst eq '/dev/null') && ($fsrc eq '/dev/null')) { - error 'Malformed diff'; + error 'Malformed diff, missing a sane filename'; } else { # fewest path name components if ($fdst=~s|/|/|g < $fsrc=~s|/|/|g) { @@ -171,9 +171,8 @@ sub parse($$$$) my @outsrc; # if desired ... my @outdst; my $line; - - # use uid and gid from file - my ($uid,$gid)=(`ls -l $archive`=~/$ls_extract_id/o); + my %fmap_size=(); + my %fmap_time=(); import Date::Parse if ($parsedates && $file eq ''); @@ -196,11 +195,12 @@ sub parse($$$$) } if($file eq '' && $filetoprint) { - printf $fh "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $fsize, datetime($time), $prefix, $f; + $fmap_size{"$prefix$f"}+=$fsize; + $fmap_time{"$prefix$f"}=$time; } # start of new file - $_ .=; # steel next line, both formats + $_ .=; # steal next line, both formats $line++; if($unified) { if(/$unified_header/o) { @@ -228,7 +228,7 @@ sub parse($$$$) push @outdst,$fdst; } ($f,$prefix)=diff_filename($fsrc,$fdst); - $filefound=($fsrc eq $file || $fdst eq $file); + $filefound=($f eq $file); $f="$f.diff"; $filetoprint=1; @@ -283,7 +283,16 @@ sub parse($$$$) } } if($file eq '' && $filetoprint) { - printf $fh "-rw-r--r-- 1 %s %s %d %s %s%s\n", $uid, $gid, $fsize, datetime($time), $prefix, $f; + $fmap_size{"$prefix$f"}+=$fsize; + $fmap_time{"$prefix$f"}=$time; + } + + # use uid and gid from file + my ($uid,$gid)=(`ls -l $archive`=~/$ls_extract_id/o); + + # flush all file names with cumulative file size + while(my ($fn, $fs) = each %fmap_size) { + printf $fh "-rw-r--r-- 1 %s %s %d %s %s\n", $uid, $gid, $fs, datetime($fmap_time{$fn}), $fn; } close($fh) if($file ne '');