sharkdp / fd

A simple, fast and user-friendly alternative to 'find'
Apache License 2.0
33.78k stars 807 forks source link

Loosen strict handling of missing --ignore-file? #280

Closed mqudsi closed 6 years ago

mqudsi commented 6 years ago

Another FZF-prompted question: in some repositories, I have a .ignore file to help rg ignore files included in the git repo but not intended to be searched. I would like fd to use .ignore when it is present in $PWD, but unfortunately if the file does not exist fd throws an error:

mqudsi@Blitzkrieg /m/d/rand> fd --ignore-file .ignore hello
Error while parsing custom ignore file '.ignore': entity not found.

For cases where an ignore file is appended programmatically, it would be helpful to either (not necessarily silently?) ignore missing --ignore-file parameters or to otherwise support some sort of --maybe-ignore-file or --ignore-file xxx --ignore-missing-ignore-file.

This doesn't just apply to fzf, in my case I would like to alias fd to fd --ignore-file .ignore, too.

sharkdp commented 6 years ago

Hi, thank you for your feedback!

I wasn't sure if raising an error would be the right thing to do. I think we should definitely downgrade this message to a warning. I would also be okay with adding a (possibly hidden?) --ignore-missing-ignore-file flag.

Also, note that fd supported .ignore files up to v6.3.0. It has just recently been changed to .fdignore. The reasoning is that there might be files that you would not want to search through via rg/ag/.. but might still very well try to find with fd. So another option would be to create a dedicated .fdignore file (or symlink .ignore to .fdignore) in your repositories.

Yet another option would be to make it possible to re-enable .ignore files in fd - although I haven't thought about this in detail.

remexre commented 6 years ago

I'd be in favor of reenabling .ignore, possibly with a --dont-use-ignore-file or something similar.

sharkdp commented 6 years ago

I think we should move forward by downgrading the error to a warning. We have just recently introduced a print_error function that doesn't exit fd, so this should be really easy to implement.

sharkdp commented 6 years ago

I'd be in favor of reenabling .ignore, possibly with a --dont-use-ignore-file or something similar.

@remexre See https://github.com/sharkdp/fd/issues/156#issuecomment-427971026

sharkdp commented 5 years ago

Fixed in fd-7.2.0. .ignore has also been added again.