Skip to content

[BUG]: glob tool does not traverse into git submodules, making file discovery unreliable in repos with submodules #33736

Description

@michael-conrad

Description

The glob tool does not traverse into git submodule directories. When a repository contains git submodules (e.g., .opencode/ as a submodule, or any dependency vendored as a submodule), glob("**/*.md") or similar patterns return zero results from within submodule directories. This makes the glob tool harmful for AI agent use in repos with submodules or subrepos — the agent receives an incomplete file listing and makes incorrect assumptions about the codebase.

Root Cause

The glob tool uses ripgrep under the hood (packages/core/src/ripgrep.ts). The glob() method invokes ripgrep with:

rg --no-config --files --glob=<pattern> --glob=!**/.git/** .

ripgrep by default respects .gitignore patterns. The --no-config flag only disables .ripgreprc config files — it does NOT disable .gitignore respect. There is no --no-ignore or --no-ignore-local flag in the invocation.

This causes two problems for submodules:

  1. Submodule paths in parent .gitignore: Many projects list submodule paths in the parent repo's .gitignore (e.g., .opencode/ is commonly gitignored when it's a submodule). ripgrep respects this and skips the entire directory.

  2. Submodule's own .gitignore: Even if the submodule directory is not in the parent .gitignore, the submodule has its own .gitignore that ripgrep respects, potentially excluding files the agent needs to find.

The --glob=!**/.git/** exclusion also interacts poorly with submodules — submodules have a .git file (not directory) pointing to the parent's .git/modules/<name>, but the submodule's actual content directories are legitimate files the agent needs to discover.

Steps to reproduce

  1. Create a repo with a git submodule:

    mkdir /tmp/submod-test && cd /tmp/submod-test
    git init
    git submodule add https://github.com/example/some-submodule vendor/sub
    echo "*.md" > vendor/sub/.gitignore
    
  2. Create a markdown file in the submodule:

    echo "# Readme" > vendor/sub/README.md
    
  3. Run glob from the parent repo:

    glob("**/*.md")
    
  4. Observe: vendor/sub/README.md is NOT returned, even though it exists on disk.

Expected behavior

The glob tool should traverse into git submodule directories and return files within them, since those files are part of the working tree and relevant to AI agent codebase analysis.

Suggested fix

Add --no-ignore (or --no-ignore-local) to the ripgrep invocation in packages/core/src/ripgrep.ts for the glob() method. This makes ripgrep ignore .gitignore rules and report all files on disk. The --glob=!**/.git/** exclusion already prevents .git internals from being listed.

Alternatively, add --no-ignore-parent to prevent parent .gitignore from blocking submodule traversal while still respecting the submodule's own .gitignore.

Environment

  • OpenCode: any version using ripgrep-based glob
  • OS: all
  • Terminal: all

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions