Skip to content

Plugin git installs check out the whole repository tree when only one subdirectory is selected #8115

Description

@afn

Summary

After #7910 / #7911, a git: plugin install fetches only the resolved commit, but it still checks out — and, where the server supports partial clone, downloads — that commit's entire tree, even when the install selects a single plugin out of a monorepo (--subdirectory <path> or a .bb/plugins.json collection entry via --plugin <name>). For a marketplace monorepo that holds many plugins and other content, writing the whole working tree now dominates install time. I expected bb to materialize only the directories the selected plugin needs.

Versions and environment

Steps to reproduce

  1. Register a marketplace whose source is a git monorepo with many plugins and sizeable unrelated content.
  2. time bb plugin install <plugin>@<marketplace> for a plugin that lives in one subdirectory of that repository.
  3. While the install job runs, watch <dataDir>/plugins/cache/git/<host>/<org>/<repo>/<sha>.staging/ fill with every directory of the commit, not just the selected plugin's.

Fixture-level repro: a repository with .bb/plugins.json listing plugins/alpha and plugins/beta plus an unrelated/ directory; after bb plugin install git:<repo>@main --plugin alpha, unrelated/ and plugins/beta are present in the shared checkout under the data dir.

Expected vs actual

I benchmarked plugin installation time with two plugins from our marketplace monorepo, on the same machine and network, with main as of #7911 ("shallow clone") versus a build with a sparse checkout of the selected directory (prototype in #7917):

Command Shallow clone only (#7911) Shallow clone + sparse checkout Speed-up
time bb plugin install plugin1@my-marketplace 1:26.62 total (0.56s user, 0.08s system) 10.409s total (0.24s user, 0.04s system) ~8.3×
time bb plugin install plugin2@my-marketplace 23.005s total (0.27s user, 0.04s system) 7.434s total (0.23s user, 0.04s system) ~3.1×

Raw time output:

# plugin1, shallow clone only
0.56s user 0.08s system 0% cpu 1:26.62 total
# plugin1, sparse checkout
0.24s user 0.04s system 2% cpu 10.409 total

# plugin2, shallow clone only
0.27s user 0.04s system 1% cpu 23.005 total
# plugin2, sparse checkout
0.23s user 0.04s system 3% cpu 7.434 total

The near-zero CPU share in every row shows the CLI is waiting on the server-side install job; the difference is the server's git checkout.

Expected: the install materializes the selected plugin's directory (plus repository-root files and .bb/ for a collection entry) and nothing else, so install time is proportional to the plugin, not the monorepo.

Evidence

  • cloneGitCommit on main:
    async function fetchGitCommitShallow(
    url: string,
    stagingDir: string,
    commit: string,
    notFoundHint: string | undefined,
    ): Promise<boolean> {
    await runInstallCommand("git", ["init", "--quiet", stagingDir], {
    notFoundHint,
    });
    try {
    await runInstallCommand("git", [
    "-C",
    stagingDir,
    "fetch",
    "--quiet",
    "--depth",
    "1",
    "--no-tags",
    url,
    commit,
    ]);
    await runInstallCommand("git", [
    "-C",
    stagingDir,
    "checkout",
    "--quiet",
    "--detach",
    "FETCH_HEAD",
    ]);
    return true;
    } catch (error) {
    if (error instanceof PluginInstallCancelledError) throw error;
    await rm(stagingDir, { recursive: true, force: true });
    return false;
    }
    }
    async function cloneGitCommit(
    url: string,
    stagingDir: string,
    commit: string,
    notFoundHint?: string,
    ): Promise<void> {
    const shallow = await fetchGitCommitShallow(
    url,
    stagingDir,
    commit,
    notFoundHint,
    );
    if (!shallow) {
    await runInstallCommand("git", ["clone", "--quiet", url, stagingDir], {
    notFoundHint,
    });
    await runInstallCommand("git", [
    "-C",
    stagingDir,
    "checkout",
    "--quiet",
    "--detach",
    commit,
    ]);
    }
    const checkedOutCommit = await runInstallCommand("git", [
    "-C",
    stagingDir,
    "rev-parse",
    "HEAD",
    ]);
    if (!checkedOutCommit.startsWith(commit)) {
    throw new Error(
    `git resolved ${commit}, but checked out ${checkedOutCommit}`,
    );
    }
    await rm(join(stagingDir, ".git"), { recursive: true, force: true });
    }
    — fetch --depth 1 then checkout --detach FETCH_HEAD with no --filter and no sparse-checkout, then rm .git.
  • The subdirectory is only chosen after the full checkout:
    const stagedSubdirectory = await resolveSelectedSubdirectory({
    checkoutDir: stagingDir,
    selection,
    sourceLabel: source,
    });
    (resolveSelectedSubdirectory reads the staged tree, then pluginRootDir picks the folder).
  • Measured with time around bb plugin install as shown above.

What you ruled out

Suggested priority and effort

Hits every user installing from a marketplace monorepo; no workaround short of publishing each plugin on npm. Contained change in cloneGitCommit: cone-mode git sparse-checkout of the selected directory (.bb first for a collection entry, then add the manifest's directory), --filter=blob:none from a named remote, and a fallback to the whole tree for symlinked plugin directories, which cone mode refuses. Prototype with tests: #7917.

AGENT GENERATED

Activity

  1. added theissue type on Nov 24, 2026
  2. added
    plugins
    confirmed-repro
    on Nov 24, 2026
  3. bb-slop-cop commented on Nov 24, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium · labels: plugins, perf.
    • Report: Reproduction and root cause.
    • Verdict: REPRODUCED · Confidence: high · Reproduction label: confirmed-repro.
    • Root cause: The server checks out the full commit before resolving the selected plugin directory, leaving sibling plugins and unrelated files in the managed checkout.
    • Verification: Real plugin-service regression tests fail for both collection-entry and explicit-subdirectory selection in two clean checkouts of trusted origin/main at af25b0b5a6.
    • No new PR: Open PR Check out only the selected plugin's directories for git installs #8116 already links this issue; a second fix PR would duplicate active work.

    AGENT GENERATED

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproperfplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions