Subject: Re: [egit / jgit] Implementation of a file tree iteration using ignore rules.

From: Florian Köberle <[email-masked]>
Date: Sat, 10 May 2008 17:11:59 +0200

Hi

| This is an interesting start.  Did you see the existing "Main" class
| in org.spearce.jgit/src/org/spearce/jgit/pgm?  It sets up and invokes
| a TextBuiltin, which is sort of like the "Command" class you added in
| your first patch.  Though TextBuiltins are created on-the-fly and thus
| are harder/impossible to use to format a "jgit help".
I noticed that the class appeared after a rebase, but didn't have a
closer look to it yet.

|
| I think your approach of building up a table of commands is likely
| the better one long term, so I am interested in seeing the two unify,
| taking the best from each (from Main and MainProgram that is).
|
| Please note that jgit is restricted to Java 5 APIs only right now.
| The "MainProgram" class you introduced uses Arrays.copyOfRange()
| which does not compile under Java 5.  I guess it is new in Java 6?
Yes it is new in Java 6. A patch fixing this is contained in the patch
set I send to the mailing list.
| What is missing here is really two things:
|
|  #1)  Take .gitignore and .git/info/exclude (and other patterns) into
|       account as WorkingTreeIterator (base class of FileTreeIterator)
|       loops over the entries in a directory.

I had a look at the WorkingTreeIterator and it seems to me that it is
possible to reuse my Rules class there.

We could simply give the iterator a member variable of type Rule.

The method loadEntries of WorkingTreeIterator could then use the rules
class to filter out unwanted files and directories.

The constructor  WorkingTreeIterator(final WorkingTreeIterator p) could
use the Rules#getRulesForSubDirectory to create a Rules instance from
the parent Rules instance.

Also note that my Rules implementation would ignore the directory a in
the case of "/a\n!/a/b.txt". This means that a directory may not appear
in the list entries, but must be used to create another iterator.

I suggest to put all the classes from the package
org.spearce.jgit.treewalk and the package
org.spearce.jgit.lib.fileiteration into one package. Please tell me
which package and I will send a patch, or do it yourself. I don't have
any outstanding changes.

I don't see a easy way of porting my Rules implementation to the
TreeFilter framework, but as you may noticed it is may not necessary to
do so.

| I think the command you are looking for is `git send-email`.
Thanks, after switching to a newer version of git I was able to use that
command.

Best regards,
Florian