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

Re: [PATCH 1/2] Create a fnmatch-style pattern TreeFilter

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 23, 2008, 00:27 UTC
Message-ID
<20080623002707.GK11793@spearce.org>
In-Reply-To
<1214177145-18963-1-git-send-email-robin.rosenberg@dewire.com>
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> +
> +package org.spearce.jgit.revwalk.filter;
This should be treewalk.filter, its a filter for tree entries.
> + * This class implements a TreeeFilter that uses the wildcard style pattern
fyi, minooooor typo on TreeFilter.
> +public class WildCardTreeFilter extends TreeFilter {
...
Show 9 quoted lines
> +	@Override
> +	public boolean include(TreeWalk walker) throws MissingObjectException,
> +			IncorrectObjectTypeException, IOException {
> +		matcher.reset();
> +		matcher.append(walker.getPathString());
> +		if (matcher.isMatch())
> +			return true;
> +		return false;
> +	}
Hmm. 

It isn't as efficient as it could be. Obtaining the string of the path is somewhat costly as we have to convert from the byte[] to a char[] and then wrap that into a String, just to check the pattern again. Its more accurate to convert to the string, but it is a lot slower.

But I'm wondering about what happens when the TreeWalk is considering a subtree path name. Does the matcher still match the pattern? By that I mean lets say the pattern was:

	src/xdiff/*.c

In this case the include method is first called with the path "src"; if it returns false the TreeWalk won't recurse into the subtree and thus you'll never get to consider "src/xdiff" or "src/xdiff/foo.c".

-- 
Shawn.
Previous: Robin RosenbergNext: Florian Köberle
Message 3 of 5 in “Create a fnmatch-style pattern TreeFilter”
  1. 1/2 Create a fnmatch-style pattern TreeFilterRobin Rosenberg, Jun 22, 2008
  2. 2/2 LsTree: Enable pattern matching in LsTreeRobin Rosenberg, Jun 22, 2008
  3. Shawn O. PearceJun 23, 2008
  4. Florian KöberleJun 23, 2008
  5. ] Implementation of a copy constructor for FileNameMatcher.Florian Köberle, Jun 23, 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.