On Mon, 18 Sep 2000, Amir Karger wrote:
> On Mon, Sep 18, 2000 at 02:41:03PM +1000, Allan Rae wrote:
> > On Fri, 15 Sep 2000, Amir Karger wrote:
> >
> > > On Fri, Sep 15, 2000 at 01:48:42PM +1000, Allan Rae wrote:
> > > >
> > > > I have modified GNU diff to be able to emulate `cvs diff`. This allows
> > > > anyone with two copies of a cvs snapshot to modify one and generate a
> > > > diff between the two that is the equivalent of what they'd get if we gave
> > > > them cvs access.
> > >
> > > are you sure one couldn't hack
> > > together a perl script that would use diff as it already stands?
> >
> > I tried this with a shell script. It was ugly and it required me to
> > identify which files were present in one directory and not the other
> > (something diff already does for directory comparisons) and call diff on
> > each individual pair of files like:
> > diff -u dir1/file1 /dev/null
>
> Sounds like this worked, even if it was ugly.
Almost worked, but was getting hideously complicated and was duplicating
all the work done by diff. In fact it was more complicated than diff
because it had to work around diff's shortcomings.
> Still not as ugly as requiring everyone to use a patched version of
> diffutils. (What happens when they upgrade diffultils? What if someone
Diffutils hasn't changed in five years -- at least according to the
ChangeLog.
> else wants them to use a differently patched version?) I guess if you
> sent in your patches to the diffutils folks, that might make more
> sense. And might even be useful since lots of people in the world who
> use diff also want to use it for cvs-diff-like things.
As I mentioned in an earlier post diffutils ChangeLog's last entry was in
1994. I was hoping for some feedback while I figure out who to submit my
changes to.
> > Either way required changes to diffutils sources so I wrote the one that
> > made better sense to me.
>
> I don't understand why the shell script you described required changing
> diffultils.
Okay, once more. The '-N' option to diff only works when comparing
directories. I can't compare directories with diff-2.7 and lyx-devel cvs
module because there are some patterns that match files that shouldn't be
excluded. For example, "acinclude.m4" can be excluded in all directories
except lyx-devel/lib/reLyX/. There are other patterns that should match
in only one subdirectory (see *.[cCh] discussion below).
Trying to work around the '-N' flag problem by figuring out which files
exist in one directory but not another was just duplicating all the work
already done in diff to build a list of files to diff (or to exclude) and
it added to the complexity. The script was basically rewriting diff as a
shell script and only using the file-comparison code from diff to generate
the actual patches. Stupid idea. So I extended diff with a few lines of
code instead.
> Alternatively, if you're worrying about ignoring the right files, why not
> write a script that creates a file of files to ignore in the diff, and then
> call diff -X?
Try:
man diff
or
info diff
diff only ignores files whose _basename_ matches a pattern in the exclude
file. My first patch to diff was to make it possible to have a pattern
like:
*/src/frontends/xforms/forms/*.[Cch]
so that particular files in a particular subdirectory would be excluded.
That's when I thought it'd be more useful to just get diff to use a local
exclude file (local to each subdir: .cvsignore for example).
And before you ask, I did try building a list a patterns to exclude from
the .cvsignore files in my shell script and then tried to add the files
that were incorrectly matched¹. You'll notice for example that
src/frontends/xforms/forms/.cvsignore contains patterns for *.[Cch] with
the result that all source files in every subdirectory would match. I
tried four different ways² of building the patch and all had similar
limitations. Ultimately, I decided diff needed extending to better cope
with these difficulties.
¹ Remember you can't remove a patch that shouldn't have been generated so
you have to err on the side of caution and then figure out which files
should have been included.
² I've just thought of a 5th way that might almost work but it involves
recursing through the directory structure and building exclude patterns to
be given to `diff -N -X` such that you only do one directory depth at any
time (ie. add the subdirectory names to the patterns so that diff won't
enter them). This is also overly complicated. Extending diff is still the
nicest solution.
Allan. (ARRae)