<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108337>108337</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] does not respect .clang-format-ignore (version 18.1.8)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Dangeroustuber
</td>
</tr>
</table>
<pre>
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:**
1. Take a git-clang-format.exe and clang-format.exe and put it in a folder.
2. Run git init in the folder
3. Add a folder called src, with a file called test.cpp and a file called test.cs. Add some code into each
4. git add the src folder or files individually
5. Add a .clang-format and a .clang-format-ignore that looks like this:
.clang format:
```
---
UseTab: ForContinuationAndIndentation
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
IndentCaseLabels: false
ColumnLimit: 180
SortIncludes: false
```
.clang-format-ignore:
```
src/*
```
6. Run the command `.\git-clang-format.exe --binary .\clang-format.exe -v --staged`
7. Output that i get:
```
Running clang-format on the following files:
src/test2.cpp
src/test2.cs
warning: in the working copy of 'src/test2.cpp', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/test2.cs', LF will be replaced by CRLF the next time Git touches it
old tree: f505a0103b68f71f76b044b83b94748d61361505
new tree: eda0caff2420a96e5c158d0ac738a3bbbf674107
changed files:
src/test2.cpp
src/test2.cs
```
**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 20.0.0 docs for clang.
https://clang.llvm.org/docs/ClangFormat.html#clang-format-ignore
"To match all files in a directory, use e.g. foo/bar/*"
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV19vqzoS_zTkZRQEBgJ5yEPabvZWqnSkc7q6zwYPwbfGztomab79amyak6TZlXa1UpWCPf_nN3_gzsm9Rtwk1VNSvSz45AdjNy9c79GayfmpRbtojThv_kClTMKeQQIfYdK8VQjewMg_EPbSLzvF9X7ZGztyDwnbJmyrjY8PMB-PZ3hOWAG9VOiAa0EXID0J8gNqMFqdb4mfEvYEfuAeJDjP9whSw9-lT5PsJcm2N1qlA6md50qhgKPkcJCHoCXYbDScpBbm5FJ4hRPXQe3kEPwgXbBkPMPBYmfGUXoYjPkgZRxG-YniYgwJDF4crPkLOw_t5AHspLXUe3IDSABRnaRSj10PYk_W6D2MXGu0szvzbwhacO2L_YjWSaOTYr6cCVfZTQBmKsibNE-bZJV9l_oTD9aIqcN7UeE3T-GdEsq_pTTFTwyuPzw8TJ7SGNzqjRIXh1gKPydN0kDqSEERijSRpEhhK8SFEbqYP2c7gttJ-oHupMKvG4_Op90hpvbRlYsSnRkpF4Ig4w0g74aosUyDQVyIYIyz3ZduYy8JEvIoxcSVOkem6svM9Cbk0Yabs6Xca2MxolYZ8-FAyY8IM4r6VbzT6yQnxRYueZ3_wutyuYwP_3D4zlui2xn7bLSXeuJeGr3V4lUL1D68ReJ48KcUfiCOMp6-8_b-6Mki_3jC3lh8srxDMhK2So18lrRVypx-Dcb61_6X5x5H1N790NtfUu8VvklNaIKeK4f3HLtJd2TTd_JXrejpytZn7vCNt6jcnbhno6ZRv8lRhiDlzRyYX2SS7tQk8J7lLoTX4b5N0--M3HIE_O2uS-27vFVE93XNJ6ssTarnh-WzXLZSc3sGovh-e4Tl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