Return to Snippet

Revision: 2154
at January 5, 2007 03:57 by basicmagic


Updated Code
Although diff can output in diverse formats, the easiest to read is the unified format; simply use the -u switch to generate unified output.

diff -u old.php new.php > file.patch

Note: the symbol > will redirect the output to the file file.patch
Because patch readability is important for the review process it's best to add another switch: -p. This switch shows the function closest to the difference, making it easy to see what function changed. (alternately you can use the flag -F^function or in abbreviated form -F^f)

diff -up old.php new.php > file.patch

When you've modified multiple files in the source tree, use diffs ability to compare directories. Add the -r switch to instruct diff to recurse (sub)directories and add the -N switch to account for new or deleted files:

diff -urNp old_directory new_directory > file.patch

Revision: 2153
at January 5, 2007 03:56 by basicmagic


Initial Code
Although diff can output in diverse formats, the easiest to read is the unified format; simply use the -u switch to generate unified output.

diff -u old.php new.php > file.patch

Note: the symbol > will redirect the output to the file file.patch
Because patch readability is important for the review process it's best to add another switch: -p. This switch shows the function closest to the difference, making it easy to see what function changed. (alternately you can use the flag -F^function or in abbreviated form -F^f)

diff -up old.php new.php > file.patch
When you've modified multiple files in the source tree, use diffs ability to compare directories. Add the -r switch to instruct diff to recurse (sub)directories and add the -N switch to account for new or deleted files:

diff -urNp old_directory new_directory > file.patch

Initial URL
http://drupal.org/diffandpatch

Initial Description


Initial Title
How to create patches using diff

Initial Tags
Bash, drupal

Initial Language
Bash