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

Re: [JGIT PATCH 4/4] LsTree: Enable pattern matching in LsTree

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 25, 2008, 04:09 UTC
Message-ID
<20080625040931.GA11793@spearce.org>
In-Reply-To
<1214343392-5341-5-git-send-email-robin.rosenberg@dewire.com>
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
Show 13 quoted lines
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/WildCardTreeFilter.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/WildCardTreeFilter.java
> index ce6da5e..8b22e25 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/WildCardTreeFilter.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/WildCardTreeFilter.java
> @@ -76,7 +76,7 @@ public class WildCardTreeFilter extends TreeFilter {
>  		if (walker.isRecursive() && walker.isSubtree())
>  			return true;
>  		matcher.reset();
> -		matcher.append(walker.getPathString());
> +		matcher.append(walker.getName());
>  		if (matcher.isMatch())
>  			return true;
>  		return false;

Are we only supporting `jgit ls-tree . '*.c'` ? Or do we want to allow `jgit ls-tree . 'src/*.c'`?

ls-tree is only a little sample program that is not likely to have a lot of real-world users calling it; but is a good demonstration of how to use TreeWalk. So I really don't care either way.

The WildCardTreeFilter on the other hand could be applied to a RevWalk, such as to grab history for not just 'foo.c' but anything that matches 'f*.c'. But then you have to ask, why is the filter limited to testing only the last component of the path? Why can't it test 'src/f*.c'?

Otherwise everything in your series up until here makes sense and looks good to me. Be nice if the tree filter wasn't so abusive in needing to look at every path in the project, as that would really hurt if it was applied to a RevWalk. But its not required to be fast, if you ask for fnmatch paths, you get what you asked for...

-- 
Shawn.
Previous: Robin Rosenberg
Message 10 of 10 in “LsTree: Do not use the default first empty tree in the walker”
  1. 1/4 LsTree: Do not use the default first empty tree in the walkerRobin Rosenberg, Jun 24, 2008
  2. 2/4 Create a fnmatch-style pattern TreeFilterRobin Rosenberg, Jun 24, 2008
  3. 3/4 Added a method to get the non-relative name from the tree walkerRobin Rosenberg, Jun 24, 2008
  4. 4/4 LsTree: Enable pattern matching in LsTreeRobin Rosenberg, Jun 24, 2008
  5. oops, resendRobin Rosenberg, Jun 24, 2008
  6. 1/4 LsTree: Do not use the default first empty tree in the walkerRobin Rosenberg, Jun 24, 2008
  7. 2/4 Create a fnmatch-style pattern TreeFilterRobin Rosenberg, Jun 24, 2008
  8. 3/4 Added a method to get the non-relative name from the tree walkerRobin Rosenberg, Jun 24, 2008
  9. 4/4 LsTree: Enable pattern matching in LsTreeRobin Rosenberg, Jun 24, 2008
  10. Shawn O. PearceJun 25, 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.