<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65643>65643</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
git-clang-format removes unstaged files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format,
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
adorostkar
</td>
</tr>
</table>
<pre>
Hi all,
While running `git clang-format` I have come to a scenario where the script doesn't work as expected.
## How to reproduce
1. Have staged changes in file `A` which require reformatting
2. Have staged changes in file `B` which don’t require reformatting
3. Have unstaged changes in file `B` which are actual changes (let’s say new function)
4. Run `git clang-format --staged`
**The effect**:
- Unstaged changes in `A` which is the format change.
- New changes in file `B` are deleted. <- this is the wrong behavior
## Additional info
2. The version of the `clang-format` and the script is 16.0.6
3. I am running this on MacOs
If the changes that need formatting are staged in `B` and anything else is not staged in `B` then the `git-clang-format` refuses to format and prints a message saying that there are unstaged changes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2P8jYQ_jXOZZTIcUIghxzY3aLdQ1upatXz4Exi93VsajvQ_feVE9iv0vaVEAgYPx_zPA6GoEdL1LHNA9s8ZThH5XyHvfMuxG_os6PrX7tnDWgME4_A-BPj-9-VNgR-tlbbEVjDRx1BGrRjPjg_YWQNhxdQeCaQbiKIDhCCJIteO7go8gRREQTp9SlC7yhYJrYRLs5_AwxAf51IRuqLlfD6LiomKnh2lwTo6eRdP0ta_ywLeE58IeJIPUiFdqQA2sKQxLKG75Oqi9JSgac_Z-0JPK16o7bjCiP-F-bhHaZ3lv0g2I6zto3_AVpdQWf7XbDoCVDGGc3bIBM7Q_GNLEDAV7B0gWG2MmpnmWhXrrqAX2Z7LxTI85WeNfzzWtPrV0VAw0Ayrt9ZtQeAa-A5_HZH-ued6rBEeuVax4rb8Z_o8q-mk92eDKW4gVWPOUSlww3v4p0d4UgKz9r5O3XY971OG0AD2g7u44QoINk6kw_aWXDDgsga_rWraPuPfdQByqbgRfMW3wvg9Fb4RZ6z8CPKn8NHvpeV4GY0KoxgiXp4L8Ti9rrKdYUPNwFoX6NKI2QCJQ3WxTujUZG9-Rh1zL968TTMIbG7WxYJ_OS1jQEQJgoBR0oFWr1gTGipcv6fDb0GmPVd1bdVixl1ZdPWJd-W2yZTXdXUmx3yRsiqrHa0FXJoa6rrcsu3m00rMt0JLirepgPltq4L3GGJshnqcnes6rphNacJtSmMOU-F82OmQ5ipazZNXWUGj2TC8ngS4pNTIZh4ZEKkS7CcSL9snjLfJaD8OI-B1dzoEMM7dNTRUPd1a-BpcmcK7-5TP0M2e9OpGE-BVXsmDkwcRh3VfCykm5g4JNTrR37y7o_l6hwWLYGJw2Lg7wAAAP__RPm4IQ">