Giter Club home page Giter Club logo

Comments (24)

BurntSushi avatar BurntSushi commented on May 16, 2024 10

No. The ignore code and the glob code are related but distinct. Sorry.

Refactoring the ignore code is pretty high on my list because I hope to get perf gains out of it.

I just got married. I'll get to this when I can.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024 4

Hmm. Would you be opposed to this going in $XDG_CONFIG_HOME/ripgrep/ignore? That way, we won't need to specify any weird interaction between the current semantics, which are "obeys parent directory .ignore files," and the new semantics, which if we did what you suggested would be, "obeys parent directory unless $HOME/.ignore exists, in which case, it's used everywhere." $XDG_CONFIG_HOME feels a bit more right.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024 2

Yes. The terminology I'd like to use is "precedence." That is, ignore files specified via --ignore-file have a lower precedence than any other ignore file. That means a whitelisted pattern in an ignore file in a directory will override an ignore pattern in an --ignore-file.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024 2

Fixed in #202.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024 1

Sorry, by $XDG_CONFIG_HOME, I meant "follow the XDG basedir spec." Specifically, if XDG_CONFIG_HOME isn't set, then it defaults to $HOME/.config.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024 1

Well, $HOME/.config/ripgrep/ignore functionality doesn't exist. I was proposing it and asking if it would satisfy your use case. :-)

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

I am on RHEL6.6 and echo $XDG_CONFIG_HOME returns

XDG_CONFIG_HOME: Undefined variable.

Also this is work machine.. so I don't have admin rights. Do we have an xdg alternative in that case?

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

Hmm, I symlinked $HOME/.config/ripgrep/ignore to ~/.agignore. I also tried few other symlink names. But none helped.. The files ignored in ~.agignore are still being searched.

km²~/.config/:ripgrep> lta                                                        
total 8.0K
drwxr-xr-x 28 kmodi users 4.0K Sep 24 00:48 ../
lrwxrwxrwx  1 kmodi users   21 Sep 24 00:52 .rpignore -> /home/kmodi/.agignore
lrwxrwxrwx  1 kmodi users   21 Sep 24 00:52 .ignore -> /home/kmodi/.agignore
lrwxrwxrwx  1 kmodi users   21 Sep 24 00:52 ignore -> /home/kmodi/.agignore
drwxr-xr-x  2 kmodi users 4.0K Sep 24 00:52 ./
km²~/.config/:ripgrep> pwd                                                             
/home/kmodi/.config/ripgrep
km²~/.config/:ripgrep> 

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

Ah OK, that would work as long as I can maintain just one common global ignore file :)

Thanks!

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

Here's another idea to implement the same. I like it better because then I use an alias to have the complete rg configuration control.

How about having a switch named --ignore-file. Here's a spec suggestion for that:

--ignore-file FILE: Read the .ignore file FILE before reading the .ignore, .gitignore, etc. in the current or parent directories. Multiple --ignore-file flags may be used.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024

When you say "Read the ignore file before reading .ignore .gitignore in current or parent directories," do you mean that --ignore-file takes precedence over them? (In contrast, I'd expect .ignore/.gitignore to take precedence over a global config file.)

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

do you mean that --ignore-file takes precedence over them?

No, here was my thinking..

Let's use we did rg --ignore-file ~/.ignore foo and suppose we had:

$ cat ~/.ignore
*.log

Suppose we had a /proj and

$ cat /proj/.ignore
!imp.log

Then if ~/.ignore (FILE arg to --ignore-file) is read first, /proj/.ignore will be able to white-list some part out of the ignore set by the previously read file if we are running rg --ignore-file ~/.ignore foo from the /proj directory.

So, read first implies open to be overridden.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024

@kaushalmodi Hmm, yes, I see, I think those semantics makes sense.

from ripgrep.

davidosomething avatar davidosomething commented on May 16, 2024

FWIW the_silver_searcher uses --path-to-ignore SOMEPATH and the file name used is (as of 0.33.0) .ignore

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

Allowing multiple --ignore-file becomes even more useful as I see an application where I can have a central .ignore file for the whole project (version controlled), and then users can add their specific .ignore files on top of that if they wish.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024

@kaushalmodi I definitely like the idea of --ignore-file (allowing multiple uses) better than a global ignore file. If we just add that, does that satisfy your use case?

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

If we just add that, does that satisfy your use case?

Absolutely! Then I need to simply add that to my alias and then it becomes as good as a global ignore file. What's even better is that I can have more than one global ignores.. one that is central to the whole project, others which could be user-specific.

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024

Perfect. Much easier to implement. Hopefully tonight. :-)

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

Thanks! Just to confirm that they will have the lowest priority when compared with the ones in the current/parent directories as in my example above, correct?

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024

This is slightly trickier than I thought and probably exceeds my budget for middle-of-the-week work unfortunately. The issue is that every ignore file needs to interpret paths relative to itself (these are the semantics of .gitignore, and frankly, nothing else really makes much sense), and current ignore code makes this a little tricky. I'm happy to hack this in because I have plans to overhaul the ignore code anyway, but it requires a bit more attention than I'm capable of right now.

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

I hope that the overhaul in the globbing code now makes it possible to implement this.

from ripgrep.

kaushalmodi avatar kaushalmodi commented on May 16, 2024

I just got married. I'll get to this when I can.

Understood. Congratulations! :)

from ripgrep.

OJFord avatar OJFord commented on May 16, 2024

@BurntSushi I think it's unfortunate that there's no way (?) to get the behaviour you proposed but ultimately decided against:

# $XDG_CONFIG_HOME/ripgrep/profile
export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/ripgreprc"
# ripgreprc
--ignore-file="$XDG_CONFIG_HOME/ripgrep/ignore"
# ignore
*.lock

"$XDG_CONFIG_HOME/ripgrep/ignore": No such file or directory (os error 2)

Would you be open to making something possible here? If so, which issue do I open - 'parse env vars in ripgreprc', or 'revisit global ignore file'? 🙂

NB: another (probably simpler) approach could be to allow relative (to the RIPGREP_CONFIG_PATH) paths:

./ignore: No such file or directory (os error 2)

(edit: when I say 'no way', I suppose I mean 'with static config files' - obviously I could have my .profile write out the location to ripgreprc, or alias it. It's just the former seems.. not great, and the latter would really need to be a wrapper script on PATH, since I'd also want this in vim for example, so that ends up quite 'hacky' too.)

from ripgrep.

BurntSushi avatar BurntSushi commented on May 16, 2024

@OJFord See: #1792

I don't know why you see wrapper scripts as hacky. I have a whole bunch of them in my ~/bin.

from ripgrep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.