Skip to content

Commit cf7cca9

Browse files
committed
[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.
1 parent e94e790 commit cf7cca9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/tools/clang-format/git-clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
606606
index_tree = old_tree
607607
else:
608608
with temporary_index_file(new_tree):
609-
run('git', 'checkout-index', '-a', '-f')
609+
run('git', 'checkout-index', '-f', '--', *changed_files)
610610
return changed_files
611611

612612

0 commit comments

Comments
 (0)