https://github.com/mrexodia updated 
https://github.com/llvm/llvm-project/pull/170003

>From cfcbfbafda0e37a4cb54456024cec1035d071c6c Mon Sep 17 00:00:00 2001
From: Duncan Ogilvie <[email protected]>
Date: Sat, 29 Nov 2025 17:07:37 +0100
Subject: [PATCH] Add .gitignore file in .cache/clangd/index

---
 .../clangd/index/BackgroundIndexStorage.cpp        | 14 ++++++++++++++
 clang-tools-extra/docs/ReleaseNotes.rst            |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp 
b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
index d887b09482a95..a09987093024a 100644
--- a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -45,6 +45,20 @@ class DiskBackedIndexStorage : public BackgroundIndexStorage 
{
     if (EC != OK) {
       elog("Failed to create directory {0} for index storage: {1}",
            DiskShardRoot, EC.message());
+      return;
+    }
+    // Create a .gitignore file in the directory to ignore all files.
+    llvm::SmallString<128> GitignorePath(DiskShardRoot);
+    llvm::sys::path::append(GitignorePath, ".gitignore");
+    if (!llvm::sys::fs::exists(GitignorePath)) {
+      llvm::raw_fd_ostream GitignoreFile(GitignorePath, EC,
+                                         llvm::sys::fs::OF_None);
+      if (EC == OK) {
+        GitignoreFile << "*\n";
+      } else {
+        elog("Failed to create .gitignore in {0}: {1}", DiskShardRoot,
+             EC.message());
+      }
     }
   }
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a6f80e3721db1..b1a3c7dd9ba07 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -126,6 +126,8 @@ Objective-C
 Miscellaneous
 ^^^^^^^^^^^^^
 
+- Add wildcard ``.gitignore`` file to the clangd index directory.
+
 Improvements to clang-doc
 -------------------------
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to