Skip to content

Git marketplace refresh clones the whole repository even when the ref has not moved #8127

Description

@afn

Summary

Refreshing a git: marketplace — manually, on bb marketplace add, and on every periodic refresh — runs a full git clone of the marketplace repository, checks out the whole tree, and then deletes .git. It does this even when the ref still points at the commit bb already has stored. For a marketplace monorepo with a long history, every refresh takes well over a minute to produce a catalog that bb could have read in under a second. I expected a refresh to check whether the ref moved and, when it did, to fetch only the catalog and its icons.

#7910 / #7911 fixed the same clone for plugin installs; the marketplace refresh path in marketplace-source.ts was not touched.

Versions and environment

  • bb built from main at d73dac8c906f34b7e722f8446b10958ad8e278dd, macOS 27.2.1, git 2.56.1
  • Reproduced through createPluginCatalogService against a real git marketplace; no provider involved

Steps to reproduce

  1. Register a marketplace whose source is a git monorepo with a long history, e.g. bb marketplace add git:github.com/<org>/<marketplace-monorepo>@main.
  2. time bb marketplace refresh <name> without pushing anything to the repository.
  3. While it runs, ps aux | grep 'git -c core.hooksPath=/dev/null clone' and du -sh <dataDir>/marketplaces/staging/*/.git.

Fixture-level repro: after addMarketplace of a local git fixture, delete the repository's loose objects so that git ls-remote still answers but any clone or fetch fails. refreshMarketplaces fails on main even though nothing changed; with the fix it succeeds from the stored catalog.

Expected vs actual

Measured through createPluginCatalogService against the marketplace monorepo that prompted this (89 entries, 39 icons, 2,967 commits, 826 MiB pack), same machine and network:

Step main with ls-remote + blobless sparse fetch
addMarketplace (ref moved) 87.05 s 3.54 s
refreshMarketplaces (ref unchanged) 87.72 s 0.75 s

Raw git timings against the same repository:

git ls-remote <url> main                                        0.96 s
git clone --quiet --no-checkout <url>   (what refresh does)   1m24.5 s   826 MiB pack, 85,650 objects
git checkout --detach origin/main                                0.9 s   157 MB working tree
git clone --depth 1 --no-checkout <url>                          8.4 s    81 MB
git clone --filter=blob:none --no-checkout <url>                 1.7 s   7.5 MB

What the refresh actually reads from that checkout is marketplace.json (346 KB) and icons/ (152 KB): fetchMarketplaceIcons reads local icons from disk, screenshots are only resolved to URLs, and .git is deleted right after checkout. The other 112 MB of plugins/, 31 MB of screenshots/, 12 MB of media/ and ~800 MB of history (including deleted multi-MB video and dataset blobs) are downloaded and thrown away.

Expected: a refresh costs one ls-remote when the ref has not moved, and a fetch proportional to the catalog when it has.

Evidence

  • materializeGit on main:
    async function materializeGit(
    source: Extract<MarketplaceSource, { kind: "git" }>,
    stagingDir: string,
    warn: ((message: string) => void) | undefined,
    ): Promise<MaterializedMarketplace> {
    await mkdir(stagingDir, { recursive: true });
    const checkout = join(stagingDir, randomUUID());
    const dispose = () => rm(checkout, { recursive: true, force: true });
    try {
    await runInstallCommand("git", [
    ...GIT_CLONE_ARGS,
    "clone",
    "--quiet",
    "--no-checkout",
    source.url,
    checkout,
    ]);
    const commit = await runInstallCommand("git", [
    "-C",
    checkout,
    "rev-parse",
    "--verify",
    "--end-of-options",
    `${source.ref}^{commit}`,
    ]).catch(() =>
    runInstallCommand("git", [
    "-C",
    checkout,
    "rev-parse",
    "--verify",
    "--end-of-options",
    `refs/remotes/origin/${source.ref}^{commit}`,
    ]),
    );
    await runInstallCommand("git", [
    ...GIT_CLONE_ARGS,
    "-C",
    checkout,
    "checkout",
    "--quiet",
    "--detach",
    commit,
    ]);
    await rm(join(checkout, ".git"), { recursive: true, force: true });
    return await materializeLocal(
    await gitMarketplaceRoot(checkout, source.subdirectory),
    commit,
    dispose,
    warn,
    );
    } catch (error) {
    await dispose();
    throw error;
    }
    }
    — clone --no-checkout with no --depth/--filter, rev-parse <ref>, checkout --detach, rm .git. The stored sourceGitCommit is never consulted.
  • Both the refresh and the add path call it after wiping the staging dir:
    if (source.kind === "git") await prepareMarketplaceStaging();
    and
    if (source.kind === "git") await prepareMarketplaceStaging();
    .
  • refreshMarketplaces refreshes marketplaces sequentially, so one slow git marketplace delays every other one:
    async function refreshMarketplaces(args?: {
    name?: string;
    attemptedAt?: number;
    }): Promise<PluginMarketplaceRefreshResult[]> {
    const attemptedAt = args?.attemptedAt ?? Date.now();
    if (args?.name !== undefined) {
    requireEnabledRow(args.name);
    return [await refreshOne(args.name, attemptedAt)];
    }
    const results: PluginMarketplaceRefreshResult[] = [];
    for (const row of enabledMarketplaces()) {
    results.push(await refreshOne(row.name, attemptedAt));
    }
    return results;
    .
  • resolveGitRef in update-resolver.ts already resolves a branch, tag or SHA to a commit with one ls-remote, and is what plugin installs use.
  • Timings measured with performance.now() around the service calls and time around the raw git commands.

What you ruled out

Suggested priority and effort

Hits every user of a git marketplace on every periodic refresh, and makes bb marketplace add / first-run setup of such a marketplace take minutes; no workaround short of mirroring the catalog to an https URL. Contained change in materializeGit: resolveGitRef first and reuse the stored catalog when the commit matches; otherwise init + fetch --depth 1 --filter=blob:none <sha> + cone-mode sparse-checkout of the root (plus the icon directories the manifest names) or of the selected subdirectory, falling back to the existing full clone when the ref cannot be resolved by ls-remote or the server refuses the fetch. Fix with tests in the linked PR.

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

  4. added a commit that references this issue on Nov 25, 2026
    3ae1d58
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