Closed Dangeroustuber closed 3 weeks ago
This may be fixed by #102629.
Aha, okey. So i can try this again when the first 19 offical release is out?
edit: Also is this an issue with clang-format or git-clang-format?
Aha, okey. So i can try this again when the first 19 offical release is out?
Yep.
edit: Also is this an issue with clang-format or git-clang-format?
I would say git-clang-format, which must be updated to skip files ignored by clang-format when .clang-format-ignore
was added.
Duplicate of #102459.
Hello, i am unable to make git-clang-format not format my C# files and for it to then only format my C++ that i stage in Git. clang-format is installed via pip and i am on windows. I want to use this for my precommit hook in a mixed C++ and C# project but running the command will format my C# files in a wrong manner.
clang format version:
clang-format version 18.1.8
Reproduce:
one line linux command for the folders and files:
mkdir test-clang-format && cd test-clang-format && git init && touch test.cpp test.cs && mkdir src && touch src/test2.cpp src/test2.cs && echo '#include <iostream> int main() { std::cout << "Hello from test.cpp"; }' > test.cpp && echo 'using System; class Program { static void Main() { Console.WriteLine("Hello test.cs"); } }' > test.cs && echo '#include <iostream> int main() { std::cout << "Hello src/test2.cpp"; }' > src/test2.cpp && echo 'using System; class Program { static void Main() { Console.WriteLine("Hello test2.cs"); } }' > src/test2.cs
.clang format:
.clang-format-ignore:
.\git-clang-format.exe --binary .\clang-format.exe -v --staged
image of test setup:
What do i expect:
In this particular case it should not format any of the files seeing as we tell it to ignore the src folder.
Other things i've tried: I have also tried using
*.cs
in the ignore file and it still does the same thing. I also tried not having a src folder and just having the .cpp file and .cs file in the same directory as the ignore file and then using the "*" pattern in the ignore file. But this produces the same result.Help:
Either my patterns are wrong for the ignore file or this ignore file does not seem to work for me at all. It feels like it's completely ignored itself. The pattern for the reproduce example i get from this quote in the 18.1.8 docs for clang.
https://releases.llvm.org/18.1.8/tools/clang/docs/ClangFormat.html
"To match all files in a directory, use e.g. foo/bar/*"