-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Add .gitignore file in .cache/clangd/index #170003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clangd Author: Duncan Ogilvie (mrexodia) ChangesThis solves a common issue where users have to manually add the Full diff: https://github.com/llvm/llvm-project/pull/170003.diff 1 Files Affected:
diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
index d887b09482a95..1dff0b55f82cd 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());
+ } else {
+ // 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());
+ }
+ }
}
}
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
7c929d3 to
7c74cf4
Compare
|
This solves a common issue where users have to manually add the
.cache/clangd/index/folder to their.gitignore. I got this idea from ruff, which creates.ruff_cache/.gitignoreand it would greatly improve the user experience for everyone without requiring per-computer configurations and without any significant cost.