Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-format continues to recurse into directories listed in .clang-format-ignore #114969

Open
synco opened this issue Nov 5, 2024 · 4 comments

Comments

@synco
Copy link

synco commented Nov 5, 2024

Create a directory with a sub-directory. If we add the first directory into the ignore list, clang-format will still recurse into the sub-directory which is not expected.
Reasoning why it's not desirable, if you add a temporary build directory into the ignore list, clang-format will still format all files in sub-directories of the build directory.

Version: Ubuntu clang-format version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1-exp1-20240731145000.144)

Recreate the directory structure, files, and execute clang-format:
mkdir -p level1/level2 && touch foo.c level1/bar.c level1/level2/bang.c && tree && echo 'level1/*' > .clang-format-ignore && shopt -s globstar && clang-format --verbose **/*
Result, it correctly ignores the file in level1 (bar.c), however continues to recurse into level2 (bang.c) which is not expected.

@owenca
Copy link
Contributor

owenca commented Nov 6, 2024

Create a directory with a sub-directory. If we add the first directory into the ignore list, clang-format will still recurse into the sub-directory which is not expected.

This is expected per the documentation.

Reasoning why it's not desirable, if you add a temporary build directory into the ignore list, clang-format will still format all files in sub-directories of the build directory.

We have DisableFormat for that.

@synco
Copy link
Author

synco commented Nov 6, 2024 via email

@owenca
Copy link
Contributor

owenca commented Nov 6, 2024

Where in the documentation? - as the behaviour I'm observing is not explicitly described. Using the DisableFormat option in a .clang-format file is less than ideal for the build directory example as the file needs to be generated in the build process.

The linked documentation above specifically mentions and links to POSIX 2.13. It doesn't say that globstar is supported.

@synco
Copy link
Author

synco commented Nov 6, 2024

It's not just globstar, as same unexpected behaviour with say find, eg:
find . -type f ( -name ".c" -o -name ".h" ) -exec clang-format -i --verbose {} +

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants