First, I tried asking the same on askubuntu and I’m not getting far there…
https://askubuntu.com/questions/186114/how-to-diff-two-folders-to-multiple-patch-files/186121#comment231985_186121
So, i’ll copy/paste here in hopes SO gives me a working solution…
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 185mb 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?
UPDATE:
I know there are 231 altered files between these folders and 4546 newly added files… I’m just interested in generating those 231 patches. I even have a file containing those 231 filenames so that can be used in a script as well.
I used this to generate the changelog
diff -qdr -x *.o -x *.cmd -x *.d original_308 my_308 | sed "s/^.* and \(.*\) differ/\1/" | sort > changes.txt
and that just prints the filenames that changed, trailed by “only in my_308” files… the 231 files are on the top of that file (the first 231 lines)
So let’s make it clear – I want .patch files for source files. If the patches can end up in patches//file_name.c.patch that would be really great…
If you give me PERL scripts please tell me how to best use them since I do not understand that garbage. Please don’t fail me SO. I need to get this thing ported, tested and running and I’m wasting time on unix commands and untangible scripts ffs.
Thanks to everyone for their contributions… Here’s the end result
The script first generates a list of changed files and files unique only to the new project/folder; then it generates a patch file for every file and copies the newly added files to the ADDONS folder (unique to the new project)