Skip to content

Bundle transport fails with 'refusing to merge unrelated histories' in shallow checkout #31345

@mrjf

Description

@mrjf

Problem

The bundle transport for push_to_pull_request_branch (#30287) fails in the safe_outputs job because the job uses a shallow checkout (fetch-depth: 1). When git merge --ff-only tries to merge the bundle ref into the local branch, git refuses because the shallow clone doesn't have enough history to find a common ancestor.

[command]/usr/bin/git merge --ff-only refs/bundles/push-autoloop-build-tsb-pandas-typescript-migration
fatal: refusing to merge unrelated histories
##[error]Failed to apply bundle: The process '/usr/bin/git' failed with exit code 128

Reproduction

Every autoloop run on githubnext/tsessebe hits this. The safe_outputs job:

  1. Shallow-clones main (fetch-depth: 1)
  2. Fetches the PR branch (git fetch origin autoloop/build-tsb-pandas-typescript-migration)
  3. Fetches the bundle to refs/bundles/...
  4. Tries git merge --ff-only refs/bundles/...fails: unrelated histories

The bundle contains commits that descend from the PR branch, but the shallow clone doesn't have enough history to see that relationship.

Possible fixes

  1. Unshallow before merge: git fetch --unshallow (or deepen enough to find the merge base)
  2. Use git update-ref instead of git merge --ff-only — directly point the branch at the bundle's HEAD (if the bundle is a strict superset)
  3. Use the GitHub API to update the branch ref instead of local git operations
  4. Increase fetch-depth in the safe_outputs checkout step

Impact

All autoloop programs on githubnext/tsessebe are blocked. Every run since the v0.72.1 upgrade fails at safe_outputs with this error.

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