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

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

From
FKFlorian Köberle <florianskarten@web.de>
Date
Jun 23, 2008, 17:32 UTC
Message-ID
<485FDE42.1060106@web.de>
In-Reply-To
<1214177145-18963-1-git-send-email-robin.rosenberg@dewire.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Robin,
thank you for accepting my first patch :D.
| +/**
| + * This class implements a TreeeFilter that uses the wildcard style
pattern
| + * matching like of Posix fnmatch function.
| + */
Typo: One 'e' to much in TreeeFilter.
It would be more efficient to
| +	@Override
| +	public TreeFilter clone() {
| +		return new WildCardTreeFilter(pattern);
| +	}

One way to create a clone of the FileNameMatcher is to call: originalMatcher.reset() FileNameMatcher clone = originalMatcher.createMatcherForSuffix()

I will send a patch which implements a copy constructor for FileNameMatcher.

First I wanted to implement a clone() method, but found this page and decided then to implement a copy constructor: http://www.javapractices.com/topic/TopicAction.do?Id=71

A Implementor of a super class could imply that clone() of object gets called, as stated in the javadoc of clone():

quote (javadoc ob Object#clone()):
- -----------
By convention, the returned object should be obtained by calling super.clone
- -----------

I think this is a bad convention, as one should not rely on Object#clone() to do the copy job for one. If you really need a clone method then I would do it the same way you did, by calling a constructor which does the job.

Best regards, Florian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIX94k59ca4mzhfxMRAgDjAJ9S76L8I5Lqed4lKfgTf+2cp2IQ9gCfQNVh z72+NGvmIy3H0gwveKRfn+w= =wnpy -----END PGP SIGNATURE-----

Previous: Shawn O. PearceNext: Florian Köberle
Message 4 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.