git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH v3 0/23] Implementation of a file tree iteration using ignore rules.

From
FKFlorian Koeberle <florianskarten@web.de>
Date
May 23, 2008, 20:34 UTC
Message-ID
<1211574872-23676-1-git-send-email-florianskarten@web.de>
Hi
This patch set contains a new fnmatch implementation.
I dropped the idea of an regex based Matcher and implemented my own one.
The matcher matches character for character and can produce another matcher, which always starts at the position where it's parent was at creation time.

If you need to match: very/long/path/a.txt very/long/path/b.txt very/long/path/c.txt

Then you can match "very/long/path" in matcher p and then "a.txt", "b.txt" and "c.txt" in another matcher c.
That works for any input pattern which are currently supported:
* characters
* the wildcards ? and *
* the wildcards ? and * with one character which should not appear like '/' 
* simple groups like [ab]
* ranges in groups like [a-c]
* inversed groups like [!ab]
Unsupported are colon expressions like ":alpha:". I didn't expect git-add to support it, but as I just noticed git does.
 
Also backslashes expressions like "\d" for digits are evaluated as the characters \ and d. Looks like git does the same for backslashes. In "git-add" patterns \  characters get replaced by / characters, as windows users might want to type a\b.txt instead of a/b.txt.

All implementations of FilePattern are now based on this matcher. I combined as suggested the TreeFilePattern and the ComplexFilePattern into one class named FilePathPattern. I furthermore renamed the GlobalFilePattern into FileNamePattern.

"git add" patterns are now handled very similar to git, except that a/\*/b.txt is also a valid pattern. It would match any path that starts with "a/" and ends with "/b.txt" independent of the number of slahes between.

 .../org/spearce/jgit/lib/FileNameMatcherTest.java  |  311 +++++++++++++
 .../jgit/treewalk/LightFileTreeIteratorTest.java   |  114 +++++
 .../treewalk/rules/AddCommandIterationTest.java    |  321 +++++++++++++
 .../treewalk/rules/OverallIgnoreRulesTest.java     |  375 +++++++++++++++
 .../jgit/errors/InvalidPatternException.java       |   44 ++
 .../jgit/errors/NoGitRepositoryFoundException.java |   28 ++
 .../errors/PathNotInProjectDirectoryException.java |   25 +
 .../src/org/spearce/jgit/lib/Constants.java        |   30 +-
 .../src/org/spearce/jgit/lib/FileNameMatcher.java  |  376 +++++++++++++++
 .../src/org/spearce/jgit/lib/Repository.java       |  482 +++++++++++++-------
 .../src/org/spearce/jgit/lib/WorkTree.java         |   67 +++
 .../jgit/treewalk/LightFileTreeIterable.java       |   59 +++
 .../jgit/treewalk/LightFileTreeIterator.java       |  112 +++++
 .../jgit/treewalk/rules/AddRuleListFactory.java    |   75 +++
 .../jgit/treewalk/rules/AddRulesFactory.java       |   90 ++++
 .../jgit/treewalk/rules/FileNamePattern.java       |   58 +++
 .../jgit/treewalk/rules/FilePathPattern.java       |   76 +++
 .../spearce/jgit/treewalk/rules/FilePattern.java   |  107 +++++
 .../jgit/treewalk/rules/IgnoreRuleListFactory.java |   94 ++++
 .../src/org/spearce/jgit/treewalk/rules/Rule.java  |   61 +++
 .../treewalk/rules/RuleListToObjectConverter.java  |  130 ++++++
 .../src/org/spearce/jgit/treewalk/rules/Rules.java |   99 ++++
 .../jgit/treewalk/rules/RulesImplementation.java   |   73 +++

Best regards, Florian Koeberle

Next: Florian Koeberle
Message 1 of 41 in “Implementation of a file tree iteration using ignore rules.”
  1. 0/23 Implementation of a file tree iteration using ignore rules.Florian Koeberle, May 23, 2008
  2. 01/23 Added the class InvalidPatternException.Florian Koeberle, May 23, 2008
  3. 02/23 Added the class FileNameMatcher and a test class for it.Florian Koeberle, May 23, 2008
  4. 03/23 Added the interface FilePattern.Florian Koeberle, May 23, 2008
  5. 04/23 Added the class Rule.Florian Koeberle, May 23, 2008
  6. 05/23 Added the iterface Rules.Florian Koeberle, May 23, 2008
  7. Robin RosenbergJun 6, 2008
  8. 06/23 Added the class FileNamePattern.Florian Koeberle, May 23, 2008
  9. Robin RosenbergJun 6, 2008
  10. 07/23 Added the class FilePathPattern.Florian Koeberle, May 23, 2008
  11. 08/23 Added the class IgnoreRuleListFactory.Florian Koeberle, May 23, 2008
  12. 09/23 Added a Rules interface implementation and a factory for it.Florian Koeberle, May 23, 2008
  13. Robin RosenbergJun 6, 2008
  14. 10/23 Added test class OverallIgnoreRulestest.Florian Koeberle, May 23, 2008
  15. 11/23 Added the class PathNotInProjectDirectoryException.Florian Koeberle, May 23, 2008
  16. 12/23 Added the class AddRuleListFactory.Florian Koeberle, May 23, 2008
  17. 13/23 Formatted Constants class.Florian Koeberle, May 23, 2008
  18. 14/23 Added constant REPOSITORY_DIRECTORY_NAME to Constants class.Florian Koeberle, May 23, 2008
  19. 15/23 Added class AddRulesFactory.Florian Koeberle, May 23, 2008
  20. 16/23 Added the class LightFileTreeIterator and a test for it.Florian Koeberle, May 23, 2008
  21. 16/23 Added the class LightFileTreeIterator and a test for it.Florian Koeberle, May 31, 2008
  22. 17/23 Added class LightFileTreeIterable.Florian Koeberle, May 23, 2008
  23. 18/23 Added path related constants to the Constants class.Florian Koeberle, May 23, 2008
  24. 19/23 Added WorkTree class which can be constructed over Repository.Florian Koeberle, May 23, 2008
  25. Robin RosenbergJun 6, 2008
  26. 20/23 Added the class NoGitRepositoryFoundException.Florian Koeberle, May 23, 2008
  27. Robin RosenbergJun 6, 2008
  28. Florian KöberleJun 8, 2008
  29. Robin RosenbergJun 8, 2008
  30. 21/23 Formatted Repository class.Florian Koeberle, May 23, 2008
  31. Robin RosenbergJun 6, 2008
  32. 22/23 Added findWorkTree method to Repository class.Florian Koeberle, May 23, 2008
  33. 23/23 Added the test class AddCommandIterationTest.Florian Koeberle, May 23, 2008
  34. 23/23 Added the test class AddCommandIterationTest.Florian Koeberle, May 31, 2008
  35. Robin RosenbergJun 6, 2008
  36. Florian KöberleMay 31, 2008
  37. Robin RosenbergJun 6, 2008
  38. Florian KöberleJun 8, 2008
  39. Robin RosenbergJun 8, 2008
  40. Florian KöberleJun 9, 2008
  41. Shawn O. PearceJun 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.