You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forward slash is special in .gitignoreformat, in that a trailing slash is stripped but means to only match directories, and the behavior of shell globs *? and [] is changed if / is present.
Now to the point: In fd, --ignore-file patterns don't match subdirs. To ignore a dir1/file1.txt,
dir1/file1.txt
doesn't work. To make it work, replace / with * :
dir1*file1.txt
The first pattern does work for fd when placed into a .gitignore.
More fail cases:
dir1/**
Is supposed to match files recursively, does nothing, works in .gitignore.
/dir1
Is supposed to match from the beginning of the pattern (so, sort of not what one would expect?), does nothing, works in .gitignore.
As a sub-case of the above, /* does not work (probably because / changes the behavior); /** and * do.
The text was updated successfully, but these errors were encountered:
If you add files via --ignore-file, the patterns are always matched relative to the current working directory (we should document this). So your dir1/file1.txt example should work if dir1 is in the current directory.
This behavior is inherited from the ignore crate, which is also used in ripgrep. I think the intention behind this is that there is no "repository root" for these custom ignore files, so using the current working directory seems like a reasonable choice. However, I agree that it is unexpected that dir1/file1.txt does not match another-folder/dir1/file1.txt.
I'm not sure, if there is an easy way to change this, though.
Interesting! The current working directory thing makes it so fd -t f "" repo/ expects the --ignore-file to say repo/dir1/file1.txt. In other words, current working directory means the directory fd was called from, not the target directory passed as an argument.
So the temporary workaround for scripting use would be to cd repo/ && fd -t f "" . instead.
This might be related to BurntSushi/ripgrep#278 and BurntSushi/ripgrep#829. Which are both bugs caused by the same behaviour in the ignore library, where it uses the current working directory places it shouldn't.
Forward slash is special in
.gitignore
format, in that a trailing slash is stripped but means to only match directories, and the behavior of shell globs*
?
and[]
is changed if/
is present.Now to the point: In fd,
--ignore-file
patterns don't match subdirs. To ignore adir1/file1.txt
,doesn't work. To make it work, replace
/
with*
:The first pattern does work for fd when placed into a
.gitignore
.More fail cases:
Is supposed to match files recursively, does nothing, works in
.gitignore
.Is supposed to match from the beginning of the pattern (so, sort of not what one would expect?), does nothing, works in
.gitignore
.As a sub-case of the above,
/*
does not work (probably because/
changes the behavior);/**
and*
do.The text was updated successfully, but these errors were encountered: