Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-format] git-clang-format --staged should format the index
When --staged (or --cached) use the index for formatting as well, not just for the line numbers to format. Without this change git-clang-format gets the changed line numbers based on the index, but then formats these lines on the working tree version of the file. This is a problem when the working tree and index differ. One common case would be (and is the motivation behind this patch) when applying the suggested changes git-clang-format --staged, then forgetting to add the applied changes. When git-clang-format --staged --diff is used in a pre-commit hook in this scenario, then the hook would allow committing the improperly formatted changes, as the file is correctly formatted in the work tree. Fixes #56797. Differential Revision: https://reviews.llvm.org/D130108
- Loading branch information
Showing
1 changed file
with
43 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters