llvm-project/clang/tools/clang-format
Gergely Meszaros 3f801e07fa [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
2022-08-10 19:30:41 -07:00
..
fuzzer
CMakeLists.txt [clang][cmake] Use `GNUInstallDirs` to support custom installation dirs 2022-01-21 23:58:08 +00:00
ClangFormat.cpp [clang-format] Fix an assertion failure on -lines=0:n 2022-07-08 23:41:16 -07:00
clang-format-bbedit.applescript
clang-format-diff.py [clang-format] add support for cppm files 2021-12-14 14:55:38 +00:00
clang-format-sublime.py
clang-format-test.el
clang-format.el clang-format.el: Make clang-format work in indirect buffers. 2022-02-23 17:00:12 +01:00
clang-format.py [Format] Work around current vim bugs in clang-format.py 2020-04-15 20:11:14 +02:00
git-clang-format [clang-format] git-clang-format --staged should format the index 2022-08-10 19:30:41 -07:00