Skip to content

bb marketplace add fails for a git branch other than the default branch #5373

Closed

Description

@maxsumrall

Summary

bb marketplace add git:<url>@<branch> fails when <branch> is not the repository's default branch. git refuses the checkout with '--detach' cannot be used with '-b/-B/--orphan'. I expected bb to read the catalog from the branch I named.

Versions and environment

  • bb 0.45.0 (desktop app), macOS 27.0.1, git 2.48.1
  • isolated data dir, BB_TELEMETRY=false
  • main at 4b12265 runs the same git commands. I did not test 0.46.0.

Steps to reproduce

octocat/Hello-World is public, has the default branch master and a second branch test, and has no marketplace.json. A working bb gets past the checkout and then reports the missing manifest.

  1. bb marketplace add git:https://github.com/octocat/Hello-World.git@test
  2. bb marketplace add git:https://github.com/octocat/Hello-World.git@origin/test
  3. bb marketplace add git:https://github.com/octocat/Hello-World.git@master

git alone reproduces it:

cd "$(mktemp -d)"
git init -q -b main src && git -C src commit -q --allow-empty -m one && git -C src branch feature
git clone -q --no-checkout src co
git -C co checkout --detach feature

Expected vs actual

$ bb marketplace add git:https://github.com/octocat/Hello-World.git@test
Error: HTTP 422: git -c failed (exit 128): fatal: '--detach' cannot be used with '-b/-B/--orphan'
$ bb marketplace add git:https://github.com/octocat/Hello-World.git@origin/test
Error: HTTP 422: ENOENT: no such file or directory, realpath '<data dir>/marketplaces/staging/<uuid>/marketplace.json'
$ bb marketplace add git:https://github.com/octocat/Hello-World.git@master
Error: HTTP 422: ENOENT: no such file or directory, realpath '<data dir>/marketplaces/staging/<uuid>/marketplace.json'

Expected: step 1 behaves like steps 2 and 3. bb checks out test and then reports the missing manifest.

Evidence

bb clones with --no-checkout and then runs git checkout --detach <ref>:

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,
]);
await runInstallCommand("git", [
...GIT_CLONE_ARGS,
"-C",
checkout,
"checkout",
"--quiet",
"--detach",
source.ref,
]);
const commit = await runInstallCommand("git", [
"-C",
checkout,
"rev-parse",
"HEAD",
]);
await rm(join(checkout, ".git"), { recursive: true, force: true });
return await materializeLocal(checkout, commit, dispose, warn);
} catch (error) {
await dispose();
throw error;

Cause, as I read it: after the clone, the default branch is the only local branch. For another branch name, git's checkout guess creates a local branch from origin/<name>, the implicit -b in the message, and git refuses that together with --detach. I did not test tags or commit SHAs.

Possible fix: git fetch --depth 1 origin <ref>, then git checkout --detach FETCH_HEAD. In my test this checks out a non-default branch. It also replaces the full-history clone on each 2-hour refresh with a one-commit fetch. Fetching a commit SHA needs server support, which GitHub has.

What you ruled out

  • Credentials: the repository is public.
  • Duplicates: no open or closed issue mentions this error.

Suggested priority and effort

Low. @origin/<branch> works around it, but you need to know git internals to find that. Effort probably low.

  • I reproduced this on 0.45.0. main at 4b12265 has the same code; I did not test 0.46.0.
  • I searched open and closed issues for the same problem.

AGENT GENERATED

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    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-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions