Open ameerj opened 1 month ago
This is expected behavior and works as documented.
Looking into the source code, it seems that this behavior is from the
matchFilePath
function, which is based on the POSIXfnmatch()
function
See the comments after that: https://github.com/llvm/llvm-project/blob/d4d38bcc3931d28d8b97d055258e27772119d0fe/clang/lib/Format/MatchFilePath.cpp#L22-L23
The
fnmatch()
function matches these cases: https://godbolt.org/z/6qxYW41Yv
Not if FNM_PATHNAME
is set: https://godbolt.org/z/Gc8z3KceE
Would you be open to supporting the double asterisk **
to match directory separators?
As used in gitignore
Would you be open to supporting the double asterisk
**
to match directory separators?As used in gitignore
See https://github.com/llvm/llvm-project/pull/110560#discussion_r1816084375.
When using a
.clang-format-ignore
file, a*
wildcard is expected to match a directory separator. For example, a line containing*g_*
should match any file in the current directory and all subdirectories that match the pattern*g_*
Currently, the
*
does not match the path separator. So a*g_*
in the .clang-format-ignore file will only match this pattern for the current working directory. There does not seem to be a way to match the pattern for the current dir and subdirs.Looking into the source code, it seems that this behavior is from the
matchFilePath
function, which is based on the POSIXfnmatch()
function https://github.com/llvm/llvm-project/blob/d4d38bcc3931d28d8b97d055258e27772119d0fe/clang/lib/Format/MatchFilePath.cpp#L10-L11All of the following tests added to
MatchFilePathTest.cpp
fail:The
fnmatch()
function matches these cases: https://godbolt.org/z/6qxYW41Yv@owenca is this expected behavior?
P.S. I am seeing this behavior on Windows/MSVC, not sure if this affects all environments or is Windows specific.