Monday, April 29, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 4935  / 3 Years ago, thu, september 30, 2021, 5:26:09

I'm not much of a unix guy so I'll just go ahead and ask:



I have a following problem - two folders with plenty of subfolders. I need to diff them.



I tried this:



diff -drupN vanila_kernel_3.0.8 my_kernel_3.0.8 > kernel.patch


and that results in a 85mb file... and not really what I want.



I want the result of the diff to be many smaller patches, ideally one for every changed file with the contents of the change. That means I have t ochange the way I use diff, and I need to put it in some sort of a loop... So i tried running this little script



for file in original_308/*.*; do
diff -dupN "$file" "my_308/${file##*/}" > "$file".patch
done


But it doesn't work :/



Ideally, I want to have a .patch file for every change, but having patches for files that changed in original would do just fine (as I could filter the newly added files and just copy them over)



Can someone provide me with a decent way to do this please?



EDIT:



Here's something choroba asked me to post



diff -Naur -x '*.o' -x '*.cmd' -x '*.d' original_308/arch/arm/boot/compressed/head.S my_308/arch/arm/boot/compressed/head.S
--- original_308/arch/arm/boot/compressed/head.S 2011-10-25 07:11:12.000000000 +0200
+++ my_308/arch/arm/boot/compressed/head.S 2012-07-04 03:57:25.000000000 +0200
@@ -656,6 +656,8 @@
@ b __arm6_mmu_cache_off
@ b __armv3_mmu_cache_flush


So yes, it is the proper output even though gedit/geany cannot open it. UltraEdit does...


More From » command-line

 Answers
3

You can use the original format that creates the huge diff file which you can subsequently split into the small files. You might be interested in csplit for the splitting, or you can use a scripting language like Perl:



perl -ne 'if(/^diff -drupN (.*) (.*)/) {
my $f = $1;
$f =~ s{/}{_}g;
open $FH, ">", "$f.patch" or die $!;
} else {
print {$FH} $_;
}' kernel.patch


If you need the diff line in each file, add the print after the open.


[#35643] Friday, October 1, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breadoules

Total Points: 212
Total Questions: 118
Total Answers: 120

Location: Dominica
Member since Mon, Jun 22, 2020
4 Years ago
;