Posted By

basicmagic on 01/05/07


Tagged

Bash diff drupal


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

micmath
koncept
kellyharding
jayallen
shrop
esritter
annalog
wnasich
jeremydouglass
ringo380


How to create patches using diff


 / Published in: Bash
 

URL: http://drupal.org/diffandpatch

  1. Although diff can output in diverse formats, the easiest to read is the unified format; simply use the -u switch to generate unified output.
  2.  
  3. diff -u old.php new.php > file.patch
  4.  
  5. Note: the symbol > will redirect the output to the file file.patch
  6. 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)
  7.  
  8. diff -up old.php new.php > file.patch
  9.  
  10. 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:
  11.  
  12. diff -urNp old_directory new_directory > file.patch

Report this snippet  

You need to login to post a comment.