junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
63.89k stars 2.37k forks source link

.gitignore pattern is not interpreted correctly #3652

Closed osa1 closed 6 months ago

osa1 commented 6 months ago

Info

Problem / Steps to reproduce

The .gitignore pattern **/foo is not interpreted by fzf correctly. For example, in this repo https://github.com/zed-industries/zed, .gitignore has this line: **/target. However if I to ctrl + t and run the fzf from the master branch (1833670), the target directory is indexed.

Relevant git documentation says: (https://git-scm.com/docs/gitignore#_pattern_format) (emphasis mine)

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".

fzf does not interpret **/foo the same way as foo.

junegunn commented 6 months ago

fzf doesn't know anything about .gitignore. If you want CTRL-T binding to respect .gitignore files, you need to install an external program such as fd or rg that understands them and set FZF_CTRL_T_COMMAND.

See https://github.com/junegunn/fzf?tab=readme-ov-file#respecting-gitignore