[llvm-branch-commits] [clang] aeb83c3 - [clang-format] Fix a serious bug in git-clang-format (#65723)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 16 23:21:58 PDT 2023


Author: Owen Pan
Date: 2023-10-17T08:18:23+02:00
New Revision: aeb83c3783a617d862f997b92fd25ff3d0803b96

URL: https://github.com/llvm/llvm-project/commit/aeb83c3783a617d862f997b92fd25ff3d0803b96
DIFF: https://github.com/llvm/llvm-project/commit/aeb83c3783a617d862f997b92fd25ff3d0803b96.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.

(cherry picked from commit 743659be87daff4cc8861c525d4a6229d787ef14)

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 695545d9e325522..5b214152e8399b6 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -605,7 +605,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 llvm-branch-commits mailing list