[all-commits] [llvm/llvm-project] 3f801e: [clang-format] git-clang-format --staged should fo...
Owen via All-commits
all-commits at lists.llvm.org
Wed Aug 10 19:30:59 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3f801e07fa82055de98278d3ebeaade68fbacee9
https://github.com/llvm/llvm-project/commit/3f801e07fa82055de98278d3ebeaade68fbacee9
Author: Gergely Meszaros <meszaros.gergely97 at gmail.com>
Date: 2022-08-10 (Wed, 10 Aug 2022)
Changed paths:
M clang/tools/clang-format/git-clang-format
Log Message:
-----------
[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
More information about the All-commits
mailing list