Closed mydeveloperday closed 11 months ago
@llvm/issue-subscribers-clang-format
I also like this feature. You peaked me to look at the gitignore documentation: https://git-scm.com/docs/gitignore I put only one gitignore file at the root. It took me while but apparently git supports several gitignore files in a repository. It would be odd if clang-format runs:
> git rev-parse --show-toplevel
but it would be helpful.
52975?
Good ideas keep rising to the top, just needs one of us to run with it...
I would love this feature. I have a repository containing both C++ source files and Matlab script files (.m) and I want to use pre-commit to enforce clang-format on those C++ source files. Currently clang-format seems to treat my Matlab script file as a Objective-C file (also .m) and completely mangles the format of the Matlab script.
I haven't found a straightforward way to configure clang-format to ignore specific files/directories.
Duplicate of #52975, which I'm working on.
I often use clang-format to check whole trees of source code and report clang-format violations with the -n option
This works well but from time to time I have generated files I want to exclude. Mostly these are files that are autogenerated for which I have little to no control of the output
Input Source -> Generator -> Output C++/C# code etc..
examples of such generators can be lex,yacc,bison,mild but also custom code generation phases
Sometimes these are Generators where I can place // clang-format off at the top but sometimes I simply cannot control the output enough.
There is also another use case, where for some reason on another (rightly or wrongly) clang-format simply isn't able to format the file well (either it takes a very long time, (lots of ifdef/endif) or it crash (rarer))
It would be nice in these cases to not have to contort my find command to exclude those files but to simply have a .clangformatignore file which would list the files locally that need to be ignored.
Initially, I would recommend just putting the files at the local directory level but I could see this being extended to behave similar to .gitignore with potential wildcards etc.. (subdirectories)
I think this could help greatly.