ggreer / the_silver_searcher

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

Glob patterns don't work inside directories #100

Open chetan opened 12 years ago

chetan commented 12 years ago

The following pattern inside .gitignore doesn't work: log/*.log; while this works fine: *.log. I created a small test repo to display the issue:

https://github.com/chetan/silver_searcher_bug

ggreer commented 12 years ago

Thanks for the repo. I can reproduce. I'm pretty sure I know where the problem is, but it'll probably be a few days before I have the time to dive into this.

gjtorikian commented 12 years ago

Probably related, but even something like log/log.log does not work.

chetan commented 12 years ago

Confirmed. Looks like the method filename_ignore_search() only takes the filename portion as a param and not the full (relative?) path as well. Updated my test repo.

ggreer commented 12 years ago

Yeah... my bad. I'm pretty busy now, but I will be not-busy starting October 30th. I'll definitely get to this then.

ggreer commented 12 years ago

Ok, try master now.

chetan commented 12 years ago

Fix looks good for the original issues. Another small variation is if you only specify a subdir, e.g., log or log/, it won't match unless you add a glob pattern like log/*. I updated the test repo to reflect this.

ggreer commented 12 years ago

Bleh. I had a return value wrong. Everything should work now.

chetan commented 12 years ago

looks good!

ggreer commented 12 years ago

:heart:

I discovered another bug while fixing this, but most people won't notice it and the current fix kills performance. I'll have to think of a different solution before merging a fix into master.

chetan commented 12 years ago

@ggreer does it have anything to do with processing ignore files found in subdirectories? :)

aeonaut commented 9 years ago

Huh. June 2015 and I'm still seeing this bug. A gitignore with log/*.log does not work; that is, ag returns results from the ignored log files. If I change that to just log/ or log, it works correctly. There's no leading slash problem (Issue #285). Just installed the latest copy of ag via homebrew. Any ideas why I still might be seeing this?

dmix commented 9 years ago

Same here... on linux with latest build.

petRUShka commented 9 years ago

Same error occurs with ag version 0.30.0.

dtuite commented 9 years ago

I'm seeing the same issue with 0.30.0 installed via homebrew.

Note that the trailing .log in @aeonaut's example isn't causing the problem. I'm seeing the same issue with a pattern like build/*. ag respects build/ but ignores build/*.

jamesgecko commented 9 years ago

This issue appears to be present in 0.31.0 from homebrew on OS X 10.11.1.

stevschmid commented 8 years ago

I just ran into the same issue as @jamesgecko

alcuadrado commented 8 years ago

I can confirm that the bug is present in 0.31.0 from homebrew on OS X 10.11.1.

jonjonw commented 8 years ago

The bug is also in 0.32.0 from homebrew on OSX 10.11.5.

Dmitra commented 8 years ago

@chetan, please reopen this issue, as it's still relevant

atsepkov commented 8 years ago

I too am seeing this with ag 0.30.0 on OSX 10.10.5

HerringtonDarkholme commented 8 years ago

Confirmed on 0.33.0, OSX Sierra

iammerrick commented 7 years ago

Also seeing this on latest Ag + Sierra

subhojit777 commented 7 years ago

Ag version 1.0.2 macOS Sierra 10.12.2

At first I thought there is some issue with ag, then I found that path was not configured properly in .gitignore. After correcting that, ag started ignoring the files.

PezCoder commented 7 years ago

Something like this: web/js/* expression in my .gitignore is being ignore by ag, i.e it's searching inside those directories & not ignoring it. The above expressions works fine for git grep command that means it's a valid expression.

tony commented 6 years ago

@ggreer Can this issued be reopened? If not we should open a new issue. I'm getting matches of artifact files that are in gitignore.

ag version 2.1.0

Features:
  +jit +lzma +zlib

git --version
git version 2.16.2
firedev commented 6 years ago

This is a bit annoying since I am using it in vim and it tries to search through compiled files.

jamesjtong commented 6 years ago

Just tried with the latest silver searcher from homebrew (2.1.0). @chetan Can we reopen this?

**/dist doesnt is ignored but something like /dist works. even though their is no /dist and I want to target nested dists.

chetan commented 6 years ago

Re-opening due to popular demand, though I don't currently use ag myself.

firedev commented 6 years ago

This is getting too annoying. Is there a replacement for ag?

papaben commented 6 years ago

Not sure what's going on here. I am on version 2.2.0 (installed with homebrew). I added the following little zsh to my profile. Now I have to call mag instead of ag. =/

##
# Maps contents of gitignore into --ignore ___ option flags for `ag`
##
function agIgnore() {
  declare ignore=""

  for thing in $(< .gitignore); do
    ignore="$ignore --ignore '$thing'"
  done

  echo $ignore
}

alias mag='ag $(agIgnore)'
dkushner commented 5 years ago

Having the same issue suddenly. Using version 2.1.0-1 on Ubuntu 18.04. ag has been my daily driver for years now for any kind of searching task. It's a shame to see such a major issue go unaddressed for so long. I'm going to roll with @papaben's workaround for now, but hope to see this addressed with a patch at some point.

chapeupreto commented 5 years ago

Same problem happens with ag version 2.2.0.