Diff: creating patch for directory which adds new files

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Diff: creating patch for directory which adds new files

Post by ^rooker »

[PROBLEM]
I've improved an existing Free Software application and wanted to save my changes in a default .patch format.
No big deal, but unfortunately, I did not only edit previously existing files, but also added new ones.

So, calling diff with "-c" (context) and "-r" recursive, only created patch information for files that exist in both versions:

Code: Select all

diff -cr original_version_folder/ my_modified_version_folder/ > tool-1.0.0_to_1.0.1.patch
[SOLUTION]
If you add the "-N" option to "diff", it will treat non-existent files as empty. That's exactly what we want:

Code: Select all

diff -Ncr original_version_folder/ my_modified_version_folder/ > tool-1.0.0_to_1.0.1.patch
Just add the "N" as diff option - the rest of the command stays the same :)
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply