https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/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.

>From eb3fc8f7c9f61650d458ffbd2952fa97e7c2e28d Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpi...@gmail.com>
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 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
 
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to