[svlug] convert normal diff to unified diff or use normal diff in patch

Roland Krause rokrau at yahoo.com
Wed Apr 25 21:26:55 PDT 2007


All,
I am trying to apply a diff taken with the command 

diff -r old_directory new_directory > directory_diff

to a copy of old_directory. Unfortunately the filenames in the "normal"
diff format seem not to be recognized by patch. I have tried the
options -p N (with N ranging from 1 to 3) inside the target directory
but stripping seems to have no effect whatsoever. I've tried "god knows
how many" other options to no avail. It seems that patch does not
recognize the file names in the diff file since this is normal diff
format not unified. I tried telling patch that this was a -n - doesn't
change a damn' thing.

I can type the name of the file to be patched and the patch will go
through but there are many hundred files patched in this diff file...

I can extract a list of filenames from the patch but that doesn't help
me since I can't get patch to ignore borked diffs. Otherwise - and I
have tried - I just apply the diff for each file in the list and over
and over again. But that only seems to work for the first file. 

So I am either going to write a program that reads the diff, splits it
into however many files are to be patched - one diff per file and then
I apply the whole thing or someone here will need to save my poor soul
from this and tell me how to convert this file.

Alternatively can I split the file automatically into many smaller
files at the every line which begins with the word diff? Like with
three lines of perl that I should know but don't...

Hope this makes sense. And yes, next time it will be diff -ur

Regards and thanks
Roland 








More information about the svlug mailing list