Skip to content

fix(distribute): prove a sync branch's base past a merge of an older branch - #44

Merged
AlexeyShalaev merged 1 commit into
masterfrom
fix/proof-old-merge
Nov 11, 2026
Merged

AlexeyShalaev merged 1 commit into
masterfrom
fix/proof-old-merge

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

Summary

A sync branch whose commit sits on an older commit of the default branch was blocked as edited ("touchmark's commit … sits on commits that are not on the default branch") as soon as someone merged into the default branch, with a merge commit, a branch with a commit older than a day before that base. The open pull request was paused, and plan --strict failed in the hub's merge requests. Seen on a self-managed GitLab: the merged branch had a commit three days older than the sync branch's base.

The proof fetches the default branch back to a day before the commit it proves (--shallow-since). git cuts that history at a commit with a parent older than the date and drops all of its parents, so the merge of the old branch becomes a shallow boundary, the default branch's own commits below it are never fetched, and merge-base --is-ancestor answers no.

The proof now takes git's "no" only when no shallow boundary in the default branch's history is as new as that date (TargetRepo.ShallowNotBefore). Otherwise it fetches the history below the boundaries deeper by a count of commits (TargetRepo.Deepen, --deepen: 20, then 500) and asks again; what is still cut short after that stays unknown, and the branch stays blocked as before. A branch that sits on someone else's commit costs no extra fetch: no such boundary is in the default branch's history.

TestDeepenOldMerge plays git's cut on a served repository. TestRunBranchOldMerge is the merge in the fake; before the fix it ended blocked:edited.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring / internal

Checklist

  • Tests added or updated
  • make check passes locally (gofmt + go vet + golangci-lint + govulncheck): all but govulncheck, which flags only the standard library of the local Go 1.26.0 (fixed in 1.26.1)
  • The title is a Conventional Commit: it becomes the line in CHANGELOG.md
  • Documentation updated (if a command, flag, configuration key or exit code changed), docs/agents.md included

Related issues

None.

…branch

The proof fetched the default branch back to a day before the commit it
proves (--shallow-since). git cuts that history at a commit with a parent
older than the date and drops all of its parents, so a merge of an old
branch hid the default branch's own commits below it, and a sync branch on
an older base was blocked as edited.

git's "no" now counts only when no shallow boundary in the default
branch's history is as new as that date; otherwise the history below the
boundaries is fetched deeper by a count of commits and asked again.
@AlexeyShalaev
AlexeyShalaev merged commit d17b0a5 into master Nov 11, 2026
22 checks passed
@AlexeyShalaev
AlexeyShalaev deleted the fix/proof-old-merge branch November 11, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant