Bug 132260 - Eclipse doesn't understand negated character classes in .cvsignore
Summary: Eclipse doesn't understand negated character classes in .cvsignore
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: CVS (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.3 M2   Edit
Assignee: platform-cvs-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-03-16 17:08 EST by Matt McCutchen CLA
Modified: 2006-09-25 00:01 EDT (History)
0 users

See Also:


Attachments
Among other things, adds character class support to StringMatcher (16.06 KB, patch)
2006-04-12 00:39 EDT, Matt McCutchen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt McCutchen CLA 2006-03-16 17:08:58 EST
I have checked out from a CVS repository that contains an empty directory "build".  When I build the software, a lot of files get created in this folder.  I wanted to ignore them, so I placed the following .cvsignore file in the folder with the intention of ignoring everything but .cvsignore itself:

     [!.]*

Command-line "cvs diff" gets the idea, but Eclipse doesn't: it fails to ignore the (non-hidden) files the build process created.

The negated character class [!.] should match any single character but a dot; I suspect Eclipse doesn't understand negated character classes.  According to "info cvs", CVS permits "sh(1) file name patterns" in .cvsignore, and according to "man sh", negated character classes are allowed in such patterns, so Eclipse should support them.

My Eclipse:
Version: 3.1.1
Build id: M20050929-0840 (Fedora Core release 4 (Stentz))
org.eclipse.team.cvs.core 3.1.1, org.eclipse.team.cvs.ui 3.1.1
Comment 1 Michael Valenta CLA 2006-03-27 09:34:46 EST
I agree that we should support them. However, we don't have time to address this issue at this time. Patches will be gratefully accepted.
Comment 2 Matt McCutchen CLA 2006-04-08 00:01:20 EDT
Upon second examination, I found that Eclipse's cvsignore parser (StringMatcher) supports only * and ?, not character classes of any kind.  I don't see an obvious way to add support for character classes, so I'm thinking of rewriting the matcher entirely.  Perhaps I can have it use a clever algorithm that takes time linear in the length of the string despite the presence of wildcards.

POSIX specifies all kinds of fancy character classes, including [[:alpha:]], [[.a.]], and [[=a=]].  I think it would be a pain to support all of these, so for the moment I'm going to focus on optionally negated classes containing ordinary characters and ranges, which is what users are likely to want.
Comment 3 Matt McCutchen CLA 2006-04-12 00:39:07 EDT
Created attachment 38362 [details]
Among other things, adds character class support to StringMatcher

I decided against rewriting the matcher to use a faster algorithm; it's too much work for too little benefit.

The attached patch should be enough to support character classes.  I tested the patched StringMatcher a bit and found that it works for typical use cases and some boundary cases, but more testing would be good.  I only supported negation with "!", not "^"; command-line cvs probably recognizes "^", but POSIX discourages its use in globs.

I also made a few other cleanups, especially to the Javadoc, and I redid the determination of fHasTrailingStar to handle \\* correctly; adopt as much or as little of this as you wish.  I stopped short of a thorough cleanup of StringMatcher, even though the class could use one.
Comment 4 Michael Valenta CLA 2006-04-12 09:15:44 EDT
Thanks for the patch. It's too late in the 3.2. release to apply it but we will have a look once 3.3 development starts.
Comment 5 Michael Valenta CLA 2006-08-21 14:29:44 EDT
Patch released to HEAD. Thanks again.
Comment 6 Michael Valenta CLA 2006-09-11 12:56:35 EDT
I have added the following copyright to the StringMatcher file. If it is not adequate, please provide us with an alternate copyright.

Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 132260 Eclipse doesn't understand negated character classes in .cvsignore
Comment 7 Matt McCutchen CLA 2006-09-11 16:28:39 EDT
Looks good.  Thanks.
Comment 8 Michael Valenta CLA 2006-09-19 14:56:26 EDT
Verified fixed in I20060919-0010
Comment 9 David Williams CLA 2006-09-25 00:01:39 EDT
FYI, see bug 158498 for possible regression possibly caused from this patch. 

I'm not sure what 'input' gives rise to the error, but seems related.