Skip to content

Ensure .git folder exists to prevent Windows Search indexing of entire scoop folder#6601

Open
29039 wants to merge 1 commit intoScoopInstaller:masterfrom
29039:patch-4
Open

Ensure .git folder exists to prevent Windows Search indexing of entire scoop folder#6601
29039 wants to merge 1 commit intoScoopInstaller:masterfrom
29039:patch-4

Conversation

@29039
Copy link
Copy Markdown

@29039 29039 commented Feb 13, 2026

Description

Fun fact that Windows search will automatically ignore and folder and subfolders if that folder has a folder called .git in it.

https://learn.microsoft.com/en-us/answers/questions/3790317/search-index-excludes-any-folder-with-a-git-subfol

This puts a .git folder in place to trick the Windows search into not indexing the whole scoop folder which contains heaps of program files which get in the way of searching for real documents, since scoop by default lives under the user profile this is usually indexed.

Motivation and Context

It was really annoying.

How Has This Been Tested?

Yep

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

Summary by CodeRabbit

  • Bug Fixes
    • Improved startup initialization to ensure proper directory structure is created during the boot process.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 13, 2026

Walkthrough

A startup operation has been added to ensure the .git directory exists within the Scoop repository, preventing Windows Search indexing issues. The change involves a single directory existence check with no impact on control flow or error handling.

Changes

Cohort / File(s) Summary
Git Directory Initialization
lib/core.ps1
Ensures the Scoop repository's .git directory exists on startup by adding an `ensure "$scoopdir.git"

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A git dir needs care, we ensure it's there,
No search indexing despair!
Three lines of grace, in the right place,
Scooping smoothly through cyberspace. 🥕

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding logic to ensure a .git folder exists to prevent Windows Search indexing of the scoop directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@lib/core.ps1`:
- Around line 1313-1314: Remove the call that creates a fake .git folder (the
ensure "$scoopdir\.git" | Out-Null line) because it breaks Git bucket
operations; instead, stop creating $scoopdir\.git and replace it with a non-Git
approach such as invoking a new helper (e.g., Add-DirectoryToSearchExclusion or
Set-DesktopIniExclusion) with $scoopdir as the argument to add $scoopdir to
Windows Search exclusions or apply a desktop.ini-based exclusion; update any
callers or documentation to reference the new helper and ensure the ensure
function is no longer used to create $scoopdir\.git.

Comment on lines +1313 to +1314
# Ensure .git folder exists to prevent Windows Search indexing
ensure "$scoopdir\.git" | Out-Null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the overall structure and find PowerShell files
ls -la lib/ | head -20

Repository: ScoopInstaller/Scoop

Length of output: 1262


🏁 Script executed:

# Search for git operations in scoop's PowerShell files
rg -n 'Invoke-Git|\.git|git ' lib/ --type=ps1 -A 2 -B 2 | head -100

Repository: ScoopInstaller/Scoop

Length of output: 91


🏁 Script executed:

# Check for bucket-related code and git operations
rg -n 'bucketsdir|buckets|bucket' lib/ --type=ps1 | head -50

Repository: ScoopInstaller/Scoop

Length of output: 91


🏁 Script executed:

# Look at the ensure function definition
sed -n '599,604p' lib/core.ps1

Repository: ScoopInstaller/Scoop

Length of output: 222


🏁 Script executed:

# Check the context around the new code (lines 1310-1320)
sed -n '1310,1320p' lib/core.ps1

Repository: ScoopInstaller/Scoop

Length of output: 245


🏁 Script executed:

# Search for git operations in all files in lib/
grep -rn 'Invoke-Git\|git ' lib/*.ps1 | head -50

Repository: ScoopInstaller/Scoop

Length of output: 1954


🏁 Script executed:

# Look at buckets.ps1 to understand bucket structure
cat lib/buckets.ps1

Repository: ScoopInstaller/Scoop

Length of output: 7452


🏁 Script executed:

# Search for where buckets directory is used
grep -n 'bucketsdir\|\$buckets' lib/*.ps1

Repository: ScoopInstaller/Scoop

Length of output: 866


🏁 Script executed:

# Check if scoop itself is a git repo and how it's structured
head -20 lib/core.ps1 | grep -i git

Repository: ScoopInstaller/Scoop

Length of output: 46


🏁 Script executed:

# Look for any existing git directory handling
grep -rn '\.git' lib/*.ps1

Repository: ScoopInstaller/Scoop

Length of output: 1447


🏁 Script executed:

# Look at the Invoke-Git function
sed -n '219,260p' lib/core.ps1

Repository: ScoopInstaller/Scoop

Length of output: 1328


🏁 Script executed:

# Confirm the git directory structure in buckets
grep -n 'Test-Path.*\.git' lib/buckets.ps1

Repository: ScoopInstaller/Scoop

Length of output: 235


Creating a fake .git directory will break scoop's bucket git operations.

Scoop stores buckets as git repositories under $scoopdir\buckets\<name>\.git and executes git commands directly in these directories (e.g., git config remote.origin.url, git log). When git runs in any bucket directory, it walks up the directory tree to find the repository root. A fake .git at $scoopdir (the parent directory) will be discovered first, causing git to misidentify the repository root and breaking bucket operations. Additionally, git-aware tools (VS Code, IDEs, etc.) will detect this fake .git as a corrupted repository.

Consider these alternatives to exclude the scoop directory from Windows Search:

  • Add $scoopdir to the Windows Search exclusion list programmatically (via registry or COM)
  • Use Windows desktop.ini with appropriate attributes
  • If .git is necessary, test thoroughly before deployment as it will directly impact bucket management
🧰 Tools
🪛 PSScriptAnalyzer (1.23.0)

[warning] Missing BOM encoding for non-ASCII encoded file 'core.ps1'

(PSUseBOMForUnicodeEncodedFile)

🤖 Prompt for AI Agents
In `@lib/core.ps1` around lines 1313 - 1314, Remove the call that creates a fake
.git folder (the ensure "$scoopdir\.git" | Out-Null line) because it breaks Git
bucket operations; instead, stop creating $scoopdir\.git and replace it with a
non-Git approach such as invoking a new helper (e.g.,
Add-DirectoryToSearchExclusion or Set-DesktopIniExclusion) with $scoopdir as the
argument to add $scoopdir to Windows Search exclusions or apply a
desktop.ini-based exclusion; update any callers or documentation to reference
the new helper and ensure the ensure function is no longer used to create
$scoopdir\.git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant