strategy: don't treat shallow merge-base miss as disconnected metadata · Entire

strategy: don't treat shallow merge-base miss as disconnected metadata

eaada83

On a shallow checkpoint clone, git merge-base reports "no common ancestor" whenever the real ancestor lives below the shallow boundary — git has no objects there. The disconnection check trusted that exit code as proof of disconnection, so an ordinary diverged-but-behind metadata branch on a shallow clone was misread as disconnected. That triggered a full-history cherry-pick reconcile, which then blew MaxCommitTraversalDepth on a deep team branch and aborted both entire push and entire doctor ("commit chain exceeded 1000 commits without reaching root"), leaving doctor looping on a fix that could never succeed.

checkpoint/v1 clones are routinely shallow (resume/explain fetch the tip with --depth=1 via FetchMetadataTreeOnly and nothing deepens them again), so this hit a normal user who fell behind while out of office.

Fix:

With the false positive gone, push rebases the local-only commits onto the remote tip normally and doctor reports OK instead of erroring. Genuine empty-orphan disconnections are still caught (by doctor after deepening, and on push the rebase cap still refuses to combine unrelated histories).

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

Changes

6

64 unmodified lines

// isShallowRepository returns true when the git repository at dir is shallow. // IsShallowRepository returns true when the git repository at dir is shallow. func isShallowRepository(ctx context.Context, dir string) bool {


Mcmd/entire/cli/checkpoint/remote/git.go+3/-3

// checkDisconnectedMetadata detects and optionally repairs disconnected // local/remote metadata branches (the "empty-orphan bug"). func checkDisconnectedMetadata(cmd *cobra.Command, force bool) error {

... // (Function Implementation)

}

// metadataDisconnected reports whether the local and remote metadata commits // share no common ancestor, accounting for shallow clones. func metadataDisconnected(ctx context.Context, repoPath, localHash, remoteHash string) (bool, error) {

... // (Function Implementation)

}

// TestMetadataDisconnected_ShallowSuppressesFalsePositive verifies that a // merge-base miss on a SHALLOW repo is not reported as a disconnection. func TestMetadataDisconnected_ShallowSuppressesFalsePositive(t *testing.T) {

... // (Test Implementation) }

// TestMetadataDisconnected_GenuineDisconnectionOnFullRepo verifies that on a // non-shallow repo a real merge-base miss (two unrelated roots) is still // reported as disconnected. func TestMetadataDisconnected_GenuineDisconnectionOnFullRepo(t *testing.T) {

... // (Test Implementation) }

// Other functions and implementations here.