From: ph12hucg@sbusol.rz.uni-sb.de (Carsten Grammes)
Newsgroups: gnu.misc.discuss
Subject: Re: Summary of answers (GNU diff question)
Date: 11 Jan 1993 09:25:37 GMT
Organization: Universitaet des Saarlandes,Rechenzentrum
NNTP-Posting-Host: sbusol.rz.uni-sb.de

Many thanks to those who helped me with my question. As at least one
(Vince) thought it a general question I will give a summary of the
answers.


From: Vince Tessier <vtessier@vela.acs.oakland.edu>

What you now need is patch, probably also available for DOS.  Patch takes
the file produced by diff and applies it to a source file, producing the
new file.  A ficticious example:

You've got floob-1.3.tar.Z, a huge file.  You see announced on the net
floob-1.4.tar.Z, even bigger, along with a notice that 
floob-1.3-1.4.diff.Z is available, only 10% of the size of either .tar
file.  You don't want to download all of floob-1.4.tar.Z, so you get
the diff file.

With the 1.3 sources in a nearby directory, and the diffs uncompressed,
you type (in Unix)
	patch < floob-1.3-1.4.diff
and all the 1.3 source files are automagically updated to 1.4.

Patch is a really wonderful program, written by Larry Wall, the same
guy that invented Perl.

[flame^H^H^H^H^H well meant advice deleted...]


Reply-To: dodd@roebling.poly.edu

get patch from prep.ai.mit.edu it uses context diffs to update files. also,
GNU diff comes with an texinfo document that covers (superbly) diff and patch.
You can get a hard copy from the texinfo file with TeX or create an info page
for use with GNU emacs.  I could send you the info file output if you can't
create it.


From: strombrg@uceng.uc.EDU (Dan Stromberg)

diff -c (or diff -C3 for older versions) will produce a context diff.
Differences are given both in terms of line numbers, and contextual
information, so if line numbers change a little, the "right place" can
still usually be found.

patch -p0 < file.diff can be used to apply such a patch.  I know
there's a patch binary in existence for MS-DOS; I used one back when I
was running DOS (and wishing I had a UNIX - now I use Linux, after a
motherboard upgrade).  It might well be in the CBIP archive.

I've applied normal (non-context) diff's with patch, but the success
rate is inherently lower, statistically speaking.

From: mcastle@cs.umr.edu

The source for gnu-diff can be found on prep.ai.mit.edu among other sites
(probably a close one to you) in pub/gnu/diff*.tar.Z  where * has the version
number and all in it.  If you get that, there are probably some *.texi and/or
some *.info files.  These are for the favored gnu doc format, texinfo.  
(The *.texi files are the source for the docs.  You can run them through 
TeX and using some gnu supplied macros and extra stuff make some nifty
printed docs. Or run the same *.texi files through emacs with it's texinfo
mode and create *.info files that are basically hypertext help files).
On simtel20, ind pd1:<msdos.gnuish> there should be and info*.zip package
that is a standalone texi->info processor and an info reader.  You may
want to try those to read the docs that come with the diff source. 

If you have access to a unix system, doing a 'man diff' will get you a lot
of useful information.  Gnu just tends to make their software run faster
and add nifty command line options (such as using --context=2 rather than 
-c2 or --recursive rather than -r).  

For producing diff's suitable for use with the program 'patch' you want
to make a context diff.  A context diff tries to place any changes made
to files within a context of what the orginal file looked like.  It does
this by listing a few lines before and after the block of changes (the 
number supplied with --context above), showing lines in old, then lines
in new file.  This diff can then be used to 'patch' a file that may
not be identical to the file used to generate the patch.  For examples,
2 people find 2 different bugs (or add 2 different features) to a 
program.  Now the line numbers of the resulting code for both people will
not necessarily match, but patch will heuristically search an area around
the line number supplied in the patch to try and apply the patch anyway
(this is why the 'context' is so important).  

To create a context diff, do the following

diff --context oldfile newfile > file.dif

A person will then do 

patch < file.dif

and patch will automagically apply the patch (and make a backup of the 
original file).

if you want to make context diffs of a whole subdir, I think 

diff --recursive --context olddir newdir > dir.dif

will create a diff usable by patch, but I'm not 100% positive on this point.


*********************************************************************
Carsten Grammes			Internet: ph12hucg@rz.uni-sb.de
Experimental Physics		Voicenet: 49-681-302-3032
Universitaet Saarbruecken	Faxnet  : 49-681-302-4316
6600 Saarbruecken
Germany
*********************************************************************