Skip to content

Repository reference with a .. host resolves outside the repos cache and gets deleted #51576

Closed

Description

@nkootstra

Description

A git reference whose host is . or .. is accepted by Repository.parse, for example ..:docs or ssh://../docs. Repository.cachePath joins the host into the cache path, so ..:docs resolves to <data>/docs instead of a folder inside <data>/repos.

When that path exists and isn't a matching checkout, RepositoryCache.ensure removes it recursively before cloning. The clone then fails. So a references entry like this deletes whatever sits at that name in the opencode data directory.

OpenCode version

v2 branch (f0ed4f6)

Steps to reproduce

  1. Create a directory <data>/docs containing any file, where <data> is the opencode data directory.
  2. In a project's opencode.json, add "references": { "docs": { "repository": "..:docs" } }.
  3. Start opencode in that project.
  4. <data>/docs has been removed, and the log shows a failed clone for the reference.

Operating System

macOS 26

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions