How to create patches using diff


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  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

URL: http://drupal.org/diffandpatch

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.