ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
26.18k stars 1.43k forks source link

.aginore not ignoring filenames containing several dots #755

Open ghost opened 9 years ago

ghost commented 9 years ago

If my .agignore file contains:

*.htm

And if I have two files a.htm and a.b.htm, the latter is not ignored by .agignore.

Here's an example:

$ echo "needle" > haystack.htm
$ echo "needle" > haystack.a.htm
$ echo "*.htm" > .agignore
$ ag needle
haystack.a.htm
1:needle

I found out that using **.htm works in this case, but if this is intentional, it is very uninituitive, especially since it does not follow .gitignore syntax. I'd recommend in this case mentioning this explicitly in https://github.com/ggreer/the_silver_searcher/wiki/Advanced-Usage, which says that:

.agignore uses the same patterns as .gitignore and .hgignore.

JIghtuse commented 9 years ago

It works on 0.30.0. git bisect told me it was intentional change indeed (introduced in d3a5de43e4c7b8735fede1c). I don't quite get why ag should behave like this, but fix is trivial - revert commit to use strrchr instead of strchr. I can sent PR if @ggreer agrees to accept it.

epmatsw commented 9 years ago

Ugh, that's my bad on that one. The issue that was fixed was that you couldn't ignore *.min.js files, because it would just get the .js, which doesn't match any ignored extension. Now, it's getting .b.htm, which again doesn't match any extension. It seems like the fix is going to have to be more nuanced than my change :(

fuzzy76 commented 8 years ago

As a web developer, not being able to ignore .min.js files means it is completely broken :(

brianpeiris commented 8 years ago

FYI, the workaround for this is to add *.a.htm or *.*.htm to your .agignore.

fuzzy76 commented 8 years ago

Why aren't you comparing the entire filename when matching against wildcards? I'm pretty sure that's what git does when parsing .gitignore

brianpeiris commented 8 years ago

@fuzzy76 It's just a bug but there are performance concerns that make the fix a bit complicated. @ggreer mentions it in his blog post: http://geoff.greer.fm/2014/10/13/help-me-get-to-ag-10/

jean commented 7 years ago

Argh. Kind of amazed to realize that glob matching (e.g. *.min.*) is "special" in ag ..

denilsonsa commented 7 years ago

I believe this issue was fixed by 221e4c2f070cb69825a42bd43a6bd79e18c0729f

spookylukey commented 7 years ago

This issue is still not fixed. With current master, if, for example, you have *.min.js in your .ignore, then foo.min.js is skipped, but foo-1.0.min.js is not. So, jquery-x.y.z.min.js for example, which is very common, is not skipped.

spookylukey commented 7 years ago

For those who want a workaround, version 0.28.0 is the last released version that doesn't have this bug.

p-phillips commented 6 years ago

You can also add a workaround to your .ignore files by using this type of pattern:

  *[*\.]js
  *[*\.]html                                                                                                                                
  *[*\.]css 

Presumably this will continue to work once the fix is in place.

adelara commented 3 years ago

Was this ever fixed ? Doesn't look like so, here is the example of files I have and want git to ignore them: project/settings/internal/com.kms.katalon.execution.properties project/settings/internal/com.kms.katalon.execution.webui.properties project/settings/internal/file1.properties project/settings/internal/file2.properties

At the top of my project directory, I have a .gitignore with only this - and it fails to ignore the first two while file1.properties and file2.properties are dutifully ignored. [.]properties

I'm on git version 2.29.2.windows.2 // ---------------------- Looks like the problem is actually somewhere else: https://github.com/msysgit/git/pull/110