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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> 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 {
...
> +	@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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux