koha-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-devel] Diff and patch


From: MJ Ray
Subject: [Koha-devel] Diff and patch
Date: Sat, 17 Mar 2007 02:00:23 +0000
User-agent: Heirloom mailx 12.2 01/07/07

I can't find the guide that I mentioned on IRC, but those looking
for tips on better use of diff and patch may find them in this book
"Comparing and Merging Files with GNU diff and patch"
by David MacKenzie, Paul Eggert, and Richard Stallman
http://www.network-theory.co.uk/docs/diff/Overview.html

My most frequent commands are:
  1. # generating a patch of changes to one file
     cp file file.orig
     edit file
     diff -u file.orig file | tee file.patch
  2. # generating a patch of all changes in a directory
     diff -ruN dir.orig dir.mod > all-changes-in-dir.patch
  3. # applying a patch to a file
     patch file < file.patch
  4. # applying a patch to a directory
     cd dir
     patch -p1 < /tmp/all-changes-in-dir.patch
  5. # reversing that patch out again when it doesn't work
     cd dir
     patch -Rp1 < /tmp/all-changes-in-dir.patch

There are some handy cvs diff commands:
  1. cvs diff -u file  # changes since last commit
  2. cvs diff -r1.1 -r1.2 -u file   # changes between given revisions
and with git:
  1. git diff -u file # changes since last commit
  2. git diff -u rel22 master file  # changes between given branches

This can also give a crude way to reverse a change: use diff to make a
patch file and then feed it to patch -R... but there are usually
better ways.  cvs update's merge options and git revert.

If you are using patch files without revision control much, you may
find wiggle helpful:
http://cgi.cse.unsw.edu.au/%7Eneilb/source/wiggle/

Ask questions and I'll try to answer.  Mangling files is one thing I
have had far too much practice at!

Hope that helps someone,
-- 
MJ Ray - see/vidu http://mjr.towers.org.uk/email.html
Webmaster/web developer, statistician, sysadmin, online shop maker,
developer of koha, debian, gobo, gnustep, various mail and web s/w.
Workers co-op @ Weston-super-Mare, Somerset http://www.ttllp.co.uk/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]