From cf7cca96897d392fcc9bef85c534261afb372d30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 8 Sep 2023 01:16:33 -0700 Subject: [PATCH] [clang-format] Fix a serious bug in git-clang-format When applying format changes to staged files, git-clang-format erroneously checks out all files in the index and thus may overwrite unstaged changes. Fixes #65643. --- clang/tools/clang-format/git-clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format index c0b99b8220323..0f33b5339ec14 100755 --- a/clang/tools/clang-format/git-clang-format +++ b/clang/tools/clang-format/git-clang-format @@ -606,7 +606,7 @@ def apply_changes(old_tree, new_tree, force=False, patch_mode=False): index_tree = old_tree else: with temporary_index_file(new_tree): - run('git', 'checkout-index', '-a', '-f') + run('git', 'checkout-index', '-f', '--', *changed_files) return changed_files