[clang] 743659b - [clang-format] Fix a serious bug in git-clang-format (#65723)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 15:05:26 PDT 2023


Author: Owen Pan
Date: 2023-09-08T15:05:22-07:00
New Revision: 743659be87daff4cc8861c525d4a6229d787ef14

URL: https://github.com/llvm/llvm-project/commit/743659be87daff4cc8861c525d4a6229d787ef14
DIFF: https://github.com/llvm/llvm-project/commit/743659be87daff4cc8861c525d4a6229d787ef14.diff

LOG: [clang-format] Fix a serious bug in git-clang-format (#65723)

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.

Added: 
    

Modified: 
    clang/tools/clang-format/git-clang-format

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format
index c0b99b82203234c..0f33b5339ec14cb 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
 
 


        


More information about the cfe-commits mailing list